Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions .claude/skills/add-whatsapp/add/src/channels/whatsapp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,7 @@ export class WhatsAppChannel implements Channel {
);

if (shouldReconnect) {
logger.info('Reconnecting...');
this.connectInternal().catch((err) => {
logger.error({ err }, 'Failed to reconnect, retrying in 5s');
setTimeout(() => {
this.connectInternal().catch((err2) => {
logger.error({ err: err2 }, 'Reconnection retry failed');
});
}, 5000);
});
this.scheduleReconnect(1);
} else {
logger.info('Logged out. Run /setup to re-authenticate.');
process.exit(0);
Expand Down Expand Up @@ -339,6 +331,17 @@ export class WhatsAppChannel implements Channel {
}
}

private scheduleReconnect(attempt: number): void {
const delayMs = Math.min(5000 * Math.pow(2, attempt - 1), 300000);
logger.info({ attempt, delayMs }, 'Reconnecting...');
setTimeout(() => {
this.connectInternal().catch((err) => {
logger.error({ err, attempt }, 'Reconnection attempt failed');
this.scheduleReconnect(attempt + 1);
});
}, delayMs);
}

private async translateJid(jid: string): Promise<string> {
if (!jid.endsWith('@lid')) return jid;
const lidUser = jid.split('@')[0].split(':')[0];
Expand Down
1 change: 1 addition & 0 deletions .claude/skills/add-whatsapp/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ adds:
modifies:
- src/channels/index.ts
- setup/index.ts
- setup/service.ts
structured:
npm_dependencies:
"@whiskeysockets/baileys": "^7.0.0-rc.9"
Expand Down
Loading