Implements Telegram user account support via GramJS/MTProto (#937). ## What's New - Complete GramJS channel adapter for user accounts (not bots) - Interactive auth flow (phone → SMS → 2FA) - Session persistence via StringSession - DM and group message support - Security policies (allowFrom, dmPolicy, groupPolicy) - Multi-account configuration ## Files Added ### Core Implementation (src/telegram-gramjs/) - auth.ts - Interactive authentication flow - auth.test.ts - Auth flow tests (mocked) - client.ts - GramJS TelegramClient wrapper - config.ts - Config adapter for multi-account - gateway.ts - Gateway adapter (poll/send) - handlers.ts - Message conversion (GramJS → openclaw) - handlers.test.ts - Message conversion tests - setup.ts - CLI setup wizard - types.ts - TypeScript type definitions - index.ts - Module exports ### Configuration - src/config/types.telegram-gramjs.ts - Config schema ### Plugin Extension - extensions/telegram-gramjs/index.ts - Plugin registration - extensions/telegram-gramjs/src/channel.ts - Channel plugin implementation - extensions/telegram-gramjs/openclaw.plugin.json - Plugin manifest - extensions/telegram-gramjs/package.json - Dependencies ### Documentation - docs/channels/telegram-gramjs.md - Complete setup guide (14KB) - GRAMJS-PHASE1-SUMMARY.md - Implementation summary ### Registry - src/channels/registry.ts - Added telegram-gramjs to CHAT_CHANNEL_ORDER ## Test Coverage - ✅ Auth flow with phone/SMS/2FA (mocked) - ✅ Phone number validation - ✅ Session verification - ✅ Message conversion (DM, group, reply) - ✅ Session key routing - ✅ Command extraction - ✅ Edge cases (empty messages, special chars) ## Features Implemented (Phase 1) - ✅ User account authentication via MTProto - ✅ DM message send/receive - ✅ Group message send/receive - ✅ Reply context preservation - ✅ Security policies (pairing, allowlist) - ✅ Multi-account support - ✅ Session persistence - ✅ Command detection ## Next Steps (Phase 2) - Media support (photos, videos, files) - Voice messages and stickers - Message editing and deletion - Reactions - Channel messages ## Documentation Highlights - Getting API credentials from my.telegram.org - Interactive setup wizard walkthrough - DM and group policies configuration - Multi-account examples - Rate limits and troubleshooting - Security best practices - Migration guide from Bot API Closes #937 (Phase 1)
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
/**
|
|
* Telegram GramJS user account adapter for openclaw.
|
|
*
|
|
* Provides MTProto access to Telegram as a user account (not bot).
|
|
*
|
|
* Features:
|
|
* - User account authentication (phone → SMS → 2FA)
|
|
* - StringSession persistence
|
|
* - Cloud chat access (DMs, groups, channels)
|
|
* - Message sending and receiving
|
|
*
|
|
* Future phases:
|
|
* - Media support (Phase 2)
|
|
* - Secret Chats E2E encryption (Phase 3)
|
|
*/
|
|
|
|
export { GramJSClient } from "./client.js";
|
|
export { AuthFlow, runAuthFlow, verifySession } from "./auth.js";
|
|
export { configAdapter } from "./config.js";
|
|
export { setupAdapter, runSetupFlow } from "./setup.js";
|
|
export { gatewayAdapter, pollMessages, sendMessage } from "./gateway.js";
|
|
export { convertToMsgContext, buildSessionKey, extractSenderInfo } from "./handlers.js";
|
|
|
|
export type {
|
|
ResolvedGramJSAccount,
|
|
AuthState,
|
|
SessionOptions,
|
|
GramJSMessageContext,
|
|
SendMessageParams,
|
|
ConnectionState,
|
|
} from "./types.js";
|
|
|
|
export type {
|
|
TelegramGramJSAccountConfig,
|
|
TelegramGramJSConfig,
|
|
TelegramGramJSActionConfig,
|
|
TelegramGramJSCapabilitiesConfig,
|
|
TelegramGramJSGroupConfig,
|
|
} from "../config/types.telegram-gramjs.js";
|