fix: telegram not get message because beyond int i use string solve this problem
Browse files234 unmodified lines23523623723823924024124224324424524624724824925025125225314 unmodified lines268269270271272273274275276277278234 unmodified lines5135145155165175181 unmodified line520521522523524525526234 unmodified linesthrow new Error('Telegram service is not running')}const numericChatId = Number(chatId)logTelegramDebug(`[telegram] sendMessage called: chatId=${chatId} (type: ${typeof chatId}), numericChatId=${numericChatId} (type: ${typeof numericChatId}), text length=${text.length}`)logTelegramDebug(`[telegram] allowedUserIds: ${JSON.stringify(this.config.allowedUserIds)}`)let lastMessageId: number | undefinedfor (const chunk of chunkTelegramMessage(text)) {logTelegramDebug(`[telegram] sending chunk to chat_id: ${numericChatId}`)const response = await this.callTelegram<TelegramSendMessageResponse>(this.config,'sendMessage',{chat_id: numericChatId,text: chunk,...(replyMarkup ? { reply_markup: replyMarkup } : {}),},14 unmodified linesthrow new Error('Telegram service is not running')}await this.callTelegram<TelegramEditMessageResponse>(this.config,'editMessageText',{chat_id: Number(chatId),message_id: messageId,text,...(replyMarkup ? { reply_markup: replyMarkup } : {}),234 unmodified lines: timeoutController.signaltry {const response = await fetch(`${TELEGRAM_API_BASE}/bot${config.botToken}/${method}`,{1 unmodified lineheaders: {'content-type': 'application/json',},body: JSON.stringify(payload),signal: combinedSignal,},)234 unmodified lines23523623723823924024124224324424524624724824925025125225325414 unmodified lines269270271272273274275276277278279280281234 unmodified lines5165175185195205215225235241 unmodified line526527528529530531532234 unmodified linesthrow new Error('Telegram service is not running')}// Telegram API 支持 chat_id 为字符串格式(特别是对于超出安全整数范围的 ID)// 直接使用字符串格式,避免整数溢出问题logTelegramDebug(`[telegram] sendMessage called: chatId=${chatId} (type: ${typeof chatId}), text length=${text.length}`)logTelegramDebug(`[telegram] allowedUserIds: ${JSON.stringify(this.config.allowedUserIds)}`)let lastMessageId: number | undefinedfor (const chunk of chunkTelegramMessage(text)) {logTelegramDebug(`[telegram] sending chunk to chat_id: ${chatId}`)const response = await this.callTelegram<TelegramSendMessageResponse>(this.config,'sendMessage',{chat_id: chatId,text: chunk,...(replyMarkup ? { reply_markup: replyMarkup } : {}),},14 unmodified linesthrow new Error('Telegram service is not running')}// Telegram API 支持 chat_id 为字符串格式(特别是对于超出安全整数范围的 ID)// 直接使用字符串格式,避免整数溢出问题await this.callTelegram<TelegramEditMessageResponse>(this.config,'editMessageText',{chat_id: chatId,message_id: messageId,text,...(replyMarkup ? { reply_markup: replyMarkup } : {}),234 unmodified lines: timeoutController.signaltry {const body = JSON.stringify(payload)logTelegramDebug(`[telegram] API request body: ${body}`)const response = await fetch(`${TELEGRAM_API_BASE}/bot${config.botToken}/${method}`,{1 unmodified lineheaders: {'content-type': 'application/json',},body,signal: combinedSignal,},)
src/services/telegram/TelegramService.ts+12-6