简体   繁体   English

我如何使用电报API在C#中接收电报消息

[英]How can i receive telegram message in C# using Telegram API

I am using this telegram C# library .I am able to send the messages but Couldn't find a way how to receive messages in this library. 我正在使用此电报C#库 。我能够发送消息,但无法在该库中找到如何接收消息的方法。 Please assist me. 请帮我。

Thanks in advance. 提前致谢。

似乎该库仅支持某些功能,可能不支持接收,因为该文档中未提及该接收器,因此没有测试。

I have this functionality(and many other) implemented in my fork 我在fork中实现了此功能(以及许多其他功能)

You need to create TelegramClient instance, subscribe to UpdateMessage event and call Start method. 您需要创建TelegramClient实例,订阅UpdateMessage事件并调用Start方法。

var client = new TelegramClient(null/*sessionStore*/, apiId, apiHash);
client.UpdateMessage += (sender, updates) =>
{
      switch (updates.constructor)
      {
          case Constructor.UpdatesTooLong: { break; }
          case Constructor.UpdateShortMessage: { break; }
          case Constructor.UpdateShortChatMessage: { break; }
          case Constructor.UpdateShort: { break; }
          case Constructor.UpdatesCombined: { break; }
          case Constructor.Updates: { break; }
      }
};
await client.Start();

For list of possible Update object constructors see this 对于可能的更新对象构造的列表,请参阅

I am not sure about this api you have mentioned, but if receiving messages is not supported in that one, I suggest using this one 我不确定您提到的该API,但是如果该API不支持接收消息,则建议您使用 API

I been using it since almost 1 year ago, I made a Fun bot for my university group where people can teach the bot what to answer to certain messages it receives. 自从大约一年前开始使用它,我为我的大学团队制作了一个Fun机器人,人们可以教该机器人如何响应收到的某些消息。 The usage is pretty simple and it have an example you can learn from . 用法很简单,并且有一个您可以从中学到的例子。

You can also check my bot here and see its functionality. 您也可以在此处检查我的机器人并查看其功能。

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

相关问题 如何使用Telegram bot API C#检查电报消息类型? - How to check telegram message type with Telegram bot api C#? 如何使用 asp.net 和 c# 发送电报消息? - How can I send telegram message using asp.net and c#? 如何在 C# 中使用 Telegram API 发送消息 - How to use Telegram API in C# to send a message C# WTelegramClient Telegram-API 如何以编程方式单击来自 Telegram-Bot 的消息中的按钮 - C# WTelegramClient Telegram-API How to programmatically click a button in a message from Telegram-Bot 如何使用 C# 使键盘按钮消息文本与其在 Telegram bot API 中的标题不同 - How to make Keyboard Button message text different from its caption in Telegram bot API using C# 如何使用 C# 中的 API 从机器人添加组中的电报读取用户发送消息 - how to read user send message from telegram in bot added group using API in C# 如何使用 Telegram API 从 Telegram 频道获取消息 - How can I get messages from a Telegram channel with the Telegram API 如何在 C# 中使用 Telegram Api 和 SharpTelegram - How Use Telegram Api in C# WIth SharpTelegram 如何使用C#在Telegram bot中创建自定义键盘? - How can i create custome keyboard in telegram bot with c#? 如何使用 c# 在电报机器人中使用斜杠命令列表而不是键盘按钮? - How can i do slash command list instead keyboard buttons in telegram bot using c#?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM