mirror of
https://github.com/QuasarApp/qTbot.git
synced 2025-05-07 18:59:37 +00:00
added new implementations for the telegramm bot
This commit is contained in:
parent
37c5d196f1
commit
8dafa0097c
@ -4,11 +4,11 @@
|
||||
"src/build/Debug/qTbotEaxample.exe"
|
||||
],
|
||||
"clear": true,
|
||||
"binPrefix": "/home/andrei/gitHub/build-qTbot-Desktop_Qt_6_5_2_GCC_64bit-Debug",
|
||||
"binPrefix": "/home/andrei/git/build-qTbot-Desktop_Qt_6_5_2_GCC_64bit-Debug",
|
||||
"libDir": [
|
||||
"/media/D/builds/qTbot",
|
||||
"/home/andrei/git/qTbot",
|
||||
"/home/andrei/Qt/6.5.2/gcc_64",
|
||||
"/home/andrei/gitHub/build-qTbot-Desktop_Qt_6_5_2_GCC_64bit-Debug"
|
||||
"/home/andrei/git/build-qTbot-Desktop_Qt_6_5_2_GCC_64bit-Debug"
|
||||
],
|
||||
"recursiveDepth": "10",
|
||||
"deploySystem": false,
|
||||
@ -17,11 +17,11 @@
|
||||
"qif": true,
|
||||
"zip": true,
|
||||
"ignoreEnv": [
|
||||
"/media/D/builds/qTbot/Distro"
|
||||
"/home/andrei/git/qTbot/Distro"
|
||||
],
|
||||
"extraLib": "crypto",
|
||||
"targetDir": "/media/D/builds/qTbot/Distro",
|
||||
"deployVersion": "0.4.e3ccbc5",
|
||||
"targetDir": "/home/andrei/git/qTbot/Distro",
|
||||
"deployVersion": "0.5.37c5d19",
|
||||
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#define QTBOT_VERSION "0.4.e3ccbc5"
|
||||
#define QTBOT_VERSION "0.5.37c5d19"
|
||||
|
||||
#if defined(QTBOT_LIBRARY)
|
||||
# define QTBOT_EXPORT Q_DECL_EXPORT
|
||||
|
@ -30,10 +30,5 @@ void IBot::setName(const QString &newName) {
|
||||
_name = newName;
|
||||
}
|
||||
|
||||
bool qTbot::IBot::sendMessage(const QSharedPointer<iMessage> &message) {
|
||||
auto data = message->makeUpload();
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
* @param message This is data for sending.
|
||||
* @return true if the message sent successful else false.
|
||||
*/
|
||||
virtual bool sendMessage(const QSharedPointer<iMessage>& message);;
|
||||
virtual bool sendMessage(const QSharedPointer<iMessage>& message) = 0;
|
||||
|
||||
/**
|
||||
* @brief token This is token value for authication on the remote server (bot)
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
* @brief setRawData This method sets new raw data value.
|
||||
* @param newRawData This is new value of the rawData.
|
||||
*/
|
||||
void setRawData(const QByteArray &newRawData);
|
||||
virtual void setRawData(const QByteArray &newRawData);
|
||||
|
||||
/**
|
||||
* @brief userId This is id of user that sent this message or must be receive this.
|
||||
|
@ -7,14 +7,25 @@
|
||||
|
||||
#include "itelegrambot.h"
|
||||
|
||||
#include <qTbot/messages/telegramgetmsg.h>
|
||||
|
||||
namespace qTbot {
|
||||
|
||||
ITelegramBot::ITelegramBot() {
|
||||
|
||||
}
|
||||
|
||||
bool ITelegramBot::sendMessage(const QSharedPointer<iMessage> &message) {
|
||||
bool ITelegramBot::login(const QByteArray &token) {
|
||||
setToken(token);
|
||||
|
||||
TelegramGetMsg msg;
|
||||
auto getInfoRquest = makePrefix() + msg.makeUpload();
|
||||
|
||||
|
||||
}
|
||||
|
||||
QByteArray ITelegramBot::makePrefix() const {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,11 +22,18 @@ class QTBOT_EXPORT ITelegramBot : public IBot
|
||||
public:
|
||||
ITelegramBot();
|
||||
|
||||
bool login(const QByteArray &token) override;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief makePrefix This method prepare a prefix message for all telegramm bots.
|
||||
* @return telegramm request prefix/
|
||||
*/
|
||||
QByteArray makePrefix() const;
|
||||
|
||||
private:
|
||||
QNetworkReques request;
|
||||
|
||||
// IBot interface
|
||||
public:
|
||||
bool sendMessage(const QSharedPointer<iMessage> &message) override;
|
||||
};
|
||||
}
|
||||
#endif // ITELEGRAMBOT_H
|
||||
|
@ -7,12 +7,11 @@
|
||||
|
||||
|
||||
#include "itelegrammessage.h"
|
||||
#include <QJsonDocument>
|
||||
|
||||
namespace qTbot {
|
||||
|
||||
ItelegramMessage::ItelegramMessage()
|
||||
{
|
||||
|
||||
}
|
||||
ItelegramMessage::ItelegramMessage():iMessage(){}
|
||||
|
||||
QByteArray ItelegramMessage::makeUpload() const {
|
||||
|
||||
@ -25,4 +24,15 @@ const QJsonObject &ItelegramMessage::rawJson() const {
|
||||
void ItelegramMessage::setRawJson(const QJsonObject &newRawJson) {
|
||||
_rawJson = newRawJson;
|
||||
}
|
||||
|
||||
void ItelegramMessage::setRawData(const QByteArray &newRawData) {
|
||||
setRawData(newRawData);
|
||||
|
||||
auto doc = QJsonDocument::fromJson(newRawData);
|
||||
if (!doc.isObject()) {
|
||||
return;
|
||||
}
|
||||
setRawJson(doc.object());
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -17,10 +17,10 @@ namespace qTbot {
|
||||
/**
|
||||
* @brief The ItelegramMessage class This is base interface of the all telegram messages.
|
||||
*/
|
||||
class QTBOT_EXPORT ItelegramMessage: public iMessage
|
||||
class QTBOT_EXPORT ITelegramMessage: public iMessage
|
||||
{
|
||||
public:
|
||||
ItelegramMessage();
|
||||
ITelegramMessage();
|
||||
|
||||
// iMessage interface
|
||||
public:
|
||||
@ -37,7 +37,10 @@ public:
|
||||
* @brief setRawJson this method convert jsobject into telegram message.
|
||||
* @param newRawJson new data for telegram message.
|
||||
*/
|
||||
void setRawJson(const QJsonObject &newRawJson);
|
||||
virtual void setRawJson(const QJsonObject &newRawJson);
|
||||
|
||||
void setRawData(const QByteArray &newRawData) override;
|
||||
|
||||
|
||||
private:
|
||||
QJsonObject _rawJson;
|
||||
|
31
src/qTbot/src/public/qTbot/messages/telegramgetmsg.cpp
Normal file
31
src/qTbot/src/public/qTbot/messages/telegramgetmsg.cpp
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.
|
||||
//#
|
||||
|
||||
#include "telegramgetmsg.h"
|
||||
|
||||
namespace qTbot {
|
||||
|
||||
TelegramGetMsg::TelegramGetMsg() {
|
||||
|
||||
}
|
||||
|
||||
QByteArray TelegramGetMsg::makeUpload() const {
|
||||
return "/get";
|
||||
}
|
||||
|
||||
bool TelegramGetMsg::isValid() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void TelegramGetMsg::setRawData(const QByteArray &) {
|
||||
return;
|
||||
}
|
||||
|
||||
void TelegramGetMsg::setRawJson(const QJsonObject &) {
|
||||
return;
|
||||
}
|
||||
}
|
28
src/qTbot/src/public/qTbot/messages/telegramgetmsg.h
Normal file
28
src/qTbot/src/public/qTbot/messages/telegramgetmsg.h
Normal file
@ -0,0 +1,28 @@
|
||||
//#
|
||||
//# 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 TELEGRAMGETMSG_H
|
||||
#define TELEGRAMGETMSG_H
|
||||
|
||||
#include "qTbot/itelegrammessage.h"
|
||||
namespace qTbot {
|
||||
|
||||
/**
|
||||
* @brief The TelegramGetMsg class just prepare get request to tellegram
|
||||
*/
|
||||
class QTBOT_EXPORT TelegramGetMsg: public ITelegramMessage
|
||||
{
|
||||
public:
|
||||
TelegramGetMsg();
|
||||
|
||||
QByteArray makeUpload() const override;
|
||||
bool isValid() const override;
|
||||
void setRawData(const QByteArray &newRawData) override;
|
||||
void setRawJson(const QJsonObject &newRawJson) override;
|
||||
};
|
||||
}
|
||||
#endif // TELEGRAMGETMSG_H
|
27
src/qTbot/src/public/qTbot/messages/telegramtextmsg.cpp
Normal file
27
src/qTbot/src/public/qTbot/messages/telegramtextmsg.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
//#
|
||||
//# 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 "telegramtextmsg.h"
|
||||
namespace qTbot {
|
||||
|
||||
TelegramTextMsg::TelegramTextMsg() {
|
||||
|
||||
}
|
||||
|
||||
void TelegramTextMsg::setRawJson(const QJsonObject &newRawJson) {
|
||||
setText(newRawJson.value("text").toString());
|
||||
ITelegramMessage::setRawJson(newRawJson);
|
||||
}
|
||||
|
||||
QString TelegramTextMsg::text() const {
|
||||
return _text;
|
||||
}
|
||||
|
||||
void TelegramTextMsg::setText(const QString &newText) {
|
||||
_text = newText;
|
||||
}
|
||||
}
|
34
src/qTbot/src/public/qTbot/messages/telegramtextmsg.h
Normal file
34
src/qTbot/src/public/qTbot/messages/telegramtextmsg.h
Normal file
@ -0,0 +1,34 @@
|
||||
//#
|
||||
//# 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 TELEGRAMTEXTMSG_H
|
||||
#define TELEGRAMTEXTMSG_H
|
||||
|
||||
#include <qTbot/itelegrammessage.h>
|
||||
|
||||
namespace qTbot {
|
||||
|
||||
/**
|
||||
* @brief The TelegramTextMsg class This class provide general text mesasges.
|
||||
*/
|
||||
class QTBOT_EXPORT TelegramTextMsg: public ITelegramMessage
|
||||
{
|
||||
public:
|
||||
TelegramTextMsg();
|
||||
|
||||
// ITelegramMessage interface
|
||||
void setRawJson(const QJsonObject &newRawJson) override;
|
||||
|
||||
QString text() const;
|
||||
void setText(const QString &newText);
|
||||
|
||||
private:
|
||||
QString _text;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // TELEGRAMTEXTMSG_H
|
24
src/qTbot/src/public/qTbot/telegramrestbot.cpp
Normal file
24
src/qTbot/src/public/qTbot/telegramrestbot.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
//#
|
||||
//# 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 "telegramrestbot.h"
|
||||
|
||||
namespace qTbot {
|
||||
|
||||
TelegramRestBot::TelegramRestBot()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool TelegramRestBot::login(const QByteArray &token) {
|
||||
ITelegramBot::login(token);
|
||||
}
|
||||
|
||||
bool TelegramRestBot::sendMessage(const QSharedPointer<iMessage> &message) {
|
||||
|
||||
}
|
||||
}
|
29
src/qTbot/src/public/qTbot/telegramrestbot.h
Normal file
29
src/qTbot/src/public/qTbot/telegramrestbot.h
Normal file
@ -0,0 +1,29 @@
|
||||
//#
|
||||
//# 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 TELEGRAMRESTBOT_H
|
||||
#define TELEGRAMRESTBOT_H
|
||||
|
||||
#include "itelegrambot.h"
|
||||
|
||||
namespace qTbot {
|
||||
|
||||
/**
|
||||
* @brief The TelegramRestBot class Is Rest implementation base on the Update API telegram method
|
||||
*/
|
||||
class QTBOT_EXPORT TelegramRestBot: public ITelegramBot
|
||||
{
|
||||
public:
|
||||
TelegramRestBot();
|
||||
|
||||
// IBot interface
|
||||
bool login(const QByteArray &token);
|
||||
bool sendMessage(const QSharedPointer<iMessage> &message);
|
||||
};
|
||||
}
|
||||
#endif // TELEGRAMRESTBOT_H
|
Loading…
x
Reference in New Issue
Block a user