qTbot 0.2.123.6f57966
qTbot is base back end library for your c++ Qt projects.
qTbot::TelegramMsg Class Reference

The TelegramMsg class This class provides the general messages of telegram. The message object can contain text, geo data or a link to a video or image. All this data can be contained in one object. More...

#include <telegrammsg.h>

Inheritance diagram for qTbot::TelegramMsg:
Inheritance graph
Collaboration diagram for qTbot::TelegramMsg:
Collaboration graph

Public Types

enum  QualitySelector { AroundSize = 0 , BestOf = 1 , Best = 2 , Fast = 3 }
 The QualitySelector enum This is the behavior of image and video selection. More...
using Type = QString
 Type This is a string value of the telegram message types.

Public Member Functions

 TelegramMsg ()
 TelegramMsg default constructor.
 TelegramMsg (const QJsonObject &obj)
 Constructs a Message object from a JSON object.
unsigned long long messageId () const override
 messageId returns the message ID.
unsigned long long fromId () const
 fromId returns the sender's ID.
bool isBot () const
 isBot checks if the sender is a bot.
QString firstName () const
 firstName returns the sender's first name.
QString lastName () const
 lastName returns the sender's last name.
QString username () const
 username returns the sender's username.
QString languageCode () const
 languageCode returns the sender's language code.
QVariant chatId () const override
 chatId returns the chat ID.
bool isValid () const override
 isValid returns true if the update is valid else false.
QString from () const override
 from This virtual function should return the id of the user that sent this update to the bot.
QString chatFirstName () const
 chatFirstName returns the first participant's first name in the chat.
QString chatLastName () const
 chatLastName returns the first participant's last name in the chat.
QString chatUsername () const
 chatUsername returns the first participant's username in the chat.
QString chatType () const
 chatType returns the chat type.
qint64 date () const
 date returns the date of the sent message.
QString text () const
 text returns text that contains this message object.
QString fullText () const
 fullText Returns the text + caption value.
QString caption () const
 caption Returns only the caption value.
bool contains (const Type &type)
 contains This method returns true if the message contains the chosen data type.
QList< QSharedPointer< TelegramImage > > images () const
 images This function returns an array of available image qualities
QSharedPointer< TelegramImage > image (QualitySelector behavior=AroundSize, int size=100000) const
 Retrieve an image from the Telegram service with specified quality and size parameters.
QSharedPointer< TelegramDocument > documents () const
 documents This method returns the contained document data.
QSharedPointer< TelegramAudio > audio () const
 audio This method returns the contained audio data.
QSharedPointer< TelegramContact > contact () const
 contact Returns the contact data.
unsigned long long updateId () const override
 updateId This method returns the numeric id of the update.
QSharedPointer< TelegramLocation > location () const
 location Returns the location object of the message.
Public Member Functions inherited from qTbot::iMessage
 iMessage ()
 iMessage default constructor.
Public Member Functions inherited from qTbot::IJsonBasedUpdate
 IJsonBasedUpdate ()
 IJsonBasedUpdate default constructor.
void setRawData (const QByteArray &newRawData) override
 setRawData This method sets a new raw data value.
Public Member Functions inherited from qTbot::iUpdate
 iUpdate ()
 iUpdate default constructor.
const QByteArray & rawData () const
 rawData returns the raw data of the update. The raw data is the not parsed value from the server.
Public Member Functions inherited from qTbot::IJsonBasedObject
 IJsonBasedObject ()
 IJsonBasedObject default constructor.
 IJsonBasedObject (const QJsonObject &newRawJson)
 IJsonBasedObject constructs the object from a raw json value.
const QJsonObject & rawJson () const
 rawJson Telegram uses a rest api with json objects. So all received messages are parsed into a json object.
virtual void setRawJson (const QJsonObject &newRawJson)
 setRawJson This method sets a new raw json data of the object.

Public Attributes

const Type Text = "text"
 Text This is the text type of the message.
const Type Image = "photo"
 Image This is the image type of the telegram.
const Type Document = "document"
 Document This is the type of the documents.
const Type Contact = "contact"
 Contact This is type of the files.
const Type Location = "location"
 Location This is the type of location data.
const Type Audio = "audio"
 Audio This is the type of audio files.

Detailed Description

The TelegramMsg class This class provides the general messages of telegram. The message object can contain text, geo data or a link to a video or image. All this data can be contained in one object.

Definition at line 24 of file telegrammsg.h.

Member Typedef Documentation

◆ Type

using qTbot::TelegramMsg::Type = QString

Type This is a string value of the telegram message types.

Definition at line 55 of file telegrammsg.h.

Member Enumeration Documentation

◆ QualitySelector

The QualitySelector enum This is the behavior of image and video selection.

Enumerator
AroundSize 

AroundSize This selection tries to find a file similar by size quality. For example, we have an image with sizes [10, 100, 1000, 10000] kbytes - the invoke image(90) returns the image with size 100, because it is more similar by quality.

BestOf 

BestOf This selection tries to find the best image with a size limit. For example, we have an image with sizes [10, 100, 1000, 10000] kbytes - the invoke image(90) returns the image with size 10, because it is the maximum quality from 0 to 90 kbytes. If we invoke this method with a 2500 limitation, the function will return the image with size 1000.

Best 

Best This selection returns the best image of the available ones.

Fast 

Fast This selection returns the fastest image of the available ones (minimum size).

Definition at line 31 of file telegrammsg.h.

Constructor & Destructor Documentation

◆ TelegramMsg() [1/2]

qTbot::TelegramMsg::TelegramMsg ( )

TelegramMsg default constructor.

Definition at line 14 of file telegrammsg.cpp.

◆ TelegramMsg() [2/2]

qTbot::TelegramMsg::TelegramMsg ( const QJsonObject & obj)

Constructs a Message object from a JSON object.

Parameters
objThe JSON object containing message data.

Definition at line 19 of file telegrammsg.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ audio()

QSharedPointer< TelegramAudio > qTbot::TelegramMsg::audio ( ) const

audio This method returns the contained audio data.

Returns
the audio description data.

Definition at line 171 of file telegrammsg.cpp.

Here is the call graph for this function:

◆ caption()

QString qTbot::TelegramMsg::caption ( ) const

caption Returns only the caption value.

Returns
only the caption value.

Definition at line 91 of file telegrammsg.cpp.

Here is the call graph for this function:

◆ chatFirstName()

QString qTbot::TelegramMsg::chatFirstName ( ) const

chatFirstName returns the first participant's first name in the chat.

Returns
The first participant's first name in the chat.

Definition at line 63 of file telegrammsg.cpp.

Here is the call graph for this function:

◆ chatId()

QVariant qTbot::TelegramMsg::chatId ( ) const
overridevirtual

chatId returns the chat ID.

Returns
The chat ID.

Implements qTbot::iUpdate.

Definition at line 51 of file telegrammsg.cpp.

Here is the call graph for this function:

◆ chatLastName()

QString qTbot::TelegramMsg::chatLastName ( ) const

chatLastName returns the first participant's last name in the chat.

Returns
The first participant's last name in the chat.

Definition at line 67 of file telegrammsg.cpp.

Here is the call graph for this function:

◆ chatType()

QString qTbot::TelegramMsg::chatType ( ) const

chatType returns the chat type.

Returns
The chat type.

Definition at line 75 of file telegrammsg.cpp.

Here is the call graph for this function:

◆ chatUsername()

QString qTbot::TelegramMsg::chatUsername ( ) const

chatUsername returns the first participant's username in the chat.

Returns
The first participant's username in the chat.

Definition at line 71 of file telegrammsg.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ contact()

QSharedPointer< TelegramContact > qTbot::TelegramMsg::contact ( ) const

contact Returns the contact data.

Returns
the contact information.

Definition at line 175 of file telegrammsg.cpp.

Here is the call graph for this function:

◆ contains()

bool qTbot::TelegramMsg::contains ( const Type & type)

contains This method returns true if the message contains the chosen data type.

Parameters
typeThis is the name of the type
Returns
true if the chosen type is available in this message.

Definition at line 95 of file telegrammsg.cpp.

Here is the call graph for this function:

◆ date()

qint64 qTbot::TelegramMsg::date ( ) const

date returns the date of the sent message.

Returns
message date.

Definition at line 79 of file telegrammsg.cpp.

Here is the call graph for this function:

◆ documents()

QSharedPointer< TelegramDocument > qTbot::TelegramMsg::documents ( ) const

documents This method returns the contained document data.

Returns
the document description data.

Definition at line 167 of file telegrammsg.cpp.

Here is the call graph for this function:

◆ firstName()

QString qTbot::TelegramMsg::firstName ( ) const

firstName returns the sender's first name.

Returns
The sender's first name.

Definition at line 35 of file telegrammsg.cpp.

Here is the call graph for this function:

◆ from()

QString qTbot::TelegramMsg::from ( ) const
overridevirtual

from This virtual function should return the id of the user that sent this update to the bot.

Returns
id of the sender.

Implements qTbot::iUpdate.

Definition at line 59 of file telegrammsg.cpp.

Here is the call graph for this function:

◆ fromId()

unsigned long long qTbot::TelegramMsg::fromId ( ) const

fromId returns the sender's ID.

Returns
The sender's ID.

Definition at line 27 of file telegrammsg.cpp.

Here is the call graph for this function:

◆ fullText()

QString qTbot::TelegramMsg::fullText ( ) const

fullText Returns the text + caption value.

Returns
the text + caption value.

Definition at line 87 of file telegrammsg.cpp.

Here is the call graph for this function:

◆ image()

QSharedPointer< TelegramImage > qTbot::TelegramMsg::image ( QualitySelector behavior = AroundSize,
int size = 100000 ) const

Retrieve an image from the Telegram service with specified quality and size parameters.

This method allows you to request an image from the Telegram service with a specific quality selection behavior. You can control the image selection behavior by providing a QualitySelector enum value, and optionally, a maximum size limit.

Parameters
behavior(Optional) The QualitySelector enum value that defines the image selection behavior. Defaults to AroundSize if not specified.
  • AroundSize: Attempts to find an image with similar quality based on size.
  • BestOf: Tries to find the best image within a size limit.
  • Best: Retrieves the best available image.
  • Fast: Retrieves the fastest available image (minimum size).
size(Optional) The required size for the image (in bytes). Defaults to 100,000 bytes if not specified.
Returns
A TelegramImage object representing the selected image.

Definition at line 110 of file telegrammsg.cpp.

Here is the call graph for this function:

◆ images()

QList< QSharedPointer< TelegramImage > > qTbot::TelegramMsg::images ( ) const

images This function returns an array of available image qualities

Returns
an array of available image qualities

Definition at line 99 of file telegrammsg.cpp.

Here is the call graph for this function:

◆ isBot()

bool qTbot::TelegramMsg::isBot ( ) const

isBot checks if the sender is a bot.

Returns
true if the sender is a bot, false otherwise.

Definition at line 31 of file telegrammsg.cpp.

Here is the call graph for this function:

◆ isValid()

bool qTbot::TelegramMsg::isValid ( ) const
overridevirtual

isValid returns true if the update is valid else false.

Returns
true if the update is valid else false.

Reimplemented from qTbot::IJsonBasedUpdate.

Definition at line 55 of file telegrammsg.cpp.

Here is the call graph for this function:

◆ languageCode()

QString qTbot::TelegramMsg::languageCode ( ) const

languageCode returns the sender's language code.

Returns
The sender's language code.

Definition at line 47 of file telegrammsg.cpp.

Here is the call graph for this function:

◆ lastName()

QString qTbot::TelegramMsg::lastName ( ) const

lastName returns the sender's last name.

Returns
The sender's last name.

Definition at line 39 of file telegrammsg.cpp.

Here is the call graph for this function:

◆ location()

QSharedPointer< TelegramLocation > qTbot::TelegramMsg::location ( ) const

location Returns the location object of the message.

Returns
the location object.

Definition at line 179 of file telegrammsg.cpp.

Here is the call graph for this function:

◆ messageId()

unsigned long long qTbot::TelegramMsg::messageId ( ) const
overridevirtual

messageId returns the message ID.

Returns
The message ID.

Implements qTbot::iMessage.

Definition at line 23 of file telegrammsg.cpp.

Here is the call graph for this function:

◆ text()

QString qTbot::TelegramMsg::text ( ) const

text returns text that contains this message object.

Returns
text of message.

Definition at line 83 of file telegrammsg.cpp.

Here is the call graph for this function:

◆ updateId()

unsigned long long qTbot::TelegramMsg::updateId ( ) const
overridevirtual

updateId This method returns the numeric id of the update.

Returns
numeric id of the update.

Implements qTbot::iUpdate.

Definition at line 183 of file telegrammsg.cpp.

◆ username()

QString qTbot::TelegramMsg::username ( ) const

username returns the sender's username.

Returns
The sender's username.

Definition at line 43 of file telegrammsg.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ Audio

const Type qTbot::TelegramMsg::Audio = "audio"

Audio This is the type of audio files.

Definition at line 85 of file telegrammsg.h.

◆ Contact

const Type qTbot::TelegramMsg::Contact = "contact"

Contact This is type of the files.

Definition at line 75 of file telegrammsg.h.

◆ Document

const Type qTbot::TelegramMsg::Document = "document"

Document This is the type of the documents.

Definition at line 70 of file telegrammsg.h.

◆ Image

const Type qTbot::TelegramMsg::Image = "photo"

Image This is the image type of the telegram.

Definition at line 65 of file telegrammsg.h.

◆ Location

const Type qTbot::TelegramMsg::Location = "location"

Location This is the type of location data.

Definition at line 80 of file telegrammsg.h.

◆ Text

const Type qTbot::TelegramMsg::Text = "text"

Text This is the text type of the message.

Definition at line 60 of file telegrammsg.h.


The documentation for this class was generated from the following files: