Ejemplo n.º 1
0
        public static Message SendMessage(this BotClient bot, SendMessageArgs args)
        {
            if (bot == default)
            {
                throw new ArgumentNullException(nameof(bot));
            }

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

            return(bot.RPC <Message>(MethodNames.SendMessage, args));
        }
Ejemplo n.º 2
0
        public static async Task <Message> SendMessageAsync(this BotClient bot, SendMessageArgs args, [Optional] CancellationToken cancellationToken)
        {
            if (bot == default)
            {
                throw new ArgumentNullException(nameof(bot));
            }

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

            return(await bot.RPCA <Message>(MethodNames.SendMessage, args, cancellationToken : cancellationToken).ConfigureAwait(false));
        }
Ejemplo n.º 3
0
        public static Message SendMessage(this BotClient api, long chatId, string text, [Optional] string?parseMode, [Optional] IEnumerable <MessageEntity>?entities, [Optional] bool?disableWebPagePreview, [Optional] bool?disableNotification, [Optional] bool?protectContent, [Optional] int?replyToMessageId, [Optional] bool?allowSendingWithoutReply, [Optional] ReplyMarkup?replyMarkup)
        {
            if (api == default)
            {
                throw new ArgumentNullException(nameof(api));
            }
            var args = new SendMessageArgs(chatId, text)
            {
                ParseMode                = parseMode,
                Entities                 = entities,
                DisableWebPagePreview    = disableWebPagePreview,
                DisableNotification      = disableNotification,
                ProtectContent           = protectContent,
                ReplyToMessageId         = replyToMessageId,
                AllowSendingWithoutReply = allowSendingWithoutReply,
                ReplyMarkup              = replyMarkup
            };

            return(api.RPC <Message>(MethodNames.SendMessage, args));
        }
Ejemplo n.º 4
0
        public static async Task <Message> SendMessageAsync(this BotClient api, string chatId, string text, [Optional] string?parseMode, [Optional] IEnumerable <MessageEntity>?entities, [Optional] bool?disableWebPagePreview, [Optional] bool?disableNotification, [Optional] bool?protectContent, [Optional] int?replyToMessageId, [Optional] bool?allowSendingWithoutReply, [Optional] ReplyMarkup?replyMarkup, [Optional] CancellationToken cancellationToken)
        {
            if (api == default)
            {
                throw new ArgumentNullException(nameof(api));
            }
            var args = new SendMessageArgs(chatId, text)
            {
                ParseMode                = parseMode,
                Entities                 = entities,
                DisableWebPagePreview    = disableWebPagePreview,
                DisableNotification      = disableNotification,
                ProtectContent           = protectContent,
                ReplyToMessageId         = replyToMessageId,
                AllowSendingWithoutReply = allowSendingWithoutReply,
                ReplyMarkup              = replyMarkup
            };

            return(await api.RPCA <Message>(MethodNames.SendMessage, args, cancellationToken : cancellationToken).ConfigureAwait(false));
        }