tgbot-cpp
Loading...
Searching...
No Matches
TgLongPoll.h
Go to the documentation of this file.
1#ifndef TGBOT_TGLONGPOLL_H
2#define TGBOT_TGLONGPOLL_H
3
4#include "tgbot/Api.h"
5#include "tgbot/export.h"
6
7#include <cstdint>
8#include <memory>
9#include <string>
10#include <vector>
11
12namespace TgBot {
13
14class Bot;
15class EventHandler;
16
22class TGBOT_API TgLongPoll {
23
24public:
25 TgLongPoll(const Api* api, const EventHandler* eventHandler, std::int32_t limit, std::int32_t timeout, std::shared_ptr<std::vector<std::string>> allowUpdates);
26 TgLongPoll(const Bot& bot, std::int32_t limit = 100, std::int32_t timeout = 10, const std::shared_ptr<std::vector<std::string>>& allowUpdates = nullptr);
27
31 void start();
32
33private:
34 const Api* _api;
35 const EventHandler* _eventHandler;
36 std::int32_t _lastUpdateId = 0;
37 std::int32_t _limit;
38 std::int32_t _timeout;
39 std::shared_ptr<std::vector<std::string>> _allowUpdates;
40
41 std::vector<Update::Ptr> _updates;
42};
43
44}
45
46#endif //TGBOT_TGLONGPOLL_H
This class executes telegram api methods. Telegram docs: https://core.telegram.org/bots/api#available...
Definition Api.h:49
This object holds other objects specific for this bot instance.
Definition Bot.h:21
This class handles long polling and updates parsing.
Definition TgLongPoll.h:22
TgLongPoll(const Bot &bot, std::int32_t limit=100, std::int32_t timeout=10, const std::shared_ptr< std::vector< std::string > > &allowUpdates=nullptr)
void start()
Starts long poll. After new update will come, this method will parse it and send to EventHandler whic...
TgLongPoll(const Api *api, const EventHandler *eventHandler, std::int32_t limit, std::int32_t timeout, std::shared_ptr< std::vector< std::string > > allowUpdates)
Definition Api.h:40