From ff11276c9a3f58b7d1fbcbbae0892b438d193bb6 Mon Sep 17 00:00:00 2001 From: Daniel Demidko Date: Sun, 11 Jul 2021 02:19:17 +1000 Subject: Channels support --- src/Api.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src') diff --git a/src/Api.cpp b/src/Api.cpp index 9acf1bb..08b102a 100644 --- a/src/Api.cpp +++ b/src/Api.cpp @@ -45,6 +45,29 @@ Message::Ptr Api::sendMessage(std::int64_t chatId, const string& text, bool disa } return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendMessage", args)); } + +Message::Ptr Api::sendMessage(const std::string &chatId, const string& text, bool disableWebPagePreview, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const { + vector args; + args.reserve(7); + args.emplace_back("chat_id", chatId); + args.emplace_back("text", text); + if (disableWebPagePreview) { + args.emplace_back("disable_web_page_preview", disableWebPagePreview); + } + if (disableNotification){ + args.emplace_back("disable_notification", disableNotification); + } + if (replyToMessageId) { + args.emplace_back("reply_to_message_id", replyToMessageId); + } + if (replyMarkup) { + args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); + } + if (!parseMode.empty()) { + args.emplace_back("parse_mode", parseMode); + } + return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendMessage", args)); +} Message::Ptr Api::forwardMessage(std::int64_t chatId, std::int64_t fromChatId, std::int32_t messageId, bool disableNotification) const { vector args; -- cgit v1.2.3