Exemple #1
0
        public async Task <Response <Message> > SendVenueAsync(ChatId chatId, float latitude, float longitude,
                                                               string title, string address,
                                                               bool disableNotification   = false, int replyToMessageId = 0,
                                                               InlineKeyboard replyMarkup = null)
        {
            var markup = "";

            if (replyMarkup != null)
            {
                markup = replyMarkup.GetJson();
            }
            var url = Address + Token + "/sendVenue";

            if (latitude < -90 || latitude > 90)
            {
                throw new ArgumentException("latitude must be between -90 and 90");
            }
            if (longitude < -180 || longitude > 180)
            {
                throw new ArgumentException("longitude must be between -180 and 180");
            }

            return(await SendRequest <Response <Message> >(new Dictionary <string, object>
            {
                { "chat_id", chatId.Id },
                { "latitude", latitude },
                { "longitude", longitude },
                { "title", title },
                { "address", address },
                { "disable_notification", disableNotification },
                { "reply_to_message_id", replyToMessageId },
                { "reply_markup", markup },
            }, url));
        }
Exemple #2
0
        public async Task <Response <Message> > SendVideoAsync(ChatId chatId, TelegramFile video, int duration = 0,
                                                               int width  = 0,
                                                               int height = 0, string caption = "",
                                                               bool disableNotification   = false, int replyToMessageId = 0,
                                                               InlineKeyboard replyMarkup = null)
        {
            var markup = "";

            if (replyMarkup != null)
            {
                markup = replyMarkup.GetJson();
            }
            var url = Address + Token + "/sendVideo";

            return(await SendRequest <Response <Message> >(new Dictionary <string, object>
            {
                { "chat_id", chatId.Id },
                { "video", video },
                { "duration", duration },
                { "width", width },
                { "height", height },
                { "caption", caption },
                { "disable_notification", disableNotification },
                { "reply_to_message_id", replyToMessageId },
                { "reply_markup", markup },
            }, url));
        }
Exemple #3
0
        public async Task <Response <Message> > SendAudioAsync(ChatId chatId, TelegramFile audio, string caption = "",
                                                               int duration               = 0,
                                                               string performer           = "", string title = "", bool disableNotification = false, int replyToMessageId = 0,
                                                               InlineKeyboard replyMarkup = null)
        {
            var markup = "";

            if (replyMarkup != null)
            {
                markup = replyMarkup.GetJson();
            }
            var url = Address + Token + "/sendAudio";

            return(await SendRequest <Response <Message> >(new Dictionary <string, object>
            {
                { "chat_id", chatId.Id },
                { "voice", audio },
                { "caption", caption },
                { "performer", performer },
                { "title", title },
                { "duration", duration },
                { "disable_notification", disableNotification },
                { "reply_to_message_id", replyToMessageId },
                { "reply_markup", markup },
            }, url));
        }
Exemple #4
0
        public async Task <Response <Message> > EditMessageReplyMarkupAsync(long inlineMessageId,
                                                                            InlineKeyboard replyMarkup = null)
        {
            var markup = "";

            if (replyMarkup != null)
            {
                markup = replyMarkup.GetJson();
            }
            var methodUrl = Address + Token + "/editMessageReplyMarkup";

            return(await SendRequest <Response <Message> >(new Dictionary <string, object>
            {
                { "inline_message_id", inlineMessageId },
                { "reply_markup", markup },
            }, methodUrl));
        }
Exemple #5
0
        public async Task <Response <Message> > SendStickerAsync(ChatId chatId, TelegramFile sticker,
                                                                 bool disableNotification = false, int replyToMessageId = 0, InlineKeyboard replyMarkup = null)
        {
            var markup = "";

            if (replyMarkup != null)
            {
                markup = replyMarkup.GetJson();
            }
            var methodUrl = Address + Token + "/sendSticker";

            return(await SendRequest <Response <Message> >(new Dictionary <string, object>
            {
                { "chat_id", chatId.Id },
                { "sticker", sticker },
                { "disable_notification", disableNotification },
                { "reply_to_message_id", replyToMessageId },
                { "reply_markup", markup }
            }, methodUrl));
        }
Exemple #6
0
        public async Task <Response <Message> > EditMessageCaptionTextAsync(string text, string inlineMessageId,
                                                                            InlineKeyboard replyMarkup = null, string parseMode = "", bool disableWebPagePreview = false)
        {
            var markup = "";

            if (replyMarkup != null)
            {
                markup = replyMarkup.GetJson();
            }
            var methodUrl = Address + Token + "/editMessageCaption";

            return(await SendRequest <Response <Message> >(new Dictionary <string, object>
            {
                { "text", text },
                { "inline_message_id", inlineMessageId },
                { "reply_markup", replyMarkup },
                { "parse_mode", parseMode },
                { "disable_web_page_preview", disableWebPagePreview }
            }, methodUrl));
        }
Exemple #7
0
        public async Task <Response <Message> > EditMessageCaptionAsync(string caption, ChatId chatId, long messageId,
                                                                        string parseMode = "", bool disableWebPagePreview = false, InlineKeyboard replyMarkup = null)
        {
            var markup = "";

            if (replyMarkup != null)
            {
                markup = replyMarkup.GetJson();
            }
            var methodUrl = Address + Token + "/editMessageCaption";

            return(await SendRequest <Response <Message> >(new Dictionary <string, object>
            {
                { "caption", caption },
                { "chat_id", chatId.Id },
                { "message_id", messageId },
                { "parse_mode", parseMode },
                { "disable_web_page_preview", disableWebPagePreview },
                { "reply_markup", markup }
            }, methodUrl));
        }
Exemple #8
0
        public async Task <Response <Message> > SendMessageAsync(ChatId chatId, string text, string parseMode = "",
                                                                 bool disableWebPagePreview = false, bool disableNotification = false, int replyToMessageId = 0,
                                                                 InlineKeyboard replyMarkup = null)
        {
            var markup = "";

            if (replyMarkup != null)
            {
                markup = replyMarkup.GetJson();
            }
            var url = Address + Token + "/sendMessage";

            return(await SendRequest <Response <Message> >(new Dictionary <string, object>
            {
                { "chat_id", chatId.Id },
                { "text", text },
                { "parse_mode", parseMode },
                { "disable_web_page_preview", disableWebPagePreview },
                { "disable_notification", disableNotification },
                { "reply_to_message_id", replyToMessageId },
                { "reply_markup", markup },
            }, url));
        }
Exemple #9
0
        public async Task <Response <Message> > SendContactAsync(ChatId chatId, string phoneNumber, string firstName,
                                                                 string lastName,
                                                                 bool disableNotification   = false, int replyToMessageId = 0,
                                                                 InlineKeyboard replyMarkup = null)
        {
            var markup = "";

            if (replyMarkup != null)
            {
                markup = replyMarkup.GetJson();
            }
            var url = Address + Token + "/sendContact";

            return(await SendRequest <Response <Message> >(new Dictionary <string, object>
            {
                { "chat_id", chatId.Id },
                { "phoneNumber", phoneNumber },
                { "firstName", firstName },
                { "lastName", lastName },
                { "disable_notification", disableNotification },
                { "reply_to_message_id", replyToMessageId },
                { "reply_markup", markup },
            }, url));
        }