0
votes

I've created a Telegram Bot using C# and I want to see who is using my bot when sending message.
I can get when people send a message to my bot in private chat but in the Groups, I can't get Username who is using Bot and it's return the GroupName.

The method I use is

var me = Bot.GetChatAsync(e.Message.Chat.Id).Result;
2
BTW, use of var is only necessary when dealing with anonymous types... try to use explicit type instead of var. (IDE0008) - Yousha Aleayoub
My problem is its return name of telegram group - this_isName
After any await method using, await it and don't put .Result The code will get error... - Muaath

2 Answers

0
votes

From doc this field User is optional for groups.

0
votes

You can see who send message in e.Message.From, this property returns who send it as User.

And you should await methods that is awaitable.


And in your case Bot.GetChatAsync, this will return Chat from ChatId.

It means: Info about chat from Id.

And you pass Chat not ChatId to Bot.GetChatAsync