| 136 | * user id, which doesn't make sense. Use group chats for automated mode. |
| 137 | */ |
| 138 | export async function sendMessageAsSenderBot( |
| 139 | chatId: string | number, |
| 140 | text: string, |
| 141 | opts: { replyToMessageId?: number } = {}, |
| 142 | ): Promise<TelegramMessage> { |
| 143 | if (!SENDER_BOT_TOKEN) { |
| 144 | throw new Error( |
| 145 | "TELEGRAM_SENDER_BOT_TOKEN not set — automated send unavailable", |
| 146 | ); |
| 147 | } |
| 148 | const params: Record<string, unknown> = { chat_id: chatId, text }; |
| 149 | if (opts.replyToMessageId) params.reply_to_message_id = opts.replyToMessageId; |
| 150 | return tgApi<TelegramMessage>(SENDER_BOT_TOKEN, "sendMessage", params); |
| 151 | } |
| 152 | |
| 153 | // ── Polling helpers ─────────────────────────────────────────────────────────── |
| 154 | |