23 #ifndef TGBOT_EVENTHANDLER_H 24 #define TGBOT_EVENTHANDLER_H 35 _broadcaster->broadcastAnyMessage(message);
38 unsigned long splitPosition;
39 unsigned long spacePosition = message->text.find(
' ');
40 unsigned long atSymbolPosition = message->text.find(
'@');
41 if (spacePosition == message->text.npos) {
42 if (atSymbolPosition == message->text.npos) {
43 splitPosition = message->text.size();
45 splitPosition = atSymbolPosition;
47 }
else if (atSymbolPosition == message->text.npos) {
48 splitPosition = spacePosition;
50 splitPosition = std::min(spacePosition, atSymbolPosition);
52 std::string command = message->text.substr(1, splitPosition - 1);
53 if (!_broadcaster->broadcastCommand(command, message)) {
54 _broadcaster->broadcastUnknownCommand(message);
57 _broadcaster->broadcastNonCommandMessage(message);
66 if (update->inlineQuery != NULL)
67 _broadcaster->broadcastInlineQuery(update->inlineQuery);
68 if (update->chosenInlineResult != NULL)
69 _broadcaster->broadcastChosenInlineResult(update->chosenInlineResult);
70 if (update->callbackQuery != NULL)
71 _broadcaster->broadcastCallbackQuery(update->callbackQuery);
72 if (update->message != NULL)
73 handleMessage(update->message);
82 #endif //TGBOT_EVENTHANDLER_H
std::shared_ptr< Update > Ptr
std::shared_ptr< Message > Ptr
EventHandler(const EventBroadcaster *broadcaster)
void handleUpdate(const Update::Ptr &update) const