This plugin auto answer on callback_query
events with answerCallbackQuery
method if you haven't done it yet.
import { Bot, InlineKeyboard } from "gramio";
import { autoAnswerCallbackQuery } from "@gramio/auto-answer-callback-query";
const bot = new Bot(process.env.BOT_TOKEN as string)
.extend(autoAnswerCallbackQuery())
.command("start", (context) =>
context.send("Hello!", {
reply_markup: new InlineKeyboard()
.text("test", "test")
.text("test2", "test2"),
})
)
.callbackQuery("test", () => {
// The plugin will call an answerCallbackQuery method since you didn't do it
return context.send("Hii");
})
.callbackQuery("test2", (context) => {
// you already answered so plugin won't try to answer
return context.answer("HII");
});
You can pass params for answerCallbackQuery method
bot.extend(
autoAnswerCallbackQuery({
text: "auto-answered",
show_alert: true,
})
);