Skip to content

Commit

Permalink
Merge pull request #29 from MuNuChapterHKN/develop
Browse files Browse the repository at this point in the history
Fix: send notification to Telegram topic
  • Loading branch information
TellToldTold authored Feb 25, 2024
2 parents 6214d36 + fcd7db3 commit fb53058
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pages/api/telegram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { handleError } from "./application";
const token = process.env.TELEGRAM_TOKEN;
const chatId = process.env.TELEGRAM_CHAT_ID;
const filePath = process.env.COUNTER_FILE_PATH ?? "HKN_APPLY_COUNTER.txt";
const threadId = process.env.TELEGRAM_THREAD_ID ?? 1;

export async function shareNewApply(name: string) {
let counter: number | undefined;
Expand All @@ -22,14 +23,13 @@ export async function shareNewApply(name: string) {
}

export async function sendApplyFailedMessage(stage: string, applicant: string) {
const bot = new TelegramBot(token, { polling: false });
const message = `Apply failed ☠️\n\nStage: ${stage}\n Applicant: ${applicant}`;
await bot.sendMessage(chatId, message);
await sendMessage(message);
}

export async function sendMessage(message: string) {
const bot = new TelegramBot(token, { polling: false });
await bot.sendMessage(chatId, message);
await bot.sendMessage(chatId, message, { message_thread_id: threadId });
}

function readCounter(): number {
Expand Down

0 comments on commit fb53058

Please sign in to comment.