Skip to content

refactor: telegram.ts monolith — extract tgApi, remove duplicate esc/bold/code/italic, add backoff#991

Merged
OneStepAt4time merged 1 commit intomainfrom
fix/352-telegram-monolith
Apr 3, 2026
Merged

refactor: telegram.ts monolith — extract tgApi, remove duplicate esc/bold/code/italic, add backoff#991
OneStepAt4time merged 1 commit intomainfrom
fix/352-telegram-monolith

Conversation

@OneStepAt4time
Copy link
Copy Markdown
Owner

Summary

Fixes #352 — TelegramChannel monolith refactor.

Changes

  1. Converted tgApi() to private instance method — removed global rateLimitUntil variable, now instance state. Fixes multi-instance and test isolation issues.

  2. Removed duplicate HTML escaping functions — esc(), bold(), code(), italic() were defined identically in both telegram.ts and telegram-style.ts. Now using the telegram-style.ts imports directly.

  3. Added exponential backoff to pollLoop — errors now back off exponentially (1s → 2s → 4s → 8s → 16s → max 30s) instead of fixed 5s sleep. Resets on successful response.

  4. Added pollBackoffMs instance variable — tracks current backoff state for graceful error recovery.

Test Plan

  • tsc --noEmit — clean
  • npm run build — OK
  • npm test — all Aegis tests pass

Developed with: v2.9.3
Tested with: v2.9.3

…te esc/bold/code/italic, add backoff

Fixes #352:
- Converted standalone tgApi() to private instance method (removes global rateLimitUntil)
- Removed duplicate HTML escaping functions (esc, bold, code, italic) — now using telegram-style.ts imports directly
- Added exponential backoff to pollLoop errors (1s → 2s → 4s → 8s → 16s → max 30s)
- Added pollBackoffMs instance variable for graceful error recovery

This resolves test isolation issues and removes ~60 lines of dead duplicated code.
Copy link
Copy Markdown
Contributor

@aegis-gh-agent aegis-gh-agent bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TelegramChannel refactor: tgApi→instance method, duplicate esc/bold/code/italic removed, pollLoop backoff added. Approved.

@OneStepAt4time OneStepAt4time merged commit e68ec13 into main Apr 3, 2026
5 checks passed
@OneStepAt4time OneStepAt4time deleted the fix/352-telegram-monolith branch April 3, 2026 18:09
@OneStepAt4time OneStepAt4time restored the fix/352-telegram-monolith branch April 3, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Architecture: telegram.ts monolith (1516 lines, 5+ concerns)

1 participant