31 _lanstUpdateTime = QDateTime::currentMSecsSinceEpoch();
44void TelegramRestBot::startUpdates() {
48 long long delta = QDateTime::currentMSecsSinceEpoch() - _lanstUpdateTime;
51 if (
delta >= _updateDelay) {
52 auto&&
replay =
sendRequest(QSharedPointer<TelegramGetUpdate>::create(_lanstUpdateid + 1));
55 handleReceiveUpdates(result);
56 }).
onFailed([
this](
const HttpException &
e){
57 handleReceiveUpdatesErr(
e.code());
63 QTimer::singleShot( _updateDelay -
delta,
this, [
this](){startUpdates();});
84void TelegramRestBot::handleReceiveUpdates(
const QByteArray &replay) {
88 _lanstUpdateTime = QDateTime::currentMSecsSinceEpoch();
95 _lanstUpdateid =
update->updateId();
103void TelegramRestBot::handleReceiveUpdatesErr(QNetworkReply::NetworkError err) {
105 qDebug() <<
"Network error occured. code: " <<
err;
static QSharedPointer< MessageType > makeMesasge(const QByteArray &data, Args &&...args)
makeMesasge This is factory method tha can create a messages types.
const QByteArray & token() const
token This is token value for authication on the remote server (bot)
void incomeNewUpdate(const QSharedPointer< iUpdate > &message)
incomeNewUpdate This method save incomed messages into store.
QFuture< QByteArray > sendRequest(const QSharedPointer< iRequest > &rquest)
sendRequest This method sent custom requests to the server.
virtual void setProcessed(const QSet< unsigned long long > &newProcessed)
setProcessed This method sets new list of processed mesages.
virtual void logout()
login This method remove login token of bot.
bool login(const QByteArray &token) override
login This method get bae information of the bot from remote server.
void logout() override
login This method remove login token of bot.
void setUpdateDelay(int newUpdateDelay)
setUpdateDelay This method sets new value for the TelegramRestBot::updateDelay property.
void setProcessed(const QSet< unsigned long long > &newProcessed) override
setProcessed This method sets new list of processed mesages.
bool login(const QByteArray &token) override
login This method get bae information of the bot from remote server.
int updateDelay() const
updateDelay This is interval "how many msec bot will be wait for sent next request of updates" By def...