(ctx: AdapterContext)
| 48 | } |
| 49 | |
| 50 | async start(ctx: AdapterContext): Promise<void> { |
| 51 | this.agent = ctx.agent; |
| 52 | this.rootDir = ctx.rootDir; |
| 53 | this.ipcBroadcaster = ctx.ipcBroadcaster ?? null; |
| 54 | |
| 55 | this.bot = new TelegramBot(this.options.token, { polling: true }); |
| 56 | |
| 57 | this.bot.on("message", (msg) => { |
| 58 | this.handleTelegramMessage(msg).catch((err) => { |
| 59 | console.error("[Telegram] Error handling message:", err); |
| 60 | }); |
| 61 | }); |
| 62 | |
| 63 | // Register bot commands with Telegram |
| 64 | await this.bot.setMyCommands(getTelegramBotCommands()); |
| 65 | |
| 66 | const me = await this.bot.getMe(); |
| 67 | console.log(`[TelegramAdapter] Started as @${me.username}`); |
| 68 | } |
| 69 | |
| 70 | async stop(): Promise<void> { |
| 71 | if (this.bot) { |
no test coverage detected