4
1
mirror of https://github.com/QuasarApp/qTbot.git synced 2025-05-10 12:19:35 +00:00

added interface of the telegram messages

This commit is contained in:
Andrei Yankovich 2023-08-31 21:49:36 +02:00
parent e3ccbc599d
commit 37c5d196f1
10 changed files with 108 additions and 11 deletions

@ -21,7 +21,7 @@
],
"extraLib": "crypto",
"targetDir": "/media/D/builds/qTbot/Distro",
"deployVersion": "0.3.4456fd7",
"deployVersion": "0.4.e3ccbc5",
}

@ -23,10 +23,7 @@ file(GLOB_RECURSE SOURCE_QRC
set(PUBLIC_INCUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/public")
set(PRIVATE_INCUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/private")
add_library(${CURRENT_PROJECT} ${SOURCE_CPP} ${SOURCE_QRC}
src/public/qTbot/itelegrambot.h src/public/qTbot/itelegrambot.cpp
src/public/qTbot/ibot.h src/public/qTbot/ibot.cpp
src/public/qTbot/imessage.h src/public/qTbot/imessage.cpp)
add_library(${CURRENT_PROJECT} ${SOURCE_CPP} ${SOURCE_QRC})
target_link_libraries(${CURRENT_PROJECT} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Network)

@ -1,5 +1,5 @@
//#
//# Copyright (C) 2018-2023 QuasarApp.
//# 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.
@ -10,7 +10,7 @@
#include <QtCore/qglobal.h>
#define QTBOT_VERSION "0.3.4456fd7"
#define QTBOT_VERSION "0.4.e3ccbc5"
#if defined(QTBOT_LIBRARY)
# define QTBOT_EXPORT Q_DECL_EXPORT

@ -1,5 +1,5 @@
//#
//# Copyright (C) 2018-2023 QuasarApp.
//# 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.

@ -1,5 +1,5 @@
//#
//# Copyright (C) 2018-2023 QuasarApp.
//# 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.
@ -29,4 +29,11 @@ const QString &IBot::name() const {
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) = 0;
virtual bool sendMessage(const QSharedPointer<iMessage>& message);;
/**
* @brief token This is token value for authication on the remote server (bot)
@ -75,5 +75,6 @@ signals:
void receiveMessage(QSharedPointer<iMessage> );
};
}
#endif // IBOT_H

@ -1,5 +1,5 @@
//#
//# Copyright (C) 2018-2023 QuasarApp.
//# 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.
@ -28,4 +28,8 @@ const QByteArray &iMessage::userId() const {
void iMessage::setUserId(const QByteArray &newUserId) {
_userId = newUserId;
}
bool iMessage::isValid() const {
return _userId.size();
}
}

@ -49,6 +49,18 @@ public:
*/
void setUserId(const QByteArray &newUserId);
/**
* @brief makeUpload This method prepare data to upload;
* @return data array prepared to sending.
*/
virtual QByteArray makeUpload() const = 0;
/**
* @brief isValid return true if the message is valid else false.
* @return true if the message is valid else false.
*/
virtual bool isValid() const;
private:
QByteArray _rawData;
QByteArray _userId;

@ -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.
//#
#include "itelegrammessage.h"
namespace qTbot {
ItelegramMessage::ItelegramMessage()
{
}
QByteArray ItelegramMessage::makeUpload() const {
}
const QJsonObject &ItelegramMessage::rawJson() const {
return _rawJson;
}
void ItelegramMessage::setRawJson(const QJsonObject &newRawJson) {
_rawJson = newRawJson;
}
}

@ -0,0 +1,48 @@
//#
//# 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 ITELEGRAMMESSAGE_H
#define ITELEGRAMMESSAGE_H
#include "imessage.h"
#include "qjsonobject.h"
namespace qTbot {
/**
* @brief The ItelegramMessage class This is base interface of the all telegram messages.
*/
class QTBOT_EXPORT ItelegramMessage: public iMessage
{
public:
ItelegramMessage();
// iMessage interface
public:
bool isValid() const override;
QByteArray makeUpload() const override;
/**
* @brief rawJson Telegram use rest api with json objects. So all received messages will be parsed in to jsobject.
* @return js implementation of object.
*/
const QJsonObject& rawJson() const;
/**
* @brief setRawJson this method convert jsobject into telegram message.
* @param newRawJson new data for telegram message.
*/
void setRawJson(const QJsonObject &newRawJson);
private:
QJsonObject _rawJson;
};
}
#endif // ITELEGRAMMESSAGE_H