diff options
author | Oleg Morozenkov <o.morozenkov@corp.mail.ru> | 2022-11-01 19:43:42 +0300 |
---|---|---|
committer | Oleg Morozenkov <o.morozenkov@corp.mail.ru> | 2022-11-01 19:43:42 +0300 |
commit | e96d3a3d4f023dc0d5d4e60fb8efb5a40ce7a71d (patch) | |
tree | f57f44b1448204120229bd83f3654b32e3df79ed /src/EventHandler.cpp | |
parent | 30136601c6755e5d7c2174ebd4ed49595e10a54b (diff) | |
parent | 7abb2509b87ef1344da97ae734211715f291cfa2 (diff) |
Merge remote-tracking branch 'llnulldisk/master' into merge-228
Diffstat (limited to 'src/EventHandler.cpp')
-rw-r--r-- | src/EventHandler.cpp | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/src/EventHandler.cpp b/src/EventHandler.cpp index edf4c13..1a6ed40 100644 --- a/src/EventHandler.cpp +++ b/src/EventHandler.cpp @@ -1,14 +1,20 @@ #include "tgbot/EventHandler.h" -#include <algorithm> -#include <cstddef> -#include <string> - -using namespace std; - namespace TgBot { void EventHandler::handleUpdate(const Update::Ptr& update) const { + if (update->message != nullptr) { + handleMessage(update->message); + } + if (update->editedMessage != nullptr) { + _broadcaster.broadcastEditedMessage(update->editedMessage); + } + if (update->channelPost != nullptr) { + handleMessage(update->channelPost); + } + if (update->editedChannelPost != nullptr) { + _broadcaster.broadcastEditedMessage(update->editedChannelPost); + } if (update->inlineQuery != nullptr) { _broadcaster.broadcastInlineQuery(update->inlineQuery); } @@ -18,11 +24,26 @@ void EventHandler::handleUpdate(const Update::Ptr& update) const { if (update->callbackQuery != nullptr) { _broadcaster.broadcastCallbackQuery(update->callbackQuery); } - if (update->message != nullptr) { - handleMessage(update->message); + if (update->shippingQuery != nullptr) { + _broadcaster.broadcastShippingQuery(update->shippingQuery); } - if (update->channelPost != nullptr) { - handleMessage(update->channelPost); + if (update->preCheckoutQuery != nullptr) { + _broadcaster.broadcastPreCheckoutQuery(update->preCheckoutQuery); + } + if (update->poll != nullptr) { + _broadcaster.broadcastPoll(update->poll); + } + if (update->pollAnswer != nullptr) { + _broadcaster.broadcastPollAnswer(update->pollAnswer); + } + if (update->myChatMember != nullptr) { + _broadcaster.broadcastMyChatMember(update->myChatMember); + } + if (update->chatMember != nullptr) { + _broadcaster.broadcastChatMember(update->chatMember); + } + if (update->chatJoinRequest != nullptr) { + _broadcaster.broadcastChatJoinRequest(update->chatJoinRequest); } } @@ -33,13 +54,13 @@ void EventHandler::handleMessage(const Message::Ptr& message) const { std::size_t splitPosition; std::size_t spacePosition = message->text.find(' '); std::size_t atSymbolPosition = message->text.find('@'); - if (spacePosition == string::npos) { - if (atSymbolPosition == string::npos) { + if (spacePosition == std::string::npos) { + if (atSymbolPosition == std::string::npos) { splitPosition = message->text.size(); } else { splitPosition = atSymbolPosition; } - } else if (atSymbolPosition == string::npos) { + } else if (atSymbolPosition == std::string::npos) { splitPosition = spacePosition; } else { splitPosition = std::min(spacePosition, atSymbolPosition); |