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
Answers
From doc this field
User
is optional for groups.You can see who send message in
e.Message.From
, this property returns who send it asUser
.And you should await methods that is awaitable.
And in your case
Bot.GetChatAsync
, this will returnChat
from ChatId.It means: Info about chat from Id.
And you pass
Chat
notChatId
toBot.GetChatAsync