Commit Graph

3 Commits

Author SHA1 Message Date
Arne Moor
1f959a188f chore: apply biome formatting
Applied formatting fixes to 21 files:
- Fixed import ordering
- Normalized indentation
- Wrapped long lines

No logic changes, formatting only.
2025-12-06 18:45:25 +01:00
Arne Moor
31246f0a34 fix: telegram allowFrom matching and entity resolution
Fixes three critical bugs in Telegram integration:

1. Case-insensitive username matching
   - Telegram usernames are case-insensitive, but the API returns them with original casing
   - Now lowercase all usernames when extracting sender identifier to match config entries
   - Fixes: messages from @ArneMoor now match config entry telegram:@arnemoor

2. Entity resolution for sending replies
   - resolveEntity() now strips telegram: prefix before resolving users/chats
   - Fixes: "Could not resolve Telegram entity: telegram:@username" errors when sending replies

3. Improved skip logging
   - Messages skipped due to allowFrom filtering now always logged (not just in verbose mode)
   - Uses clear emoji indicator: ⏭️ Skipped message from...
2025-12-06 10:19:19 +01:00
Arne Moor
69608fd305 feat: add telegram provider with CLI integration
Add Telegram as a third messaging provider alongside web and twilio.

Core Features:
- Interactive login flow with phone/SMS/2FA authentication
- Send text and media messages (images, videos, audio, documents)
- Monitor incoming messages with auto-reply support
- Session management at ~/.clawdis/telegram/session/
- Full CLI integration (login, logout, status, send, relay commands)

Implementation Details:
- Uses telegram npm package for MTProto API access
- Supports both URL and local file media sending
- Cross-platform path handling (Windows/Unix)
- Optional Twilio env vars (supports Telegram-only usage)
- Minimal provider abstraction pattern
- Comprehensive test coverage (440 tests passing)

Changes:
- Add Telegram module (client, login, monitor, inbound, outbound, session)
- Add provider factory and base interfaces
- Wire Telegram functions into CLI deps
- Update env validation to make Twilio fields optional
- Add telegram to all CLI commands (login, logout, status, send, relay)
- Add null checks in Twilio code for optional env fields
- Fix send command to properly load session and connect
- Add local file support with cross-platform path handling
- Update login message to show correct ~/.clawdis path
- Add comprehensive tests and documentation

Basic Usage:
  warelay login --provider telegram
  warelay send --provider telegram --to "@user" --message "Hi"
  warelay send --provider telegram --to "@user" --media "/path/to/file.jpg"
  warelay relay --provider telegram

All tests pass (63 files, 440 tests). Zero TypeScript errors.
2025-12-05 18:59:38 +01:00