wiki search people tested pipeline
This commit is contained in:
24
sandbox/tgbot/bot.mjs
Normal file
24
sandbox/tgbot/bot.mjs
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Bot } from "grammy";
|
||||
|
||||
const BOT_TOKEN = "8428861272:AAH9V_I-ZLk9CsS1-_KnNT77I28WTrzwl4A";
|
||||
|
||||
const bot = new Bot(BOT_TOKEN);
|
||||
|
||||
bot.on("message", (ctx) => {
|
||||
const chatId = ctx.chat.id;
|
||||
const text = ctx.msg.text ?? "(no text)";
|
||||
const from = ctx.from?.username ?? ctx.from?.first_name ?? "unknown";
|
||||
console.log(`[MSG] chat_id=${chatId} from=${from} text="${text}"`);
|
||||
ctx.reply(`Your chat_id is: ${chatId}`);
|
||||
});
|
||||
|
||||
bot.command("start", (ctx) => {
|
||||
const chatId = ctx.chat.id;
|
||||
console.log(`[START] chat_id=${chatId}`);
|
||||
ctx.reply(`Hello! Your chat_id is: ${chatId}\nUse this in Zabbix media settings.`);
|
||||
});
|
||||
|
||||
console.log("Bot starting (polling)...");
|
||||
bot.start({
|
||||
onStart: (info) => console.log(`Bot @${info.username} is running. Send a message to get your chat_id.`),
|
||||
});
|
||||
Reference in New Issue
Block a user