summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/tgbot/Bot.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/include/tgbot/Bot.h b/include/tgbot/Bot.h
index 49131d3..ac5d096 100644
--- a/include/tgbot/Bot.h
+++ b/include/tgbot/Bot.h
@@ -20,7 +20,10 @@ class TGBOT_API Bot {
public:
explicit Bot(std::string token, const HttpClient& httpClient = _getDefaultHttpClient())
- : _token(std::move(token)), _api(_token, httpClient), _eventHandler(_eventBroadcaster) {
+ : _token(std::move(token))
+ , _api(_token, httpClient)
+ , _eventBroadcaster(std::make_unique<EventBroadcaster>())
+ , _eventHandler(getEvents()) {
}
/**
@@ -41,7 +44,7 @@ public:
* @return Object which holds all event listeners.
*/
inline EventBroadcaster& getEvents() {
- return _eventBroadcaster;
+ return *_eventBroadcaster;
}
/**
@@ -59,7 +62,7 @@ private:
const std::string _token;
const Api _api;
- EventBroadcaster _eventBroadcaster;
+ std::unique_ptr<EventBroadcaster> _eventBroadcaster;
const EventHandler _eventHandler;
};