S
S
Sergey Twin2020-05-02 15:36:18
C++ / C#
Sergey Twin, 2020-05-02 15:36:18

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)

5ead6f7da5860802694011.png

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

1 answer(s)
A
Andrey_Dolg, 2020-05-02
@SergeyTwin

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)

And does the bot have a lot of proxies or is it sharing of the main available lists and services?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question