电报机器人:获取聊天ID组

时间:2019-12-23 12:10:30

标签: c# .net telegram telegram-bot

我已经使用C#创建了一个Telegram Bot,我想看看谁在发送消息时正在使用我的机器人。
当人们通过私人聊天向我的机器人发送消息时,我可以获取信息,但是在网上论坛中,我无法获取正在使用Bot的用户名,并且该用户名返回了GroupName。

我使用的方法是

var me = Bot.GetChatAsync(e.Message.Chat.Id).Result;

2 个答案:

答案 0 :(得分:0)

doc中,该字段User对于组是可选的。

答案 1 :(得分:0)

您可以看到谁在Future<void> addBookingConversation(Booking booking) async { Conversation conversation = Conversation(); await conversation.addConversationToFirestore(booking.posting.host); //additional method working fine String text = "Hi, my name is ${AppConstants.currentUser.firstName}"; await conversation.addMessageToFirestore(text); //additional method working fine //this is where i should navigate to the conversation page and facing the error here Navigator.push( context, //error here context undefined MaterialPageRoute(builder: (context) => ConversationPage(conversation: conversation,), ), ); } 中发送消息,此属性返回谁以class ConversationPage extends StatefulWidget { final Conversation conversation; static final String routeName = '/conversationPageRoute'; ConversationPage({this.conversation, Key key}) : super(key: key); @override _ConversationPageState createState() => _ConversationPageState(); } class _ConversationPageState extends State<ConversationPage> { Conversation _conversation; // additional code of wiget build } 的身份发送消息。

并且您应该等待可等待的方法。


对于您的情况e.Message.From,它将从ChatId返回User

这意味着:有关来自ID的聊天的信息。

您将Bot.GetChatAsync而不是Chat传递给Chat

相关问题