TelegramBots / Telegram.Bot

.NET Client for Telegram Bot API
https://telegrambots.github.io/book
MIT License
3.17k stars 686 forks source link

SendTextMessageAsync strange behavior #585

Closed joaodotneto closed 6 years ago

joaodotneto commented 6 years ago

Hi my friends! I have this strange behavior sending text messages using the method SendTextMessageAsync: When sending the message to the user, I first send a ChatAction (SendChatActionAsync (ID, ChatAction.Typing)). Sending this or not, the message takes more than 30 seconds to send. But if I receive another message while the one I am sending has not yet arrived, the process "unlocks" and the message arrives. I'm forcing the message to not be sent asynchronously, using .GetAwaiter(). GetResult() Are there any settings I should make or something am I doing wrong to make this happen?

Detail: Using GetAwaiter or not the message gets stuck.

Client Instance: this.Client = new TelegramBotClient(this.BotKey); this.Client.OnMessage += Client_OnMessage; this.Client.OnMessageEdited += Client_OnMessage; this.Client.OnReceiveError += Client_OnReceiveError; this.Client.OnReceiveGeneralError += Client_OnReceiveGeneralError; this.Client.StartReceiving();

Sending the Message: Client.SendTextMessageAsync(message.UserInfo.ID, message.TextMessage, ParseMode.Markdown, true, true).GetAwaiter().GetResult();

Thanks in advance.

poulad commented 6 years ago

@joaodotneto please follow issue template. information here isn't enough and don't seem to be a bug report. ask in group chat.

https://github.com/TelegramBots/Telegram.Bot/blob/master/ISSUE_TEMPLATE.md