diff --git a/src/qTbot/src/private/requests/telegramsendcontact.cpp b/src/qTbot/src/private/requests/telegramsendcontact.cpp new file mode 100644 index 0000000..55e58aa --- /dev/null +++ b/src/qTbot/src/private/requests/telegramsendcontact.cpp @@ -0,0 +1,25 @@ +//# +//# Copyright (C) 2023-2023 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + +#include "telegramsendcontact.h" + +namespace qTbot { + + +TelegramSendContact::TelegramSendContact(const TelegramArgs &args, + const QString &firstName, + const QString &phone, + const QString &lastName): + TelegramSingleRquest("sendContact", args.toMap(true)) { + + addArg("first_name", firstName); + addArg("last_name", lastName); + addArg("phone_number", phone); + +} + +} diff --git a/src/qTbot/src/private/requests/telegramsendcontact.h b/src/qTbot/src/private/requests/telegramsendcontact.h new file mode 100644 index 0000000..5e7e5c0 --- /dev/null +++ b/src/qTbot/src/private/requests/telegramsendcontact.h @@ -0,0 +1,31 @@ +//# +//# Copyright (C) 2023-2023 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + + +#ifndef TELEGRAMSENDCONTACT_H +#define TELEGRAMSENDCONTACT_H + +#include "qTbot/telegramargs.h" +#include "telegramsinglerquest.h" + +namespace qTbot { + +/** + * @brief The TelegramSendContact class + */ +class TelegramSendContact: public TelegramSingleRquest +{ +public: + + TelegramSendContact(const TelegramArgs &args, + const QString &firstName, + const QString &phone, + const QString &lastName); +}; +} +#endif // TELEGRAMSENDCONTACT_H diff --git a/src/qTbot/src/public/qTbot/itelegrambot.cpp b/src/qTbot/src/public/qTbot/itelegrambot.cpp index 018fe83..535fef9 100644 --- a/src/qTbot/src/public/qTbot/itelegrambot.cpp +++ b/src/qTbot/src/public/qTbot/itelegrambot.cpp @@ -10,6 +10,7 @@ #include "file.h" #include "requests/telegrammdownloadfile.h" #include "qdir.h" +#include "requests/telegramsendcontact.h" #include "requests/telegramsenddocument.h" #include "virtualfile.h" #include <QNetworkAccessManager> @@ -435,6 +436,19 @@ bool ITelegramBot::sendLocation(const TelegramArgs &args, prepareInlineKeyBoard(keyboard))); } +bool ITelegramBot::sendContact(const TelegramArgs &args, + const QString &phone, + const QString &firstName, + const QString &secondName) { + if (!args.chatId.isValid() || args.chatId.isNull()) + return false; + + return sendMessageRequest(QSharedPointer<TelegramSendContact>::create(args, + firstName, + phone, + secondName)); +} + int ITelegramBot::getFileSizeByUniqueId(const QString &id) const { if (auto && file = _filesMetaInfo.value(id)) { return file->fileSize(); diff --git a/src/qTbot/src/public/qTbot/itelegrambot.h b/src/qTbot/src/public/qTbot/itelegrambot.h index 0c4649e..00270b1 100644 --- a/src/qTbot/src/public/qTbot/itelegrambot.h +++ b/src/qTbot/src/public/qTbot/itelegrambot.h @@ -250,15 +250,26 @@ public: float longitude, const KeyboardOnMessage &keyboard = {}); + /** + * @brief sendContact This method sents a contact data. + * @param args base arguments of message. + * @param firstName This is first name of contact. + * @param phone This is phone number of contact. + * @param secondName This is second name of user. + * @return true if contact sent successful + */ + bool sendContact(const TelegramArgs &args, + const QString& phone, + const QString& firstName, + const QString& secondName = ""); + // to do // * forwardMessage implementations // * copyMessage implementations - // * sendPhoto implementations // * sendAudio implementations // * sendVideo implementations // * sendVoice implementations - // * sendLocation implementations // * sendContact implementations // * sendPoll implementations // * sendDice implementations diff --git a/src/qTbot/src/public/qTbot/messages/telegramlocation.cpp b/src/qTbot/src/public/qTbot/messages/telegramlocation.cpp index f8112b4..0a7f38d 100644 --- a/src/qTbot/src/public/qTbot/messages/telegramlocation.cpp +++ b/src/qTbot/src/public/qTbot/messages/telegramlocation.cpp @@ -26,7 +26,7 @@ double TelegramLocation::latitude() const { } double TelegramLocation::longitude() const { - return rawJson()["latitude"].toDouble(); + return rawJson()["longitude"].toDouble(); }