Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove (not to hide) ReplyKeyboardMarkup in Telegram.Bot using C#?

I'm using Telegram.Bot library in C# for developing telegram bots.

I post a text message using SendTextMessageAsync() method and sent a Keyboard with it :

bot.SendTextMessageAsync(chatId, "sample msg", ParseMode.Default, false, false, 0, new InlineKeyboardMarkup(keyboardData));

I want to remove (not to hide) the keyboard, after click of any user on one of the keyboard buttons, so I use this instruction :

int msgId = bot.SendTextMessageAsync(chatId, "sample msg", ParseMode.Default, false, false, 0, new InlineKeyboardMarkup(keyboardData)).Result;
...
bot.EditMessageReplyMarkupAsync(chatId, msgId, new ReplyKeyboardRemove());

But it doesn't work. Please help me about it.

Meanwhile if I set oneTimeKeyboard to true in ReplyKeyboardMarkup, the keyboard will be hide after user click, but it doesn't removed, only it will be hide and user can make it visible using keyboard button of telegram.

like image 866
Atefeh Ashourzadeh Avatar asked Sep 01 '17 07:09

Atefeh Ashourzadeh


People also ask

How do I get rid of the reply keyboard?

We can remove the displayed keyboard by sending another message and by passing ReplyKeyboardRemove object with it.

What can Telegram bots see?

All bots, regardless of settings, will receive: All service messages. All messages from private chats with users. All messages from channels where they are a member.

Can Telegram bots read messages?

Bot admins and bots with privacy mode disabled will receive all messages except messages sent by other bots. Bots with privacy mode enabled will receive: Commands explicitly meant for them (e.g., /command@this_bot). General commands from users (e.g. /start) if the bot was the last bot to send a message to the group.


2 Answers

I'm afraid, it's too late, but you can use ReplyKeyboardRemove

var send = new SendMessage(update.Message.Chat.Id, "your_text")
{
    ReplyMarkup = new ReplyKeyboardRemove() { RemoveKeyboard = true }
};
await bot.MakeRequestAsync(send);
like image 138
Mehdi Khademloo Avatar answered Sep 22 '22 13:09

Mehdi Khademloo


You can use ReplyKeyboardRemove method to do that.

like image 24
Sean Avatar answered Sep 22 '22 13:09

Sean