mirror of
https://github.com/QuasarApp/qTbot.git
synced 2025-04-27 14:24:33 +00:00
commit
e989530c94
@ -17,7 +17,7 @@ namespace qTbot {
|
|||||||
* @brief The FileWaiter class. This is a simple storage for the shared pointer of files.
|
* @brief The FileWaiter class. This is a simple storage for the shared pointer of files.
|
||||||
* All added files will be removed (shared object) after finish donwload or upload.
|
* All added files will be removed (shared object) after finish donwload or upload.
|
||||||
*/
|
*/
|
||||||
class FileWaiter: public QObject
|
class QTBOT_EXPORT FileWaiter: public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -21,6 +21,10 @@ IBot::~IBot() {
|
|||||||
delete _manager;
|
delete _manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IBot::logout() {
|
||||||
|
setToken({});
|
||||||
|
}
|
||||||
|
|
||||||
const QByteArray &IBot::token() const {
|
const QByteArray &IBot::token() const {
|
||||||
return _token;
|
return _token;
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual bool login(const QByteArray& token) = 0;
|
virtual bool login(const QByteArray& token) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief login This method remove login token of bot.
|
||||||
|
*/
|
||||||
|
virtual void logout();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief sendMessage This method sents text to the selected chat.
|
* @brief sendMessage This method sents text to the selected chat.
|
||||||
* @param chatId This is selected chat id
|
* @param chatId This is selected chat id
|
||||||
@ -223,6 +228,11 @@ signals:
|
|||||||
*/
|
*/
|
||||||
void sigReceiveUpdate(const QSharedPointer<iUpdate>& );
|
void sigReceiveUpdate(const QSharedPointer<iUpdate>& );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief sigStopRequire just custm event for stop bot if tou use services.
|
||||||
|
*/
|
||||||
|
void sigStopRequire();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void doRemoveFinishedRequests();
|
void doRemoveFinishedRequests();
|
||||||
|
|
||||||
|
@ -505,8 +505,14 @@ bool ITelegramBot::sendMessageRequest(const QSharedPointer<iRequest> &rquest,
|
|||||||
if (chatId) {
|
if (chatId) {
|
||||||
_lastMessageId[chatId] = messageID;
|
_lastMessageId[chatId] = messageID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (msgIdCB) {
|
||||||
|
msgIdCB(-1);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ namespace qTbot {
|
|||||||
/**
|
/**
|
||||||
* @brief The TelegramLocation class just simple struct with latitude and longitude
|
* @brief The TelegramLocation class just simple struct with latitude and longitude
|
||||||
*/
|
*/
|
||||||
class TelegramLocation: public IJsonBasedObject
|
class QTBOT_EXPORT TelegramLocation: public IJsonBasedObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TelegramLocation();
|
TelegramLocation();
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <qTbot/messages/telegrammsg.h>
|
#include <qTbot/messages/telegrammsg.h>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
namespace qTbot {
|
namespace qTbot {
|
||||||
|
|
||||||
@ -28,13 +29,22 @@ bool TelegramRestBot::login(const QByteArray &token) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_lanstUpdateTime = QDateTime::currentMSecsSinceEpoch();
|
_lanstUpdateTime = QDateTime::currentMSecsSinceEpoch();
|
||||||
|
_run = true;
|
||||||
|
|
||||||
startUpdates();
|
startUpdates();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TelegramRestBot::logout() {
|
||||||
|
_run = false;
|
||||||
|
ITelegramBot::logout();
|
||||||
|
}
|
||||||
|
|
||||||
void TelegramRestBot::startUpdates() {
|
void TelegramRestBot::startUpdates() {
|
||||||
|
if (!_run)
|
||||||
|
return;
|
||||||
|
|
||||||
long long delta = QDateTime::currentMSecsSinceEpoch() - _lanstUpdateTime;
|
long long delta = QDateTime::currentMSecsSinceEpoch() - _lanstUpdateTime;
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,8 +26,9 @@ public:
|
|||||||
~TelegramRestBot();
|
~TelegramRestBot();
|
||||||
|
|
||||||
// IBot interface
|
// IBot interface
|
||||||
bool login(const QByteArray &token);
|
bool login(const QByteArray &token) override;
|
||||||
|
|
||||||
|
void logout() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief updateDelay This is interval "how many msec bot will be wait for sent next request of updates" By defaul is 1000 msecs.
|
* @brief updateDelay This is interval "how many msec bot will be wait for sent next request of updates" By defaul is 1000 msecs.
|
||||||
@ -49,6 +50,7 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
void startUpdates();
|
void startUpdates();
|
||||||
|
|
||||||
|
bool _run = false;
|
||||||
long long _lanstUpdateTime = 0;
|
long long _lanstUpdateTime = 0;
|
||||||
unsigned long long _lanstUpdateid = 0;
|
unsigned long long _lanstUpdateid = 0;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user