qTbot 0.2.123.6f57966
qTbot is base back end library for your c++ Qt projects.
telegrammsg.h
Go to the documentation of this file.
1//#
2//# Copyright (C) 2023-2026 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#ifndef TELEGRAMMSG_H
9#define TELEGRAMMSG_H
10
11#include "imessage.h"
13#include "telegramaudio.h"
14#include "telegramdocument.h"
15#include "telegramlocation.h"
17
18namespace qTbot {
19
24class QTBOT_EXPORT TelegramMsg: public iMessage
25{
26public:
27
41 BestOf = 1,
45 Best = 2,
49 Fast = 3
50 };
51
55 using Type = QString;
56
60 const Type Text = "text";
61
65 const Type Image = "photo";
66
70 const Type Document = "document";
71
75 const Type Contact = "contact";
76
80 const Type Location = "location";
81
85 const Type Audio = "audio";
86
91
96 TelegramMsg(const QJsonObject& obj);
97
102 unsigned long long messageId() const override;
103
108 unsigned long long fromId() const;
109
114 bool isBot() const;
115
120 QString firstName() const;
121
126 QString lastName() const;
127
132 QString username() const;
133
138 QString languageCode() const;
139
144 QVariant chatId() const override;
145
146 bool isValid() const override;
147
148 QString from() const override;
149
154 QString chatFirstName() const;
155
160 QString chatLastName() const;
161
166 QString chatUsername() const;
167
172 QString chatType() const;
173
178 qint64 date() const;
179
184 QString text() const;
185
190 QString fullText() const;
191
196 QString caption() const;
197
203 bool contains(const Type& type);
204
209 QList<QSharedPointer<TelegramImage>> images() const;
210
227 QSharedPointer<TelegramImage> image(QualitySelector behavior = AroundSize, int size = 100000) const;
228
233 QSharedPointer<TelegramDocument> documents() const;
234
239 QSharedPointer<TelegramAudio> audio() const;
240
245 QSharedPointer<TelegramContact> contact() const;
246
247 unsigned long long updateId() const override;
248
253 QSharedPointer<TelegramLocation> location() const;
254};
255
256}
257#endif // TELEGRAMMSG_H
bool isBot() const
isBot checks if the sender is a bot.
QString from() const override
from This virtual function should return the id of the user that sent this update to the bot.
QString languageCode() const
languageCode returns the sender's language code.
QString fullText() const
fullText Returns the text + caption value.
unsigned long long fromId() const
fromId returns the sender's ID.
const Type Document
Document This is the type of the documents.
Definition telegrammsg.h:70
const Type Contact
Contact This is type of the files.
Definition telegrammsg.h:75
QSharedPointer< TelegramLocation > location() const
location Returns the location object of the message.
const Type Location
Location This is the type of location data.
Definition telegrammsg.h:80
QString username() const
username returns the sender's username.
const Type Audio
Audio This is the type of audio files.
Definition telegrammsg.h:85
QString Type
Type This is a string value of the telegram message types.
Definition telegrammsg.h:55
unsigned long long messageId() const override
messageId returns the message ID.
QString firstName() const
firstName returns the sender's first name.
QString caption() const
caption Returns only the caption value.
qint64 date() const
date returns the date of the sent message.
const Type Image
Image This is the image type of the telegram.
Definition telegrammsg.h:65
const Type Text
Text This is the text type of the message.
Definition telegrammsg.h:60
unsigned long long updateId() const override
updateId This method returns the numeric id of the update.
bool isValid() const override
isValid returns true if the update is valid else false.
QSharedPointer< TelegramImage > image(QualitySelector behavior=AroundSize, int size=100000) const
Retrieve an image from the Telegram service with specified quality and size parameters.
QString chatFirstName() const
chatFirstName returns the first participant's first name in the chat.
QSharedPointer< TelegramContact > contact() const
contact Returns the contact data.
QString chatUsername() const
chatUsername returns the first participant's username in the chat.
QSharedPointer< TelegramDocument > documents() const
documents This method returns the contained document data.
QualitySelector
The QualitySelector enum This is the behavior of image and video selection.
Definition telegrammsg.h:31
@ BestOf
BestOf This selection tries to find the best image with a size limit. For example,...
Definition telegrammsg.h:41
@ Fast
Fast This selection returns the fastest image of the available ones (minimum size).
Definition telegrammsg.h:49
@ Best
Best This selection returns the best image of the available ones.
Definition telegrammsg.h:45
@ AroundSize
AroundSize This selection tries to find a file similar by size quality. For example,...
Definition telegrammsg.h:36
QString text() const
text returns text that contains this message object.
QList< QSharedPointer< TelegramImage > > images() const
images This function returns an array of available image qualities
QString chatLastName() const
chatLastName returns the first participant's last name in the chat.
QSharedPointer< TelegramAudio > audio() const
audio This method returns the contained audio data.
QVariant chatId() const override
chatId returns the chat ID.
QString lastName() const
lastName returns the sender's last name.
TelegramMsg()
TelegramMsg default constructor.
QString chatType() const
chatType returns the chat type.
bool contains(const Type &type)
contains This method returns true if the message contains the chosen data type.
iMessage()
iMessage default constructor.
Definition imessage.cpp:11