added request buttons
All checks were successful
buildbot/WindowsCMakeBuilder Build finished.

This commit is contained in:
Andrei Yankovich 2024-04-09 20:55:16 +02:00
parent c8e88681a4
commit 536d483df2
2 changed files with 53 additions and 0 deletions

View File

@ -70,6 +70,41 @@ bool ITelegramBot::sendMessage(const QVariant &chatId, const QString &text) {
return sendSpecificMessage(TelegramArgs{chatId, text});
}
bool ITelegramBot::sendLocationRequest(const QVariant &chatId, const QString &text, const QString &buttonText,
bool onetimeKeyboard) {
auto replyMarkup = QSharedPointer<QJsonObject>::create();
QJsonArray keyboard;
QJsonObject contactButton;
contactButton["text"] = buttonText;
contactButton["request_location"] = true;
QJsonArray row;
row.append(contactButton);
keyboard.append(row);
replyMarkup->insert("keyboard", keyboard);
replyMarkup->insert("resize_keyboard", true);
replyMarkup->insert("one_time_keyboard", onetimeKeyboard);
return sendSpecificMessage(TelegramArgs{chatId, text}, {{"reply_markup", replyMarkup}});
}
bool ITelegramBot::sendSelfContactRequest(const QVariant &chatId, const QString &text, const QString &buttonText,
bool onetimeKeyboard) {
auto replyMarkup = QSharedPointer<QJsonObject>::create();
QJsonArray keyboard;
QJsonObject contactButton;
contactButton["text"] = buttonText;
contactButton["request_contact"] = true;
QJsonArray row;
row.append(contactButton);
keyboard.append(row);
replyMarkup->insert("keyboard", keyboard);
replyMarkup->insert("resize_keyboard", true);
replyMarkup->insert("one_time_keyboard", onetimeKeyboard);
return sendSpecificMessage(TelegramArgs{chatId, text}, {{"reply_markup", replyMarkup}});
}
bool ITelegramBot::sendSpecificMessage(const TelegramArgs& args,
const ExtraJsonObjects &extraObjects) {

View File

@ -42,6 +42,24 @@ public:
bool sendMessage(const QVariant &chatId, const QString& text) override;
/**
* @brief sendLocationRequest This method setn into chat button that will automaticaly sent geo location to bot.
* @param chatId
* @param text message text
* @param buttonText Text on the button
* @return true if request sents successfull else false.
*/
bool sendLocationRequest(const QVariant &chatId, const QString& text, const QString &buttonText, bool onetimeKeyboard);
/**
* @brief sendSelfContactRequest This method sent into chat button that will automaticaly sent self contact information to bot.
* @param chatId
* @param text message text
* @param buttonText Text on the button
* @return true if request sents successfull else false.
*/
bool sendSelfContactRequest(const QVariant &chatId, const QString& text, const QString &buttonText, bool onetimeKeyboard);
/**
* @brief Sends a specific message to a chat.
*