4
1
mirror of https://github.com/QuasarApp/qTbot.git synced 2025-05-09 03:39:35 +00:00
This commit is contained in:
Andrei Yankovich 2023-10-08 13:50:47 +02:00
parent bcad34ef98
commit ef558b5543

@ -37,43 +37,24 @@ public:
bool sendMessage(const QVariant &chatId, const QString& text) override;
/**
* @brief Send a message to a chat or channel with optional additional objects.
* @brief Sends a specific message to a chat.
*
* The `sendSpecificMessage` method is used to send a message to a chat or channel. This method allows
* sending text messages to chats and channels. You can also specify additional
* parameters such as text formatting, replying to a specific message, disabling
* web page preview, and including extra JSON objects in the message.
* This function sends a specific message to a chat. You can include text and additional objects as needed to customize the message's content and behavior.
*
* @param chatId The identifier of the chat or channel to which the message will be sent.
* It can be a string, number, or another valid data type containing the chat identifier.
* @param text The text of the message to be sent.
* @param extraObjects A map containing additional JSON objects to include in the message.
* @param callBackQueryId A unique identifier for this message (can be used to identify responses).
* @param replyToMessageId The identifier of the message to which you want to reply. If you want to send
* a regular message without replying to another message, leave this field as 0.
* @param markdown A flag indicating whether the message text should be formatted using Markdown.
* If `true`, the text will be formatted using Markdown syntax. If `false`, the text will be
* sent as plain text.
* @param disableWebPagePreview A flag indicating whether to disable web page preview in the message.
* If `true`, web page preview will be disabled.
* @param chatId The unique identifier of the chat to send the message to.
* @param text The text content of the message to be sent.
* @param extraObjects A map containing additional objects associated with the message (optional).
* @param callBackQueryId The unique identifier for callback queries triggered by the message (optional).
* @param replyToMessageId The unique identifier of the message to reply to, if any (optional).
* @param markdown Set to true to enable Markdown formatting for the text (optional).
* @param disableWebPagePreview Set to true to disable web page previews for links in the message (optional).
*
* @return `true` if the message was successfully sent, and `false` otherwise.
* @return Returns true if the message was sent successfully, false otherwise.
*
* Usage examples:
* @code
* // Send a plain text message
* bool result = sendSpecificMessage(chatId, "Hello, world!");
*
* // Send a formatted text message as a reply to another message with additional JSON objects
* QMap<QString, QJsonObject> additionalObjects = {
* {"key1", {"value1"}},
* {"key2", {"value2"}}
* };
* bool result = sendSpecificMessage(chatId, "This is a reply with additional objects.", additionalObjects, "123456789", messageId);
*
* // Send a message with disabled web page preview
* bool result = sendSpecificMessage(chatId, "Check)", {}, "987654321", 0, false, true);
* @endcode
* @note The extraObjects parameter is a map where each key represents the object's name, and the associated value is a shared pointer to a JSON object (optional).
* @note The callBackQueryId parameter is used to handle callback queries when applicable (optional).
* @note By default, the message will be sent with Markdown formatting enabled (optional).
* @note By default, web page previews for links in the message are not disabled (optional).
*/
bool sendSpecificMessage(const QVariant &chatId,
const QString& text,
@ -84,45 +65,24 @@ public:
bool disableWebPagePreview = false);
/**
* @brief Send a message to a chat or channel with an optional custom **inline keyboard**.
* @brief Sends a specific message with a custom keyboard to a chat.
*
* The `sendSpecificMessageWithKeyboard` method is used to send a message to a chat or channel. This method allows
* sending text messages with optional interactive **inline keyboards** to chats and channels. You can also specify
* additional parameters such as text formatting, replying to a specific message, disabling web page preview,
* and providing a custom inline keyboard for user interaction.
* This function sends a specific message to a chat with a custom keyboard. The message can contain text and additional settings to customize its behavior.
*
* @param chatId The identifier of the chat or channel to which the message will be sent. It can be a string,
* number, or another valid data type containing the chat identifier.
* @param text The text of the message to be sent.
* @param keyboard A list of maps, each containing buttons and corresponding callback functions for a custom inline keyboard.
* Each map should have button text as the key and a callback function as the value.
* @param callBackQueryId A unique identifier for this message (can be used to identify responses).
* @param replyToMessageId The identifier of the message to which you want to reply. If you want to send a regular message
* without replying to another message, leave this field as 0. Default is 0.
* @param markdown A flag indicating whether the message text should be formatted using Markdown syntax. If `true`, the text
* will be formatted using Markdown. If `false`, the text will be sent as plain text. Default is `true`.
* @param disableWebPagePreview A flag indicating whether to disable web page preview in the message. If `true`, web page
* preview will be disabled. Default is `false`.
* @param chatId The unique identifier of the chat to send the message to.
* @param text The text content of the message to be sent.
* @param keyboard A list of maps where each map represents a button with a callback function.
* @param callBackQueryId The unique identifier for callback queries triggered by the message (optional).
* @param replyToMessageId The unique identifier of the message to reply to, if any (optional).
* @param markdown Set to true to enable Markdown formatting for the text (optional).
* @param disableWebPagePreview Set to true to disable web page previews for links in the message (optional).
*
* @return `true` if the message was successfully sent, and `false` otherwise.
* @return Returns true if the message was sent successfully, false otherwise.
*
* Usage examples:
* @code
* // Send a plain text message
* bool result = sendSpecificMessageWithKeyboard(chatId, "Hello, world!", {}, "123456789");
*
* // Send a formatted text message as a reply to another message with a custom inline keyboard
* QList<QMap<QString, std::function<void(const QString &queryID)>>> customKeyboard = {
* {
* {"Button 1", [](const QString &queryID) { "Callback function for Button 1" }},
* {"Button 2", [](const QString &queryID) { "Callback function for Button 2" }}
* }
* };
* bool result = sendSpecificMessageWithKeyboard(chatId, "This is a reply with a custom inline keyboard.", customKeyboard, "987654321", messageId);
*
* // Send a message with disabled web page preview
* bool result = sendSpecificMessageWithKeyboard(chatId, "Check)", {}, "555555555", 0, false, true);
* @endcode
* @note The keyboard parameter should be a list of maps where each map represents a button. The button's label is the map key, and the associated callback function is the map value.
* @note The callBackQueryId parameter is used to handle callback queries when buttons are pressed (optional).
* @note By default, the message will be sent with Markdown formatting enabled (optional).
* @note By default, web page previews for links in the message are not disabled (optional).
*/
bool sendSpecificMessageWithKeyboard(const QVariant &chatId,
const QString& text,
@ -133,43 +93,26 @@ public:
bool disableWebPagePreview = false);
/**
* @brief Send a specific message with a custom keyboard to a chat.
* @brief Sends a specific message with a custom keyboard to a chat.
*
* This method sends a specific message with a custom keyboard to a chat, allowing
* you to customize various aspects of the message, such as the text, keyboard layout,
* and other options.
* This function sends a specific message to a chat with a custom keyboard. The message can contain text and additional settings to customize its behavior.
*
* @param chatId The identifier of the chat to which the message will be sent.
* @param text The text of the message to be sent.
* @param keyboard A list of text buttons to display in the custom keyboard.
* @param callBackQueryId A unique identifier for this message (can be used to identify responses).
* @param onTimeKeyboard A flag indicating whether the keyboard should be hidden after
* selecting one of the buttons (one-time keyboard).
* @param autoResizeKeyboard A flag indicating whether the keyboard should automatically
* adjust its size based on the number of buttons.
* @param replyToMessageId The identifier of the message to which this message is a reply
* (if applicable).
* @param markdown A flag indicating whether Markdown formatting is supported in the message text.
* @param disableWebPagePreview A flag indicating whether to disable web page preview in the message.
* @param chatId The unique identifier of the chat to send the message to.
* @param text The text content of the message to be sent.
* @param keyboard A list of lists containing the keyboard buttons to display.
* @param callBackQueryId The unique identifier for callback queries triggered by the message.
* @param onTimeKeyboard Set to true to display the keyboard only once.
* @param autoResizeKeyboard Set to true to automatically resize the keyboard.
* @param replyToMessageId The unique identifier of the message to reply to, if any.
* @param markdown Set to true to enable Markdown formatting for the text.
* @param disableWebPagePreview Set to true to disable web page previews for links in the message.
*
* @return Returns true if the message was successfully sent, and false in case of an error.
* @return Returns true if the message was sent successfully, false otherwise.
*
* @example
* @code
* bool result = sendSpecificMessageWithKeyboard(chatId, "Hello, how are you?", {"Button 1", "Button 2"}, "123456789", true, true, 0, true, false);
* if (result) {
* qDebug() << "Message sent successfully.";
* } else {
* qDebug() << "Error sending the message.";
* }
* @endcode
*
* @note If the onTimeKeyboard parameter is set to true, the keyboard will be hidden after selecting
* one of the buttons, and the user won't be able to use it again.
* @note If the autoResizeKeyboard parameter is set to true, the keyboard will automatically adjust
* its size based on the number of buttons.
* @note The markdown and disableWebPagePreview parameters allow you to configure text formatting
* and web page preview options in the message.
* @note The keyboard parameter should be a list of lists of strings representing keyboard buttons.
* @note The callBackQueryId parameter is used to handle callback queries when buttons are pressed.
* @note By default, the message will be sent with Markdown formatting enabled.
* @note By default, web page previews for links in the message are not disabled.
*/
bool sendSpecificMessageWithKeyboard(const QVariant &chatId,
const QString& text,
@ -184,32 +127,26 @@ public:
bool deleteMessage(const QVariant& chatId, const QVariant& messageId) override;
/**
* @brief Edit a specific message's keyboard in a chat or channel.
* @brief Edits a specific message with a custom keyboard in a chat.
*
* The `editSpecificMessageWithKeyboard` method is used to edit the keyboard of a specific message in a chat or channel.
* This method allows you to modify the keyboard layout and options of an existing message, including adding or changing buttons.
* This function allows you to edit a specific message in a chat with a custom keyboard. You can update the message's text and customize its behavior as needed.
*
* @param chatId The identifier of the chat or channel where the message to be edited is located.
* It can be a string, number, or another valid data type containing the chat identifier.
* @param keyboard A list of text buttons for the new keyboard layout.
* @param callBackQueryId A unique identifier for this message (can be used to identify responses).
* @param onTimeKeyboard A flag indicating whether the new inline keyboard should be hidden after the user interacts with it
* (one-time keyboard). Default is `false`.
* @param autoResizeKeyboard A flag indicating whether the new inline keyboard should automatically adjust its size based on
* the number of buttons. Default is `false`.
* @param messageId The unique identifier of the message to edit.
* @param chatId The unique identifier of the chat containing the message.
* @param newText The new text content for the message.
* @param markdown Set to true to enable Markdown formatting for the new text (optional).
* @param disableWebPagePreview Set to true to disable web page previews for links in the new text (optional).
* @param keyboard A list of lists containing the new keyboard buttons to display (optional).
* @param callBackQueryId The unique identifier for callback queries triggered by the edited message (optional).
* @param onTimeKeyboard Set to true to display the keyboard only once (optional).
* @param autoResizeKeyboard Set to true to automatically resize the keyboard (optional).
*
* @return `true` if the message keyboard was successfully edited, and `false` otherwise.
* @return Returns true if the message was successfully edited, false otherwise.
*
* Usage example:
* @code
* // Edit the keyboard of a specific message
* bool result = editSpecificMessageWithKeyboard(chatId, {"New Button 1", "New Button 2"}, "123456789", true, true);
* if (result) {
* qDebug() << "Message keyboard edited successfully.";
* } else {
* qDebug() << "Error editing the message keyboard.";
* }
* @endcode
* @note The keyboard parameter should be a list of lists of strings representing keyboard buttons (optional).
* @note The callBackQueryId parameter is used to handle callback queries when buttons are pressed (optional).
* @note By default, the new text will be displayed with Markdown formatting enabled (optional).
* @note By default, web page previews for links in the new text are not disabled (optional).
*/
bool editSpecificMessageWithKeyboard(const QVariant &messageId,
const QVariant &chatId,
@ -222,39 +159,25 @@ public:
bool autoResizeKeyboard = false);
/**
* @brief Edit the keyboard of a specific message in a chat or channel.
* @brief Edits a specific message with a custom keyboard in a chat.
*
* The `editSpecificMessageWithKeyboard` method is used to modify the keyboard of a specific message in a chat or channel.
* This method allows you to customize the layout and behavior of the keyboard by providing a list of text buttons
* along with their corresponding callback functions.
* This function allows you to edit a specific message in a chat with a custom keyboard. You can update the message's text and customize its behavior as needed.
*
* @param chatId The identifier of the chat or channel where the message to be edited is located.
* It can be a string, number, or another valid data type containing the chat identifier.
* @param keyboard A list of maps, each containing buttons and their corresponding callback functions for the new keyboard layout.
* Each map should have button text as the key and a callback function as the value.
* @param callBackQueryId A unique identifier for this message (can be used to identify responses).
* @param messageId The unique identifier of the message to edit.
* @param chatId The unique identifier of the chat containing the message.
* @param text The new text content for the message.
* @param markdown Set to true to enable Markdown formatting for the new text (optional).
* @param disableWebPagePreview Set to true to disable web page previews for links in the new text (optional).
* @param keyboard A list of maps where each map represents a button with a callback function (optional).
* @param callBackQueryId The unique identifier for callback queries triggered by the edited message (optional).
*
* @return `true` if the message keyboard was successfully edited, and `false` otherwise.
* @return Returns true if the message was successfully edited, false otherwise.
*
* Usage example:
* @code
* // Define a custom keyboard layout with callback functions
* QList<QMap<QString, std::function<void(const QString &queryID)>> customKeyboard = {
* {
* {"Button 1", [](const QString &queryID) { Callback function for Button 1 }},
* {"Button 2", [](const QString &queryID) { Callback function for Button 2 }}
* }
* };
*
* // Edit the keyboard of a specific message with the custom keyboard layout
* bool result = editSpecificMessageWithKeyboard(chatId, customKeyboard, "123456789");
* if (result) {
* qDebug() << "Message keyboard edited successfully.";
* } else {
* qDebug() << "Error editing the message keyboard.";
* }
* @endcode
*/
* @note The keyboard parameter should be a list of maps where each map represents a button. The button's label is the map key, and the associated callback function is the map value (optional).
* @note The callBackQueryId parameter is used to handle callback queries when buttons are pressed (optional).
* @note By default, the new text will be displayed with Markdown formatting enabled (optional).
* @note By default, web page previews for links in the new text are not disabled (optional).
*/
bool editSpecificMessageWithKeyboard(const QVariant& messageId,
const QVariant &chatId,
const QString &text,
@ -264,32 +187,22 @@ public:
const QString &callBackQueryId = "");
/**
* @brief Edit a specific message in a chat or channel with optional additional objects.
* @brief Edits a specific message in a chat.
*
* The `editSpecificMessage` method is used to edit the content of a specific message in a chat or channel. This method allows
* you to modify the message text, various message options, and additional parameters.
* This function allows you to edit a specific message in a chat. You can update the message's text and customize its behavior as needed.
*
* @param messageId The identifier of the message to be edited.
* @param chatId The identifier of the chat or channel where the message to be edited is located.
* It can be a string, number, or another valid data type containing the chat identifier.
* @param newText The updated text for the message.
* @param callBackQueryId A unique identifier for this message (can be used to identify responses).
* @param markdown A flag indicating whether the edited message text should be formatted using Markdown syntax.
* If `true`, the text will be formatted using Markdown. If `false`, the text will be sent as plain text.
* Default is `true`.
* @param disableWebPagePreview A flag indicating whether to disable web page preview in the edited message.
* If `true`, web page preview will be disabled. Default is `false`.
* @param messageId The unique identifier of the message to edit.
* @param chatId The unique identifier of the chat containing the message.
* @param newText The new text content for the message.
* @param callBackQueryId The unique identifier for callback queries triggered by the edited message (optional).
* @param markdown Set to true to enable Markdown formatting for the new text (optional).
* @param disableWebPagePreview Set to true to disable web page previews for links in the new text (optional).
*
* @return `true` if the message was successfully edited, and `false` otherwise.
* @return Returns true if the message was successfully edited, false otherwise.
*
* Usage examples:
* @code
* // Edit the text of a specific message
* bool result = editSpecificMessage(123456789, chatId, "Updated message text");
*
* // Edit the message with a callback query identifier and disable web page preview
* bool result = editSpecificMessage(987654321, chatId, "Updated message text with callback query ID", "555555555", false, true);
* @endcode
* @note The callBackQueryId parameter is used to handle callback queries when applicable (optional).
* @note By default, the new text will be displayed with Markdown formatting enabled (optional).
* @note By default, web page previews for links in the new text are not disabled (optional).
*/
bool editSpecificMessage(const QVariant &messageId,
const QVariant &chatId,