Surf Studio commited on
Commit
56c49e4
·
1 Parent(s): fd6a697

tg: tracked chats every 20s; polling is the primary path for channels

Browse files
Files changed (2) hide show
  1. lib/scheduler.js +1 -1
  2. lib/tg/index.js +3 -3
lib/scheduler.js CHANGED
@@ -47,7 +47,7 @@ function start() {
47
  every('x-profiles', 180000, () => xscan.profileTick(), 40000)
48
  every('tg-watchdog', 60000, () => tg.watchdog(), 60000)
49
  every('tg-poll', 30000, () => tg.pollDialogs(), 60000)
50
- every('tg-catchup', 120000, () => tg.catchup(), 100000)
51
  every('tg-global', 180000, () => tg.globalSearch(), 130000)
52
  every('keepalive', 20 * 60000, keepAlive, 60000)
53
  tg.start().catch((err) => log.fail('telegram', err))
 
47
  every('x-profiles', 180000, () => xscan.profileTick(), 40000)
48
  every('tg-watchdog', 60000, () => tg.watchdog(), 60000)
49
  every('tg-poll', 30000, () => tg.pollDialogs(), 60000)
50
+ every('tg-catchup', 20000, () => tg.catchup(), 70000)
51
  every('tg-global', 180000, () => tg.globalSearch(), 130000)
52
  every('keepalive', 20 * 60000, keepAlive, 60000)
53
  tg.start().catch((err) => log.fail('telegram', err))
lib/tg/index.js CHANGED
@@ -467,11 +467,11 @@ async function pollNow() {
467
  state.polled += read
468
  state.missedByRealtime += missed
469
  if (fresh) log.info('telegram', `轮询补到 ${fresh} 条相关消息`)
470
- // Realtime looks dead: several messages arrived that no event reported.
471
- if (missed >= 3 && Date.now() - lastReset > 15 * 60000) {
 
472
  lastReset = Date.now()
473
  state.realtimeResets += 1
474
- log.warn('telegram', `实时推送漏了 ${missed} 条消息,重启接收`)
475
  restartUpdates().catch(() => {})
476
  }
477
  log.ok('tg-poll', { dialogs: dialogs.length, changed, read, fresh, missed })
 
467
  state.polled += read
468
  state.missedByRealtime += missed
469
  if (fresh) log.info('telegram', `轮询补到 ${fresh} 条相关消息`)
470
+ // Telegram rarely pushes big-channel posts to user accounts, so polling is the main path for
471
+ // channels. Re-subscribing once in a while is harmless and helps for small groups / DMs.
472
+ if (missed >= 3 && Date.now() - lastReset > 60 * 60000) {
473
  lastReset = Date.now()
474
  state.realtimeResets += 1
 
475
  restartUpdates().catch(() => {})
476
  }
477
  log.ok('tg-poll', { dialogs: dialogs.length, changed, read, fresh, missed })