コード例 #1
0
        /// <summary>
        /// Use this method to edit text and game messages sent by the bot or via the bot (for inline bots).
        /// See <see href="https://core.telegram.org/bots/api#editmessagetext">API</see>
        /// </summary>
        /// <param name="text">New text of the message</param>
        /// <param name="chatId">Optional.
        /// Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)</param>
        /// <param name="messageId">Optional.
        /// Required if inline_message_id is not specified. Identifier of the sent message</param>
        /// <param name="inlineMessageId">Optional.
        /// Required if chat_id and message_id are not specified. Identifier of the inline message</param>
        /// <param name="parseMode">Optional.
        /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.</param>
        /// <param name="disableWebPagePreview">Optional.
        /// Disables link previews for links in this message.</param>
        /// <param name="replyMarkup">Optional.
        /// A JSON-serialized object for an inline keyboard. Please note, that it is currently only possible to edit messages without reply_markup or with inline keyboards.</param>
        /// <returns>On success, if edited message is sent by the bot, the edited Message is returned</returns>
        public SendMessageResult EditMessageText(string text, object chatId        = null, int?messageId       = null,
                                                 string inlineMessageId            = null, ParseMode?parseMode = null, bool?disableWebPagePreview = null,
                                                 IInlineKeyboardMarkup replyMarkup = null)
        {
            RestRequest request = NewRestRequest(mEditMessageTextUri);

            request.AddParameter("text", text);

            if (chatId != null)
            {
                request.AddParameter("chat_id", chatId);
            }
            if (messageId != null)
            {
                request.AddParameter("message_id", messageId);
            }
            if (inlineMessageId != null)
            {
                request.AddParameter("inline_message_id", inlineMessageId);
            }
            if (parseMode != null)
            {
                request.AddParameter("parse_mode", parseMode.Value);
            }
            if (disableWebPagePreview.HasValue)
            {
                request.AddParameter("disable_web_page_preview", disableWebPagePreview.Value);
            }
            if (replyMarkup != null)
            {
                request.AddParameter("reply_markup", replyMarkup.GetJson());
            }

            return(ExecuteRequest <SendMessageResult>(request) as SendMessageResult);
        }
コード例 #2
0
        /// <summary>
        /// Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots).
        /// See <see href="https://core.telegram.org/bots/api#editmessagereplymarkup">API</see>
        /// </summary>
        /// <param name="chatId">Optional.
        /// Required if inline_message_id is not specified.
        /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)</param>
        /// <param name="messageId">Optional.
        /// Required if inline_message_id is not specified. Identifier of the sent message</param>
        /// <param name="inlineMessageId">Optional.
        /// Required if chat_id and message_id are not specified. Identifier of the inline message</param>
        /// <param name="replyMarkup">Optional.
        /// A JSON-serialized object for an inline keyboard. </param>
        /// <returns>On success, if edited message is sent by the bot, the edited Message is returned</returns>
        public SendMessageResult EditMessageReplyMarkup(object chatId          = null, int?messageId = null,
                                                        string inlineMessageId = null, IInlineKeyboardMarkup replyMarkup = null)
        {
            RestRequest request = NewRestRequest(mEditMessageReplyMarkupUri);

            if (chatId != null)
            {
                request.AddParameter("chat_id", chatId);
            }
            if (messageId != null)
            {
                request.AddParameter("message_id", messageId);
            }
            if (inlineMessageId != null)
            {
                request.AddParameter("inline_message_id", inlineMessageId);
            }
            if (replyMarkup != null)
            {
                request.AddParameter("reply_markup", replyMarkup.GetJson());
            }

            return(ExecuteRequest <SendMessageResult>(request) as SendMessageResult);
        }