Answer the question
In order to leave comments, you need to log in
C# Telegram Bot | How to remove Inline keyboard after interacting with it?
Good day.
I am writing a bot in C#, new to it.
I want to know how you can remove the keyboard from messages after interacting with it (For example, choosing a language)
public static InlineKeyboardMarkup Lang = new InlineKeyboardMarkup(new[]
{
new[]
{
InlineKeyboardButton.WithCallbackData("Русский", "russian"),
InlineKeyboardButton.WithCallbackData("English", "english")
}
});
private static async void CallbackQueryHandler (string ButText, string UserNames, string username, Int64 userid, string CQID, string MessageId)
{
MySqlConnection DetectLang = new MySqlConnection(connStr);
string lang = "en"; // Lang for user
try
{
// Set lang
if (ButText == "russian" || ButText == "english")
{
string lng;
if (ButText == "russian")
{
lng = "ru";
await Task.Run(() => LangSwitcher(userid, lng));
await Bot.AnswerCallbackQueryAsync(CQID, "Выбран русский язык.");
}
else
{
lng = "en";
await Task.Run(() => LangSwitcher(userid, lng));
await Bot.AnswerCallbackQueryAsync(CQID, "English has been selected.");
}
}
Answer the question
In order to leave comments, you need to log in
We just remove the markup of this message and that's it.
# Edit only the reply markup of messages sent by the bot.
bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question