diff options
author | llnulldisk <48621230+llnulldisk@users.noreply.github.com> | 2022-10-18 18:25:18 +0200 |
---|---|---|
committer | llnulldisk <48621230+llnulldisk@users.noreply.github.com> | 2022-10-18 18:25:18 +0200 |
commit | a547fca53b0cad280a4ef3a42b65490efc8e631d (patch) | |
tree | 341323c337373c8b04d3ebae7fc2188fd264f82e /src/EventHandler.cpp | |
parent | 1d238b70e2655e64b1cb1a51357a9eb0c753181d (diff) |
Update EventBroadcaster (#235)
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); |