qTbot 0.87.9547b0c
qTbot is base back end library for your c++ Qt projects.
telegramupdate.cpp
Go to the documentation of this file.
1//#
2//# Copyright (C) 2023-2024 QuasarApp.
3//# Distributed under the GPLv3 software license, see the accompanying
4//# Everyone is permitted to copy and distribute verbatim copies
5//# of this license document, but changing it is not allowed.
6//#
7
8#include "telegramupdate.h"
10
11namespace qTbot {
12
15
16bool TelegramUpdate::contains(const Type &type) const {
17 return rawJson().contains(type);
18}
19
20QSharedPointer<TelegramMsg> TelegramUpdate::message() const {
21 if (!contains(MessageUpdate)) {
22 return nullptr;
23 }
24
25 return QSharedPointer<TelegramMsg>::create(rawJson()[MessageUpdate].toObject());
26}
27
28QSharedPointer<TelegramMsg> TelegramUpdate::editedMessage() const {
29
31 return nullptr;
32 }
33
34 return QSharedPointer<TelegramMsg>::create(rawJson()[EditedMessageUpdate].toObject());
35}
36
37QJsonObject TelegramUpdate::channelPost() const {
38 return rawJson().value(ChannelPostUpdate).toObject();
39}
40
42 return rawJson().value(EditedChannelPostUpdate).toObject();
43}
44
46 return rawJson().value(InlineQueryUpdate).toObject();
47}
48
50 return rawJson().value(ChosenInlineResultUpdate).toObject();
51}
52
53QSharedPointer<TelegramInlineKeyBoardCallBack> TelegramUpdate::callbackQueryUpdate() const {
55 return nullptr;
56 }
57
58 return QSharedPointer<TelegramInlineKeyBoardCallBack>::create(rawJson()[CallbackQueryUpdate].toObject());
59}
60
62 return rawJson().value(ShippingQueryUpdate).toObject();
63}
64
66 return rawJson().value(PreCheckuptAueryUpdate).toObject();
67}
68
69QJsonObject TelegramUpdate::pollUpdate() const {
70 return rawJson().value(PollUpdate).toObject();
71}
72
74 return rawJson().value(PollAnswerUpdate).toObject();
75}
76
78 return rawJson().value(MyChatMemberUpdate).toObject();
79}
80
82 return rawJson().value(ChatMemberUpdate).toObject();
83}
84
86 return rawJson().value(ChatJoinRequestUpdate).toObject();
87}
88
89unsigned long long TelegramUpdate::updateId() const {
90 return rawJson().value("update_id").toInteger();
91}
92
94 return rawJson().contains("update_id");
95}
96
97QString TelegramUpdate::from() const {
98 return "";
99}
100
101QVariant TelegramUpdate::chatId() const {
102 return "";
103}
104
105}
const QJsonObject & rawJson() const
rawJson Telegram use rest api with json objects. So all received messages will be parsed in to jsobje...
unsigned long long updateId() const override
updateId returns the update ID.
QJsonObject inlineQueryUpdate() const
inlineQueryUpdate returns the inline query update.
const Type ChosenInlineResultUpdate
const Type PreCheckuptAueryUpdate
bool isValid() const override
isValid return true if the message is valid else false.
QSharedPointer< TelegramInlineKeyBoardCallBack > callbackQueryUpdate() const
callbackQueryUpdate returns the callback query update.
QJsonObject preCheckuptAueryUpdate() const
preCheckuptAueryUpdate returns the pre-checkout query update.
const Type CallbackQueryUpdate
QJsonObject shippingQueryUpdate() const
shippingQueryUpdate returns the shipping query update.
QSharedPointer< TelegramMsg > editedMessage() const
editedMessage returns the edited message update.
QVariant chatId() const override
from This virtual function should return name of the chat when sent this message to bot.
QJsonObject editedChannelPost() const
editedChannelPost returns the edited channel post update.
QString Type
Type just string value of the telegram messages types.
QJsonObject chosenInlineResult() const
chosenInlineResult returns the chosen inline result update.
const Type EditedMessageUpdate
QJsonObject chatMemberUpdate() const
chatMemberUpdate returns the chat member update.
QJsonObject myChatMemberUpdate() const
myChatMemberUpdate returns the my chat member update.
const Type MyChatMemberUpdate
bool contains(const Type &type) const
contains This method returns true if the message contains choosed data type.
const Type ChatJoinRequestUpdate
QJsonObject channelPost() const
channelPost returns the channel post update.
const Type ShippingQueryUpdate
QJsonObject pollAnswerUpdate() const
pollAnswerUpdate returns the poll answer update.
QJsonObject chatJoinRequestUpdate() const
chatJoinRequestUpdate returns the chat join request update.
QString from() const override
from This virtual function should return name of the user that sent this message to bot.
QJsonObject pollUpdate() const
pollUpdate returns the poll update.
QSharedPointer< TelegramMsg > message() const
message returns the array of the updates messages.
const Type EditedChannelPostUpdate