示例#1
0
        /// <summary>Use this method to stop a poll which was sent by the bot. On success, the stopped Poll with the final results is returned.</summary>
        /// <param name="bot">BotClient</param>
        /// <param name="args">Parameters.</param>
        /// <exception cref="BotRequestException">Thrown when a request to Telegram Bot API got an error response.</exception>
        /// <exception cref="ArgumentNullException">Thrown when a required parameter is null.</exception>
        public static Poll StopPoll(this BotClient bot, StopPollArgs args)
        {
            if (bot == default)
            {
                throw new ArgumentNullException(nameof(bot));
            }

            if (args == default)
            {
                throw new ArgumentNullException(nameof(args));
            }

            return(bot.RPC <Poll>(MethodNames.StopPoll, args));
        }
示例#2
0
        /// <summary>Use this method to stop a poll which was sent by the bot. On success, the stopped Poll with the final results is returned.</summary>
        /// <param name="bot">BotClient</param>
        /// <param name="args">Parameters.</param>
        /// <param name="cancellationToken">The cancellation token to cancel operation.</param>
        /// <exception cref="BotRequestException">Thrown when a request to Telegram Bot API got an error response.</exception>
        /// <exception cref="ArgumentNullException">Thrown when a required parameter is null.</exception>
        public static async Task <Poll> StopPollAsync(this BotClient bot, StopPollArgs args, [Optional] CancellationToken cancellationToken)
        {
            if (bot == default)
            {
                throw new ArgumentNullException(nameof(bot));
            }

            if (args == default)
            {
                throw new ArgumentNullException(nameof(args));
            }

            return(await bot.RPCA <Poll>(MethodNames.StopPoll, args, cancellationToken : cancellationToken).ConfigureAwait(false));
        }
示例#3
0
        /// <summary>Use this method to stop a poll which was sent by the bot. On success, the stopped Poll with the final results is returned.</summary>
        /// <param name="bot">BotClient</param>
        /// <param name="chatId">Unique identifier for the target chat or username of the target channel (in the format @channelusername).</param>
        /// <param name="messageId">Identifier of the original message with the poll</param>
        /// <param name="replyMarkup">A <see cref="InlineKeyboardMarkup"/> object for a new message inline keyboard.</param>
        /// <exception cref="BotRequestException">Thrown when a request to Telegram Bot API got an error response.</exception>
        /// <exception cref="ArgumentNullException">Thrown when a required parameter is null.</exception>
        public static Poll StopPoll(this BotClient bot, long chatId, int messageId, InlineKeyboardMarkup replyMarkup)
        {
            if (bot == default)
            {
                throw new ArgumentNullException(nameof(bot));
            }

            if (replyMarkup == default)
            {
                throw new ArgumentNullException(nameof(replyMarkup));
            }

            var args = new StopPollArgs
            {
                ChatId      = chatId,
                MessageId   = messageId,
                ReplyMarkup = replyMarkup
            };

            return(bot.RPC <Poll>(MethodNames.StopPoll, args));
        }
示例#4
0
        /// <summary>Use this method to stop a poll which was sent by the bot. On success, the stopped Poll with the final results is returned.</summary>
        /// <param name="bot">BotClient</param>
        /// <param name="chatId">Unique identifier for the target chat or username of the target channel (in the format @channelusername).</param>
        /// <param name="messageId">Identifier of the original message with the poll</param>
        /// <param name="replyMarkup">A <see cref="InlineKeyboardMarkup"/> object for a new message inline keyboard.</param>
        /// <param name="cancellationToken">The cancellation token to cancel operation.</param>
        /// <exception cref="BotRequestException">Thrown when a request to Telegram Bot API got an error response.</exception>
        /// <exception cref="ArgumentNullException">Thrown when a required parameter is null.</exception>
        public static async Task <Poll> StopPollAsync(this BotClient bot, string chatId, int messageId, InlineKeyboardMarkup replyMarkup, [Optional] CancellationToken cancellationToken)
        {
            if (bot == default)
            {
                throw new ArgumentNullException(nameof(bot));
            }

            if (replyMarkup == default)
            {
                throw new ArgumentNullException(nameof(replyMarkup));
            }

            var args = new StopPollArgs
            {
                ChatId      = chatId,
                MessageId   = messageId,
                ReplyMarkup = replyMarkup
            };

            return(await bot.RPCA <Poll>(MethodNames.StopPoll, args, cancellationToken : cancellationToken).ConfigureAwait(false));
        }