qTbot 0.89.ee6949a
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)
17{
18
19 this->chatId = id;
20 this->text = text;
21 this->callBackQueryId = callBackQueryId;
22 this->disableWebPagePreview = disableWebPagePreview;
23 this->replyToMessageId = replyToMessageId;
24 this->parseMode = parseMode;
25 this->msgIdCB = msgIdCB;
26}
27
28QMap<QString, QVariant> TelegramArgs::toMap(bool textAsCaption) const {
29 QMap<QString, QVariant> args {{"chat_id", chatId}};
30
31 if (text.size()) {
32 if (textAsCaption) {
33 args["caption"] = text;
34
35 } else {
36 args["text"] = text;
37 }
38 }
39
40 if (replyToMessageId) {
41 args["reply_to_message_id"] = replyToMessageId;
42 }
43
44 if (parseMode.size()) {
45 args["parse_mode"] = parseMode;
46 }
47
49 args["disable_web_page_preview"] = disableWebPagePreview;
50 }
51
52 if (callBackQueryId.size()) {
53 args["callback_query_id"] = callBackQueryId;
54 }
55
56 return args;
57}
58
59}
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.
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: {}.
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={})
QString text
Text of the message. Default: "".