tgbot-cpp
Loading...
Searching...
No Matches
TgBot::EventBroadcaster Class Reference

This class holds all event listeners. More...

#include <EventBroadcaster.h>

Public Types

typedef std::function< void(const Message::Ptr)> MessageListener
 
typedef std::function< void(const InlineQuery::Ptr)> InlineQueryListener
 
typedef std::function< void(const ChosenInlineResult::Ptr)> ChosenInlineResultListener
 
typedef std::function< void(const CallbackQuery::Ptr)> CallbackQueryListener
 
typedef std::function< void(const ShippingQuery::Ptr)> ShippingQueryListener
 
typedef std::function< void(const PreCheckoutQuery::Ptr)> PreCheckoutQueryListener
 
typedef std::function< void(const Poll::Ptr)> PollListener
 
typedef std::function< void(const PollAnswer::Ptr)> PollAnswerListener
 
typedef std::function< void(const ChatMemberUpdated::Ptr)> ChatMemberUpdatedListener
 
typedef std::function< void(const ChatJoinRequest::Ptr)> ChatJoinRequestListener
 

Public Member Functions

void onAnyMessage (const MessageListener &listener)
 Registers listener which receives new incoming message of any kind - text, photo, sticker, etc.
 
void onCommand (const std::string &commandName, const MessageListener &listener)
 Registers listener which receives all messages with commands (messages with leading '/' char).
 
void onCommand (const std::initializer_list< std::string > &commandsList, const MessageListener &listener)
 Registers listener which receives all messages with commands (messages with leading '/' char).
 
void onUnknownCommand (const MessageListener &listener)
 Registers listener which receives all messages with commands (messages with leading '/' char) which haven't been handled by other listeners.
 
void onNonCommandMessage (const MessageListener &listener)
 Registers listener which receives all messages without commands (messages with no leading '/' char)
 
void onEditedMessage (const MessageListener &listener)
 Registers listener which receives new versions of a message that is known to the bot and was edited.
 
void onInlineQuery (const InlineQueryListener &listener)
 Registers listener which receives new incoming inline queries.
 
void onChosenInlineResult (const ChosenInlineResultListener &listener)
 Registers listener which receives the results of an inline query that was chosen by a user and sent to their chat partner. Please see https://core.telegram.org/bots/inline#collecting-feedback for details on how to enable these updates for your bot.
 
void onCallbackQuery (const CallbackQueryListener &listener)
 Registers listener which receives new incoming callback queries.
 
void onShippingQuery (const ShippingQueryListener &listener)
 Registers listener which receives new incoming shipping queries. Only for invoices with flexible price.
 
void onPreCheckoutQuery (const PreCheckoutQueryListener &listener)
 Registers listener which receives new incoming pre-checkout queries. Contains full information about checkout.
 
void onPoll (const PollListener &listener)
 Registers listener which receives new poll states. Bots receive only updates about stopped polls and polls, which are sent by the bot.
 
void onPollAnswer (const PollAnswerListener &listener)
 Registers listener which receives an answer if a user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself.
 
void onMyChatMember (const ChatMemberUpdatedListener &listener)
 Registers listener which receives the bot's chat member status if it was updated in a chat. For private chats, this update is received only when the bot is blocked or unblocked by the user.
 
void onChatMember (const ChatMemberUpdatedListener &listener)
 Registers listener which receives a status if a chat member's status was updated in a chat. The bot must be an administrator in the chat and must explicitly specify “chat_member” in the list of allowedUpdates to receive these updates.
 
void onChatJoinRequest (const ChatJoinRequestListener &listener)
 Registers listener which receives requests to join the chat. The bot must have the canInviteUsers administrator right in the chat to receive these updates.
 

Detailed Description

This class holds all event listeners.

Definition at line 31 of file EventBroadcaster.h.

Member Typedef Documentation

◆ CallbackQueryListener

Definition at line 39 of file EventBroadcaster.h.

◆ ChatJoinRequestListener

Definition at line 45 of file EventBroadcaster.h.

◆ ChatMemberUpdatedListener

Definition at line 44 of file EventBroadcaster.h.

◆ ChosenInlineResultListener

Definition at line 38 of file EventBroadcaster.h.

◆ InlineQueryListener

Definition at line 37 of file EventBroadcaster.h.

◆ MessageListener

typedef std::function<void (const Message::Ptr)> TgBot::EventBroadcaster::MessageListener

Definition at line 36 of file EventBroadcaster.h.

◆ PollAnswerListener

typedef std::function<void (const PollAnswer::Ptr)> TgBot::EventBroadcaster::PollAnswerListener

Definition at line 43 of file EventBroadcaster.h.

◆ PollListener

typedef std::function<void (const Poll::Ptr)> TgBot::EventBroadcaster::PollListener

Definition at line 42 of file EventBroadcaster.h.

◆ PreCheckoutQueryListener

Definition at line 41 of file EventBroadcaster.h.

◆ ShippingQueryListener

Definition at line 40 of file EventBroadcaster.h.

Member Function Documentation

◆ onAnyMessage()

void TgBot::EventBroadcaster::onAnyMessage ( const MessageListener & listener)
inline

Registers listener which receives new incoming message of any kind - text, photo, sticker, etc.

Parameters
listenerListener.

Definition at line 51 of file EventBroadcaster.h.

◆ onCallbackQuery()

void TgBot::EventBroadcaster::onCallbackQuery ( const CallbackQueryListener & listener)
inline

Registers listener which receives new incoming callback queries.

Parameters
listenerListener.

Definition at line 131 of file EventBroadcaster.h.

◆ onChatJoinRequest()

void TgBot::EventBroadcaster::onChatJoinRequest ( const ChatJoinRequestListener & listener)
inline

Registers listener which receives requests to join the chat. The bot must have the canInviteUsers administrator right in the chat to receive these updates.

Parameters
listenerListener.

Definition at line 201 of file EventBroadcaster.h.

◆ onChatMember()

void TgBot::EventBroadcaster::onChatMember ( const ChatMemberUpdatedListener & listener)
inline

Registers listener which receives a status if a chat member's status was updated in a chat. The bot must be an administrator in the chat and must explicitly specify “chat_member” in the list of allowedUpdates to receive these updates.

Parameters
listenerListener.

Definition at line 191 of file EventBroadcaster.h.

◆ onChosenInlineResult()

void TgBot::EventBroadcaster::onChosenInlineResult ( const ChosenInlineResultListener & listener)
inline

Registers listener which receives the results of an inline query that was chosen by a user and sent to their chat partner. Please see https://core.telegram.org/bots/inline#collecting-feedback for details on how to enable these updates for your bot.

Parameters
listenerListener.

Definition at line 123 of file EventBroadcaster.h.

◆ onCommand() [1/2]

void TgBot::EventBroadcaster::onCommand ( const std::initializer_list< std::string > & commandsList,
const MessageListener & listener )
inline

Registers listener which receives all messages with commands (messages with leading '/' char).

Parameters
commandsListCommands names which listener can handle.
listenerListener. Pass nullptr to remove listener of commands

Definition at line 73 of file EventBroadcaster.h.

◆ onCommand() [2/2]

void TgBot::EventBroadcaster::onCommand ( const std::string & commandName,
const MessageListener & listener )
inline

Registers listener which receives all messages with commands (messages with leading '/' char).

Parameters
commandNameCommand name which listener can handle.
listenerListener. Pass nullptr to remove listener of command

Definition at line 60 of file EventBroadcaster.h.

◆ onEditedMessage()

void TgBot::EventBroadcaster::onEditedMessage ( const MessageListener & listener)
inline

Registers listener which receives new versions of a message that is known to the bot and was edited.

Parameters
listenerListener.

Definition at line 105 of file EventBroadcaster.h.

◆ onInlineQuery()

void TgBot::EventBroadcaster::onInlineQuery ( const InlineQueryListener & listener)
inline

Registers listener which receives new incoming inline queries.

Parameters
listenerListener.

Definition at line 113 of file EventBroadcaster.h.

◆ onMyChatMember()

void TgBot::EventBroadcaster::onMyChatMember ( const ChatMemberUpdatedListener & listener)
inline

Registers listener which receives the bot's chat member status if it was updated in a chat. For private chats, this update is received only when the bot is blocked or unblocked by the user.

Parameters
listenerListener.

Definition at line 181 of file EventBroadcaster.h.

◆ onNonCommandMessage()

void TgBot::EventBroadcaster::onNonCommandMessage ( const MessageListener & listener)
inline

Registers listener which receives all messages without commands (messages with no leading '/' char)

Parameters
listenerListener.

Definition at line 97 of file EventBroadcaster.h.

◆ onPoll()

void TgBot::EventBroadcaster::onPoll ( const PollListener & listener)
inline

Registers listener which receives new poll states. Bots receive only updates about stopped polls and polls, which are sent by the bot.

Parameters
listenerListener.

Definition at line 161 of file EventBroadcaster.h.

◆ onPollAnswer()

void TgBot::EventBroadcaster::onPollAnswer ( const PollAnswerListener & listener)
inline

Registers listener which receives an answer if a user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself.

Parameters
listenerListener.

Definition at line 171 of file EventBroadcaster.h.

◆ onPreCheckoutQuery()

void TgBot::EventBroadcaster::onPreCheckoutQuery ( const PreCheckoutQueryListener & listener)
inline

Registers listener which receives new incoming pre-checkout queries. Contains full information about checkout.

Parameters
listenerListener.

Definition at line 151 of file EventBroadcaster.h.

◆ onShippingQuery()

void TgBot::EventBroadcaster::onShippingQuery ( const ShippingQueryListener & listener)
inline

Registers listener which receives new incoming shipping queries. Only for invoices with flexible price.

Parameters
listenerListener.

Definition at line 141 of file EventBroadcaster.h.

◆ onUnknownCommand()

void TgBot::EventBroadcaster::onUnknownCommand ( const MessageListener & listener)
inline

Registers listener which receives all messages with commands (messages with leading '/' char) which haven't been handled by other listeners.

Parameters
listenerListener.

Definition at line 89 of file EventBroadcaster.h.


The documentation for this class was generated from the following file: