[英]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.