'Telegraft (Javascript) : How do I return the function in telegram keyboard or inline keyboard?
I want to return a function I tried replacing the "Yes" It doesn't work, when I look at the function itself, it only accepts string,
thus I'm puzzled, because if I use bot.hear in telegraf, any person who says yes, will activate the command.
is there anyway to call a function ?
bot.command("report", (ctx) => {
ctx.reply("Are you sure? using this will have a refresh timeout of 2 minutes.", {
reply_markup: {
keyboard: [
/* Inline buttons. 2 side-by-side */
[{ text: "Yes", callback_data: test() }, { text: "No", callback_data: "No" }],
/* One button */
[{ text: "Next", callback_data: "next" }],
/* Also, we can have URL buttons. */
[{ text: "Open in browser", url: "telegraf.js.org" }]
]
}
});
});
const test = () => {
console.log("test")
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
