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

The TelegramMsg class This class provide general mesasges of telegram. The message object can contains text, geo or link to video,image. all this dates can be contains in one object. More...

#include <telegrammsg.h>

Public Types

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

Public Member Functions

 TelegramMsg ()
 
 TelegramMsg (const QJsonObject &obj)
 
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 return true if the message is valid else false.
 
QString from () const override
 from This virtual function should return name of the user that sent this message to 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 date of the snet message.
 
QString text () const
 text returns text that contains this message object.
 
QString fullText () const
 fullText return text + caption value
 
QString caption () const
 caption return only caption value
 
bool contains (const Type &type)
 contains This method returns true if the message contains choosed data type.
 
QList< QSharedPointer< TelegramImage > > images () const
 images This function returns array of available images qualites
 
QSharedPointer< TelegramImageimage (QualitySelector behavior=AroundSize, int size=100000) const
 Retrieve an image from the Telegram service with specified quality and size parameters.
 
QSharedPointer< TelegramDocumentdocuments () const
 documents This method returns contained document data.
 
QSharedPointer< TelegramAudioaudio () const
 audio This method returns contained audio data.
 
QSharedPointer< TelegramContactcontact () const
 contact return contact
 
unsigned long long updateId () const override
 updateId This method returns numeric id of the update.
 
QSharedPointer< TelegramLocationlocation () const
 location returns location object of message.
 
- Public Member Functions inherited from qTbot::iMessage
 iMessage ()
 
- Public Member Functions inherited from qTbot::IJsonBasedUpdate
 IJsonBasedUpdate ()
 
void setRawData (const QByteArray &newRawData) override
 setRawData This method sets new raw data value.
 
- Public Member Functions inherited from qTbot::iUpdate
 iUpdate ()
 
const QByteArray & rawData () const
 rawData returns raw data of the message. The raw data is not parsed value form the server.
 
- Public Member Functions inherited from qTbot::IJsonBasedObject
 IJsonBasedObject ()
 
 IJsonBasedObject (const QJsonObject &newRawJson)
 
const QJsonObject & rawJson () const
 rawJson Telegram use rest api with json objects. So all received messages will be parsed in to jsobject.
 
virtual void setRawJson (const QJsonObject &newRawJson)
 setRawJson this method convert jsobject into telegram message.
 

Public Attributes

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

Detailed Description

The TelegramMsg class This class provide general mesasges of telegram. The message object can contains text, geo or link to video,image. all this dates can be contains in one object.

Definition at line 24 of file telegrammsg.h.

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

Member Typedef Documentation

◆ Type

using qTbot::TelegramMsg::Type = QString

Type just string value of the telegram messages types.

Definition at line 48 of file telegrammsg.h.

Member Enumeration Documentation

◆ QualitySelector

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

Enumerator
AroundSize 

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

BestOf 

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

Best 

This selection returns best iamge of available.

Fast 

This selection returns faster iamge of available. (minimum size)

Definition at line 31 of file telegrammsg.h.

Constructor & Destructor Documentation

◆ TelegramMsg() [1/2]

qTbot::TelegramMsg::TelegramMsg ( )

Definition at line 14 of file telegrammsg.cpp.

◆ TelegramMsg() [2/2]

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

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 contained audio data.

Returns
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 return only caption value

Returns
only 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 return contact

Returns
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 choosed data type.

Parameters
typeThis is name of the type
Returns
true if the choosed 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 date of the snet 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 contained document data.

Returns
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 name of the user that sent this message to 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 return text + caption value

Returns
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 array of available images qualites

Returns
array of available images qualites

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 return true if the message is valid else false.

Returns
true if the message 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 location object of message.

Returns
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 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 type of Audio files.

Definition at line 78 of file telegrammsg.h.

◆ Contact

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

Contact This is type of the files.

Definition at line 68 of file telegrammsg.h.

◆ Document

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

Document This is type of the files.

Definition at line 63 of file telegrammsg.h.

◆ Image

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

Image This is image type of the telegram.

Definition at line 58 of file telegrammsg.h.

◆ Location

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

Location This is type of location data.

Definition at line 73 of file telegrammsg.h.

◆ Text

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

Text This is text type of the message.

Definition at line 53 of file telegrammsg.h.


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