수정완료

This commit is contained in:
kjy
2025-12-28 22:35:32 +09:00
parent dd854cac08
commit 151d3a0908
11 changed files with 101 additions and 157 deletions

View File

@@ -1,6 +1,8 @@
import TelegramBot from "node-telegram-bot-api";
import fs from "fs";
process.env.NTBA_FIX_350 = "1";
export interface TelegramUser {
site: string;
chatId: number;
@@ -108,7 +110,10 @@ export class TelegramService {
constructor(token: string, enablePolling: boolean = false) {
this.token = token;
this.bot = new TelegramBot(token, { polling: enablePolling });
this.bot = new TelegramBot(token, {
polling: enablePolling,
filepath: false,
});
if (enablePolling) {
this.setupListeners();
@@ -149,16 +154,15 @@ export class TelegramService {
caption?: string
): Promise<void> {
try {
const buffer = Buffer.from(await Bun.file(fileName).arrayBuffer());
await this.bot.sendDocument(
chatId,
fs.createReadStream(fileName),
{
caption: caption || "",
},
buffer,
{ caption: caption || "" },
{
filename: fileName.split("/").pop(),
contentType:
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
contentType: "application/octet-stream",
}
);
console.log(`✅ 문서 전송 성공 - chatId: ${chatId}, file: ${fileName}`);