/// <summary> /// Edits captions of the message with the provided identifier sent by the bot or via the bot (for /// inline bots). /// </summary> /// <param name="inlineMessageId">Identifier of the inline message.</param> /// <param name="caption">New caption of the message.</param> /// <param name="replyMarkup"> /// An <see cref="InlineKeyboardMarkup" /> object for a custom reply keyboard. /// </param> /// <param name="cancellationToken"> /// A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to /// complete. /// </param> /// <returns> /// A task that represents the asynchronous operation. On success the task results contains the edited /// Message is returned. /// </returns> public Task <Message> EditMessageCaptionAsync([NotNull] string inlineMessageId, [NotNull] string caption, InlineKeyboardMarkup replyMarkup = null, CancellationToken cancellationToken = default(CancellationToken)) { Contracts.EnsureNotNull(inlineMessageId, nameof(inlineMessageId)); return(this.EditMessageCaptionAsync(null, 0, inlineMessageId, caption, replyMarkup, cancellationToken)); }
/// <summary> /// Edits captions of the message with the provided identifier sent by the bot or via the bot (for /// inline bots). /// </summary> /// <param name="chatId"> /// Unique identifier for the target chat or username of the target channel (in the format /// @channelusername). /// </param> /// <param name="messageId">Unique identifier of the sent message.</param> /// <param name="caption">New caption of the message.</param> /// <param name="replyMarkup"> /// An <see cref="InlineKeyboardMarkup" /> object for a custom reply keyboard. /// </param> /// <param name="cancellationToken"> /// A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to /// complete. /// </param> /// <returns> /// A task that represents the asynchronous operation. On success the task results contains the edited /// Message is returned. /// </returns> public Task <Message> EditMessageCaptionAsync(long chatId, long messageId, [NotNull] string caption, InlineKeyboardMarkup replyMarkup = null, CancellationToken cancellationToken = default(CancellationToken)) { Contracts.EnsurePositiveNumber(chatId, nameof(chatId)); return(this.EditMessageCaptionAsync(chatId.ToString(), messageId, caption, replyMarkup, cancellationToken)); }
/// <summary> /// Edits text messages sent by the bot or via the bot (for inline bots). /// </summary> /// <param name="chatId"> /// Unique identifier for the target chat or username of the target channel (in the format /// @channelusername). /// </param> /// <param name="messageId">Unique identifier of the sent message.</param> /// <param name="text">New text of the message</param> /// <param name="parseMode"> /// A value from <see cref="ParseMode" /> enum indicates the way that the Telegram should parse the /// sent message. Send <see cref="ParseMode.Markdown" />, if you want Telegram apps to show bold, /// italic, fixed-width text or inline URLs in your bot's message. /// </param> /// <param name="disableWebPagePreview">Disables link previews for links in this message</param> /// <param name="replyMarkup"> /// An <see cref="InlineKeyboardMarkup" /> object for a custom reply keyboard. /// </param> /// <param name="cancellationToken"> /// A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to /// complete. /// </param> /// <returns> /// A task that represents the asynchronous operation. The task results contains the edited /// <see cref="Message" /> on success. /// </returns> public Task <Message> EditMessageTextAsync(long chatId, long messageId, [NotNull] string text, ParseMode parseMode = ParseMode.Normal, bool disableWebPagePreview = false, InlineKeyboardMarkup replyMarkup = null, CancellationToken cancellationToken = default(CancellationToken)) { Contracts.EnsurePositiveNumber(chatId, nameof(chatId)); return(this.EditMessageTextAsync(chatId.ToString(), messageId, text, parseMode, disableWebPagePreview, replyMarkup, cancellationToken)); }
/// <summary> /// Edits text messages sent by the bot or via the bot (for inline bots). /// </summary> /// <param name="inlineMessageId">The identifier of the inline message.</param> /// <param name="text">New text of the message</param> /// <param name="parseMode"> /// A value from <see cref="ParseMode" /> enum indicates the way that the Telegram should parse the /// sent message. Send <see cref="ParseMode.Markdown" />, if you want Telegram apps to show bold, /// italic, fixed-width text or inline URLs in your bot's message. /// </param> /// <param name="disableWebPagePreview">Disables link previews for links in this message</param> /// <param name="replyMarkup"> /// An <see cref="InlineKeyboardMarkup" /> object for a custom reply keyboard. /// </param> /// <param name="cancellationToken"> /// A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to /// complete. /// </param> /// <returns> /// A task that represents the asynchronous operation. The task results contains the edited /// <see cref="Message" /> on success. /// </returns> public Task <Message> EditMessageTextAsync([NotNull] string inlineMessageId, [NotNull] string text, ParseMode parseMode = ParseMode.Normal, bool disableWebPagePreview = false, InlineKeyboardMarkup replyMarkup = null, CancellationToken cancellationToken = default(CancellationToken)) { Contracts.EnsureNotNull(inlineMessageId, nameof(inlineMessageId)); return(this.EditMessageTextAsync(null, 0, inlineMessageId, text, parseMode, disableWebPagePreview, replyMarkup, cancellationToken)); }
/// <summary> /// Unbans a previously kicked user in a supergroup. The user will not return to the group /// automatically, but will be able to join via link, etc. The bot must be an administrator in the /// group for this to work. /// </summary> /// <param name="chatId">Unique identifier for the target group.</param> /// <param name="userId">Unique identifier of the target user.</param> /// <param name="cancellationToken"> /// A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to /// complete. /// </param> /// <returns> /// A task that represents the asynchronous operation. The task results contains <c>true</c> on /// success. /// </returns> /// <remarks> /// Note: This will method only work if the ‘All Members Are Admins’ setting is off in the target /// group. Otherwise members may only be removed by the group's creator or by the member that added /// them. /// </remarks> /// <exception cref="System.ArgumentNullException">chatId cannot be null.</exception> /// <exception cref="System.ArgumentException">userId must be a number greater than zero.</exception> public Task <bool> UnbanChatMemberAsync(long chatId, long userId, CancellationToken cancellationToken = default(CancellationToken)) { Contracts.EnsureNotZero(chatId, nameof(chatId)); return(this.KickChatMemberAsync(chatId.ToString(), userId, cancellationToken)); }
/// <summary> /// Returns basic info about a file and prepare it for downloading. For the moment, bots can download /// files of up to 20MB in size. /// </summary> /// <param name="fileId">The file identifier.</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, a <see cref="Types.File" /> object containing basic info about the file to download. /// </returns> public Task <File> GetFileAsync([NotNull] string fileId, CancellationToken cancellationToken = default(CancellationToken)) { Contracts.EnsureNotNull(fileId, nameof(fileId)); return(this.CallTelegramMethodAsync <File>(cancellationToken, $"getFile?file_id={fileId}")); }