qTbot 0.2.102.bb22a69
qTbot is base back end library for your c++ Qt projects.
telegramargs.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 "telegramargs.h"
9namespace qTbot {
10
11TelegramArgs::TelegramArgs(const QVariant &id,
12 const QString &text,
13 unsigned long long replyToMessageId,
14 const QString &parseMode,
15 bool disableWebPagePreview,
16 const QString &callBackQueryId, const std::function<void (int)> &msgIdCB,
18{
19
20 this->chatId = id;
21 this->text = text;
22 this->callBackQueryId = callBackQueryId;
23 this->disableWebPagePreview = disableWebPagePreview;
24 this->replyToMessageId = replyToMessageId;
25 this->parseMode = parseMode;
26 this->msgIdCB = msgIdCB;
27 this->requestPriority = priority;
28}
29
30QMap<QString, QVariant> TelegramArgs::toMap(bool textAsCaption) const {
31 QMap<QString, QVariant> args {{"chat_id", chatId}};
32
33 if (text.size()) {
34 if (textAsCaption) {
35 args["caption"] = text;
36
37 } else {
38 args["text"] = text;
39 }
40 }
41
42 if (replyToMessageId) {
43 args["reply_to_message_id"] = replyToMessageId;
44 }
45
46 if (parseMode.size()) {
47 args["parse_mode"] = parseMode;
48 }
49
51 args["disable_web_page_preview"] = disableWebPagePreview;
52 }
53
54 if (callBackQueryId.size()) {
55 args["callback_query_id"] = callBackQueryId;
56 }
57
58 return args;
59}
60
61}
RequestPriority
The RequestPriority enum.
Definition irequest.h:52
QString callBackQueryId
Callback query ID. Default: "".
bool disableWebPagePreview
Disable web page preview when sending links. Default: false.
QMap< QString, QVariant > toMap(bool textAsCaption=false) const
toMap convert all arguments to the map.
iRequest::RequestPriority requestPriority
TelegramArgs(const QVariant &id, const QString &text="", unsigned long long replyToMessageId=0, const QString &parseMode="html", bool disableWebPagePreview=false, const QString &callBackQueryId="", const std::function< void(int msgId)> &msgIdCB={}, iRequest::RequestPriority priority=iRequest::RequestPriority::NormalPriority)
QString parseMode
Parse mode of the message. Default: "html".
unsigned long long replyToMessageId
ID of the message to which a reply will be given. Default: 0.
std::function< void(int msgId)> msgIdCB
msgIdCB This is id message call bak function. Will be inwoked when request finished successful.
QVariant chatId
Chat ID where the message will be sent. Default: {}.
QString text
Text of the message. Default: "".