Answer the question
In order to leave comments, you need to log in
How to write a news suggestion bot?
Hello everyone, I decided to write a bot for my telegram channel, with which users can offer news, and these news will be sent to me:
1. The user clicks on one of the four buttons:
bot.on("message", (msg) => {
const { id } = msg.chat;
bot.sendMessage(
id,
"Привет, " +
msg.from.first_name +
". Я бот для предложки новостей",
options
);
});
var options = {
reply_markup: {
inline_keyboard: [
[{ text: "Предложить новость 1", callback_data: "news1" }],
[{ text: "Предложить новость 2", callback_data: "news2" }],
],
},
};
bot.on("callback_query", function onCallbackQuery(callbackQuery) {
const action = callbackQuery.data;
const msg = callbackQuery.message;
const opts = {
chat_id: msg.chat.id,
message_id: msg.message_id,
};
let text;
if (action === "news1") {
text =
"Вы можете написать ваш вопрос который касается страны";
}
if (action === "news2") {
text =
"Вы можете написать ваш вопрос который касается города";
}
}
bot.editMessageText(text, opts);
});
Answer the question
In order to leave comments, you need to log in
1. Along with the bot's response (text), I want to have a "Back" button that would return to the first item (choosing what kind of news to offer).
2. After the user writes the news, I want to show him a message that this news will be published. And the text of the news was sent to me.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question