简体   繁体   English

回复消息电报机器人

[英]reply message telegram bot

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我需要机器人 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?但我想回复你好用户我需要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);
    }
}

you shold use reply_markup property in SendMessage function and set it to ForceReply .您应该在SendMessage函数中使用reply_markup属性并将其设置为ForceReply

read more about this in telegram bot api documentation:在电报机器人 API 文档中阅读更多相关信息:

嗨,我希望你做得好,我自己是个菜鸟,看到你的问题并做了一些工作,找到了一种显然不是专业的方法,但它以某种方式起作用你看到了replyToMessageId:后跟一个整数时起作用聊天中的消息已编号,因此您可以找到要回复的消息的编号,然后将其放在replyToMessageId:之后replyToMessageId:下面的代码将在最后一条消息之前回复一条消息Bot.SendTextMessageAsync(e.Message.Chat.Id,"the text you want",replyToMessageId: e.Message.MessageId-1);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM