From 436bce09662adebdf55dc01c04fa74098caf4a26 Mon Sep 17 00:00:00 2001 From: "Sebastian J. Wolf" Date: Tue, 1 Sep 2020 23:14:59 +0200 Subject: [PATCH] Enable Telegram Notification API --- src/tdlibwrapper.cpp | 14 ++++++++++++++ src/tdlibwrapper.h | 1 + 2 files changed, 15 insertions(+) diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index 82bd14e..50b8b3b 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -67,6 +67,7 @@ TDLibWrapper::TDLibWrapper(QObject *parent) : QObject(parent) this->tdLibReceiver->start(); this->setLogVerbosityLevel(); + this->setOptionInteger("notification_group_count_max", 5); } TDLibWrapper::~TDLibWrapper() @@ -218,6 +219,19 @@ void TDLibWrapper::getMessage(const QString &chatId, const QString &messageId) this->sendRequest(requestObject); } +void TDLibWrapper::setOptionInteger(const QString &optionName, const int &optionValue) +{ + qDebug() << "[TDLibWrapper] Setting integet option " << optionName << optionValue; + QVariantMap requestObject; + requestObject.insert("@type", "setOption"); + requestObject.insert("name", optionName); + QVariantMap optionValueMap; + optionValueMap.insert("@type", "optionValueInteger"); + optionValueMap.insert("value", optionValue); + requestObject.insert("value", optionValueMap); + this->sendRequest(requestObject); +} + QVariantMap TDLibWrapper::getUserInformation() { return this->userInformation; diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h index 944e9fb..85d6940 100644 --- a/src/tdlibwrapper.h +++ b/src/tdlibwrapper.h @@ -83,6 +83,7 @@ public: Q_INVOKABLE void viewMessage(const QString &chatId, const QString &messageId); Q_INVOKABLE void sendTextMessage(const QString &chatId, const QString &message, const QString &replyToMessageId = "0"); Q_INVOKABLE void getMessage(const QString &chatId, const QString &messageId); + Q_INVOKABLE void setOptionInteger(const QString &optionName, const int &optionValue); signals: void versionDetected(const QString &version);