Reputation: 388
I know how to reply the message of users , but I don 't know how to reply the latest message made by the robot .
I need the robot MessageID
this message from user: hi this is a send message to user:
await BotAdminChannel.SendTextMessageAsync(e.Message.Chat.Id, "hello user");
this is reply message from user:
await BotAdminChannel.SendTextMessageAsync(358434970, "How are you user", replyToMessageId:e.Message.MessageId);
but i want reply hello user do i need bot_messageID? how can get it
class Program
{
private static ITelegramBotClient BotAdminChannel = new TelegramBotClient("token");
static void Main(string[] args)
{
BotAdminChannel.OnMessage += BotAdminChannel_OnMessage;
Console.Title = BotAdminChannel.GetMeAsync().Result.FirstName;
BotAdminChannel.StartReceiving();
Console.ReadLine();
}
private async static void BotAdminChannel_OnMessage(object sender, MessageEventArgs e)
{
await BotAdminChannel.SendTextMessageAsync(e.Message.Chat.Id, "hello user");
await BotAdminChannel.SendTextMessageAsync(358434970, "How are you user", replyToMessageId:e.Message.MessageId);
}
}
Upvotes: 5
Views: 20978
Reputation: 41
Hi I hope your doing well, I'm a nooby myself, saw your question and worked a little bit on it and found a way obviously not a professional one but it somehow works
You see the replyToMessageId:
works when followed by an integer and all messages on chats are numbered so you can find the number of the message you want to reply and put it afterwards replyToMessageId:
the code below will reply a message previous to the last message Bot.SendTextMessageAsync(e.Message.Chat.Id,"the text you want",replyToMessageId: e.Message.MessageId-1);
Upvotes: 4
Reputation: 1093
you shold use reply_markup property in SendMessage function and set it to ForceReply.
read more about this in telegram bot api documentation:
Upvotes: 5