/// <summary> /// Use this method to send text messages. On success, the sent Message is returned. /// </summary> /// <param name="chatId">Unique identifier for the message recipient — User or GroupChat id</param> /// <param name="text">Text of the message to be sent</param> /// <param name="disableWebPagePreview">Disables link previews for links in this message</param> /// <param name="replyToMessageId">If the message is a reply, ID of the original message</param> /// <param name="replyMarkup">Additional interface options. A <see cref="ITelegramKeyboard"/> object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.</param> /// <returns>The sent <see cref="Message"/></returns> public async Task<Message> SendMessageAsync(int chatId, string text, bool? disableWebPagePreview = null, int? replyToMessageId = null, ITelegramKeyboard replyMarkup = null) { IRestRequest request = CreatePostRestRequest("sendMessage"); request.AddParameter("chat_id", chatId); request.AddParameter("text", text); request.AddParameter("disable_web_page_preview", disableWebPagePreview); request.AddParameter("reply_to_message_id", replyToMessageId); request.AddParameter("reply_markup", JsonConvert.SerializeObject(replyMarkup)); IRestResponse response = _restClient.Execute(request); return await PrepareResult<Message>(response.Content); }
/// <summary> /// Use this method to send photos. On success, the sent Message is returned. /// </summary> /// <param name="chatId">Unique identifier for the message recipient — User or GroupChat id</param> /// <param name="fileName">The name of the file including the extension</param> /// <param name="inputFile">Photo to send. Uploads a new photo using multipart/form-data.</param> /// <param name="caption">Photo caption (may also be used when resending photos by file_id).</param> /// <param name="replyToMessageId">If the message is a reply, ID of the original message</param> /// <param name="replyMarkup">Additional interface options. A <see cref="ITelegramKeyboard"/> object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.</param> public async Task<Message> SendPhotoAsync(int chatId, string fileName, byte[] inputFile, string caption = null, int? replyToMessageId = null, ITelegramKeyboard replyMarkup = null) { IRestRequest request = CreatePostRestRequest("sendPhoto"); request.AddParameter("chat_id", chatId); request.AddParameter("caption", caption); request.AddParameter("reply_to_message_id", replyToMessageId); request.AddParameter("reply_markup", JsonConvert.SerializeObject(replyMarkup)); request.AddFile("photo", inputFile, fileName); IRestResponse response = _restClient.Execute(request); return await PrepareResult<Message>(response.Content); }
public Message SendMessage(int chatId, string text, bool? disableWebPagePreview = null, int? replyToMessageId = null, ITelegramKeyboard replyMarkup = null) { return SendMessageAsync(chatId, text, disableWebPagePreview, replyToMessageId, replyMarkup).Result; }
public Message SendAudio(int chatId, string audio, int? duration = null, int? replyToMessageId = null, ITelegramKeyboard replyMarkup = null) { return SendAudioAsync(chatId, audio, duration, replyToMessageId, replyMarkup).Result; }
/// <summary> /// Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. /// For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as <see cref="Document"/>). /// On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future. /// </summary> /// <param name="chatId">Unique identifier for the message recipient — User or GroupChat id</param> /// <param name="audio">Audio to send. You can pass a file_id as String to resend an audio that is already on the Telegram servers</param> /// <param name="duration">Duration of sent audio in seconds</param> /// <param name="replyToMessageId">If the message is a reply, ID of the original message</param> /// <param name="replyMarkup">Additional interface options. A <see cref="ITelegramKeyboard"/> object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.</param> public async Task<Message> SendAudioAsync(int chatId, string audio, int? duration = null, int? replyToMessageId = null, ITelegramKeyboard replyMarkup = null) { IRestRequest request = CreatePostRestRequest("sendAudio"); request.AddParameter("chat_id", chatId); request.AddParameter("duration", duration); request.AddParameter("reply_to_message_id", replyToMessageId); request.AddParameter("reply_markup", JsonConvert.SerializeObject(replyMarkup)); request.AddParameter("audio", audio); IRestResponse response = _restClient.Execute(request); return await PrepareResult<Message>(response.Content); }
public Message SendAudio(int chatId, string fileName, byte[] inputFile, int? duration = null, int? replyToMessageId = null, ITelegramKeyboard replyMarkup = null) { return SendAudioAsync(chatId, fileName, inputFile, duration, replyToMessageId, replyMarkup).Result; }
public Message SendPhoto(int chatId, string photo, string caption = null, int? replyToMessageId = null, ITelegramKeyboard replyMarkup = null) { return SendPhotoAsync(chatId, photo, caption, replyToMessageId, replyMarkup).Result; }