mirror of
https://github.com/koala73/worldmonitor.git
synced 2026-04-25 17:14:57 +02:00
fix(relay): fix telegram ESM import path and broaden latch regex
- `import('telegram/sessions')` fails with "Directory import is not
supported resolving ES modules" — use explicit `telegram/sessions/index.js`
- Broaden permanent-disable latch to also catch "Directory import" errors
This commit is contained in:
@@ -230,7 +230,7 @@ async function initTelegramClientIfNeeded() {
|
||||
|
||||
try {
|
||||
const { TelegramClient } = await import('telegram');
|
||||
const { StringSession } = await import('telegram/sessions');
|
||||
const { StringSession } = await import('telegram/sessions/index.js');
|
||||
|
||||
const client = new TelegramClient(new StringSession(sessionStr), apiId, apiHash, {
|
||||
connectionRetries: 3,
|
||||
@@ -242,7 +242,7 @@ async function initTelegramClientIfNeeded() {
|
||||
console.log('[Relay] Telegram client connected');
|
||||
return true;
|
||||
} catch (e) {
|
||||
if (e?.code === 'ERR_MODULE_NOT_FOUND' || /Cannot find package/.test(e?.message)) {
|
||||
if (e?.code === 'ERR_MODULE_NOT_FOUND' || /Cannot find package|Directory import/.test(e?.message)) {
|
||||
telegramImportFailed = true;
|
||||
telegramState.lastError = 'telegram package not installed';
|
||||
console.warn('[Relay] Telegram package not installed — disabling permanently for this session');
|
||||
|
||||
Reference in New Issue
Block a user