added sentContact method

This commit is contained in:
Andrei Yankovich 2023-11-19 22:33:10 +01:00
parent 33cc4f0989
commit 9d09c6b5c1
5 changed files with 84 additions and 3 deletions

View File

@ -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);
}
}

View File

@ -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

View File

@ -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();

View File

@ -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

View File

@ -26,7 +26,7 @@ double TelegramLocation::latitude() const {
}
double TelegramLocation::longitude() const {
return rawJson()["latitude"].toDouble();
return rawJson()["longitude"].toDouble();
}