-
Notifications
You must be signed in to change notification settings - Fork 0
/
telegramhelper.h
54 lines (41 loc) · 2.45 KB
/
telegramhelper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef TELEGRAMPOLL_H
#define TELEGRAMPOLL_H
#include "CivetServer.h"
#include <QString>
#include <QByteArray>
#include <QtNetwork/QNetworkAccessManager>
#include "routeshandler.h"
class TelegramHelper: public CivetHandler
{
public:
TelegramHelper(const QString& vToken, const QString& vStorageFolder, const RoutesHandler& vRoutesh);
void checkUpdates();
bool parseUpdate(QJsonObject& updateObj, QString &httpPath, QJsonDocument &jsonDoc );
bool replyOnChat(const QString& httpPath, const QJsonDocument& jsonDoc);
bool setChatParameter(int chatId, const QString& paramValue);
QString getChatParameter(int chatId, const QString& defaultValue);
protected:
bool parseGetUpdates(const QByteArray& payload);
bool parseMessage(const QJsonObject& messageObj, QString &httpPath, QJsonDocument &jsonDoc);
bool parseInlineQuery(const QJsonObject& messageObj, QString &httpPath, QJsonDocument &jsonDoc);
bool parseCallbackQuery(const QJsonObject& messageObj, QString &httpPath, QJsonDocument &jsonDoc);
bool parsePollAnswer(const QJsonObject& messageObj, QString &httpPath, QJsonDocument &jsonDoc);
bool parsePoll(const QJsonObject& messageObj, QString &httpPath, QJsonDocument &jsonDoc);
bool parseCommand(int chatId, const QString& first_name, const QString& messageText, bool& unknownCommand, QString &httpPath, QJsonDocument &jsonDoc);
bool makeMessage(int chatId, const QString& message, const QJsonObject& replyMarkup, QString& httpPath, QJsonDocument& jsonDoc);
bool makePhoto(int chatId, const QString& photoUrl, QString& httpPath, QJsonDocument& jsonDoc);
bool makePosition(int chatId, const QPointF& thePosition, QString& httpPath, QJsonDocument& jsonDoc);
bool makeInlineQueryResult(const QString& inlineQueryId, const QJsonArray& articles, QString& httpPath, QJsonDocument& jsonDoc);
bool makeAnswerCallbackQuery(const QString &callbackQueryId, const QString& message, QString& httpPath, QJsonDocument& jsonDoc);
bool makePoll(int chatId, QString& httpPath, QJsonDocument& jsonDoc);
void createContactKeyboard(QJsonObject& replyMarkup);
void createInlineKeyboard(QJsonObject& replyMarkup);
QByteArray makeHttpGet(const QUrl& toCall);
QByteArray makeHttpPost(const QUrl& toCall, const QString& contentType, const QByteArray& toSend);
QString token;
QString storageFolder;
const RoutesHandler& routesh;
int lastUpdateId;
QNetworkAccessManager manager;
};
#endif // TELEGRAMPOLL_H