/// <inheritdoc /> /// <summary> /// Sends a text message /// </summary> /// <param name="chat">Chat where the message will be sent</param> /// <param name="message">Message to send</param> /// <param name="parseMode">Message parse mode</param> /// <returns>Async task</returns> public Task SendTextMessageAsync(BotChat chat, string message, MessageParseMode parseMode = MessageParseMode.Default) { var taskSource = new TaskCompletionSource <bool>(TaskCreationOptions.RunContinuationsAsynchronously); _client.SendMessage(received => taskSource.TrySetResult(true), chat.Id, message); return(taskSource.Task); }
public async Task SendTextMessageAsync(BotChat chat, string message, MessageParseMode parseMode = MessageParseMode.Default) { if (!_active) { return; } await _bot.SendTextMessageAsync(chat.Id.ParseTo <long>(-1), message, disableWebPagePreview : DisableWebPagePreview, parseMode : (TBot.Types.Enums.ParseMode)parseMode).ConfigureAwait(false); }
public async Task SendTextMessageAsync(BotChat chat, string message, MessageParseMode parseMode = MessageParseMode.Default) { if (!IsConnected) { return; } Core.Log.LibVerbose("Sending text message. ChatId = {0}, Message = {1}", chat?.Id, message); await Transport.SendTextMessageAsync(chat, message, parseMode).ConfigureAwait(false); Core.Log.LibVerbose("Message sent."); }
public async Task SendTextMessageToTrackedChatsAsync(string message, MessageParseMode parseMode = MessageParseMode.Default) { if (!IsConnected) { return; } Core.Log.LibVerbose("Sending text message to all tracked chats: Chats Count = {0} Message = {1}", TrackedChats.Count, message); foreach (var chat in TrackedChats) { await Transport.SendTextMessageAsync(chat, message, parseMode).ConfigureAwait(false); } Core.Log.LibVerbose("Messages sent."); }