[英]How to find if a the sending message by a telegram bot has been sent to the channel correctly in c#?
I have designed a telegram bot (c# winforms project) which sends messages to a telegram channel.我设计了一个电报机器人(c# winforms 项目),它将消息发送到电报频道。 I want to find if my sending message in the last try has been sent to the channel correctly or not?
我想查看我上次尝试的发送消息是否已正确发送到频道? Is there a way to find that?
有没有办法找到它?
I am using the following code in order to send my message:我正在使用以下代码来发送我的消息:
string chatId = "@MyChannel";
string testMessage = "Hello Channel";
bot.SendTextMessageAsync(chatId, testMessage, ParseMode.Html);
You can use it by defining message, because SendTextMessageAsync
method returns message on success (see Telegram API docs ), do like this:您可以通过定义消息来使用它,因为
SendTextMessageAsync
方法在成功时返回消息(请参阅Telegram API 文档),这样做:
Message msg = await bot.SendTextMessageAsync(chatId, testMessage, ParseMode.Html);
if (msg is null)
{
// Message didn't arrive!
}
else
{
// Message Arrived successfully!
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.