/// <summary> /// Sends a chat action. Use this method when you need to tell the user that something is happening on /// the bot's side. /// </summary> /// <param name="chatId"> /// Unique identifier for the message recipient or username of the target channel (in the format /// @channelusername). /// </param> /// <param name="action">Type of action to broadcast.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of /// cancellation. /// </param> /// <returns> /// On success, returns the sent <see cref="Message" />. /// </returns> /// <remarks> /// Use this method when you need to tell the user that something is happening on the bot's side. The /// status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear /// its typing status). /// <example> /// The <c>ImageBot</c> needs some time to process a request and upload the image. Instead of sending a /// text message along the lines of "Retrieving image, please wait…", the bot may use /// <see cref="SendChatActionAsync(string,Taikandi.Telebot.Types.ChatAction,System.Threading.CancellationToken)" /> /// with action = upload_photo. The user will see a "sending photo" status for the bot. /// </example> /// </remarks> public Task<bool> SendChatActionAsync([NotNull] string chatId, ChatAction action, CancellationToken cancellationToken = default(CancellationToken)) { Contracts.EnsureNotNull(chatId, nameof(chatId)); var parameters = new NameValueCollection { { "action", action.Value } }; return this.CallTelegramMethodAsync<bool>(cancellationToken, "sendChatAction", parameters, chatId); }
/// <summary> /// Sends a chat action. Use this method when you need to tell the user that something is happening on /// the bot's side. /// </summary> /// <param name="chatId">Unique identifier for the message recipient.</param> /// <param name="action">Type of action to broadcast.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of /// cancellation. /// </param> /// <returns> /// On success, returns the sent <see cref="Message" />. /// </returns> /// <remarks> /// Use this method when you need to tell the user that something is happening on the bot's side. The /// status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear /// its typing status). /// <example> /// The <c>ImageBot</c> needs some time to process a request and upload the image. Instead of sending a /// text message along the lines of "Retrieving image, please wait…", the bot may use /// <see cref="SendChatActionAsync(long,ChatAction,CancellationToken)" /> /// with action = upload_photo. The user will see a "sending photo" status for the bot. /// </example> /// </remarks> public Task<bool> SendChatActionAsync(long chatId, ChatAction action, CancellationToken cancellationToken = default(CancellationToken)) { Contracts.EnsureNotZero(chatId, nameof(chatId)); return this.SendChatActionAsync(chatId.ToString(), action, cancellationToken); }