mirror of
https://github.com/QuasarApp/qTbot.git
synced 2025-04-27 06:14:32 +00:00
added sentContact method
This commit is contained in:
parent
33cc4f0989
commit
9d09c6b5c1
25
src/qTbot/src/private/requests/telegramsendcontact.cpp
Normal file
25
src/qTbot/src/private/requests/telegramsendcontact.cpp
Normal 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);
|
||||
|
||||
}
|
||||
|
||||
}
|
31
src/qTbot/src/private/requests/telegramsendcontact.h
Normal file
31
src/qTbot/src/private/requests/telegramsendcontact.h
Normal 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
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -26,7 +26,7 @@ double TelegramLocation::latitude() const {
|
||||
}
|
||||
|
||||
double TelegramLocation::longitude() const {
|
||||
return rawJson()["latitude"].toDouble();
|
||||
return rawJson()["longitude"].toDouble();
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user