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

This class holds all event listeners. More...

#include <EventBroadcaster.h>

Public Types

using MessageListener = std::function<void(std::shared_ptr<Message>)>
using InlineQueryListener = std::function<void(std::shared_ptr<InlineQuery>)>
using ChosenInlineResultListener = std::function<void(std::shared_ptr<ChosenInlineResult>)>
using CallbackQueryListener = std::function<void(std::shared_ptr<CallbackQuery>)>
using ShippingQueryListener = std::function<void(std::shared_ptr<ShippingQuery>)>
using PreCheckoutQueryListener = std::function<void(std::shared_ptr<PreCheckoutQuery>)>
using PollListener = std::function<void(std::shared_ptr<Poll>)>
using PollAnswerListener = std::function<void(std::shared_ptr<PollAnswer>)>
using ChatMemberUpdatedListener = std::function<void(std::shared_ptr<ChatMemberUpdated>)>
using ChatJoinRequestListener = std::function<void(std::shared_ptr<ChatJoinRequest>)>
using MessageReactionUpdatedListener = std::function<void(std::shared_ptr<MessageReactionUpdated>)>
using MessageReactionCountUpdatedListener = std::function<void(std::shared_ptr<MessageReactionCountUpdated>)>
using SuccessfulPaymentListener = std::function<void(std::shared_ptr<Message>, std::shared_ptr<SuccessfulPayment>)>

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.
void onMessageReaction (const MessageReactionUpdatedListener &listener)
 Registers listener which receives new incoming message reaction update event.
void onMessageReactionCount (const MessageReactionCountUpdatedListener &listener)
 Registers listener which receives new incoming message reaction count update event.
void onSuccessfulPayment (const SuccessfulPaymentListener &listener)
 Registers listener which receives information about successful payments. This listener is triggered when a successful payment is received by the bot.

Detailed Description

This class holds all event listeners.

Definition at line 21 of file EventBroadcaster.h.

Member Typedef Documentation

◆ CallbackQueryListener

using TgBot::EventBroadcaster::CallbackQueryListener = std::function<void(std::shared_ptr<CallbackQuery>)>

Definition at line 28 of file EventBroadcaster.h.

◆ ChatJoinRequestListener

using TgBot::EventBroadcaster::ChatJoinRequestListener = std::function<void(std::shared_ptr<ChatJoinRequest>)>

Definition at line 34 of file EventBroadcaster.h.

◆ ChatMemberUpdatedListener

using TgBot::EventBroadcaster::ChatMemberUpdatedListener = std::function<void(std::shared_ptr<ChatMemberUpdated>)>

Definition at line 33 of file EventBroadcaster.h.

◆ ChosenInlineResultListener

using TgBot::EventBroadcaster::ChosenInlineResultListener = std::function<void(std::shared_ptr<ChosenInlineResult>)>

Definition at line 27 of file EventBroadcaster.h.

◆ InlineQueryListener

using TgBot::EventBroadcaster::InlineQueryListener = std::function<void(std::shared_ptr<InlineQuery>)>

Definition at line 26 of file EventBroadcaster.h.

◆ MessageListener

using TgBot::EventBroadcaster::MessageListener = std::function<void(std::shared_ptr<Message>)>

Definition at line 25 of file EventBroadcaster.h.

◆ MessageReactionCountUpdatedListener

Definition at line 36 of file EventBroadcaster.h.

◆ MessageReactionUpdatedListener

Definition at line 35 of file EventBroadcaster.h.

◆ PollAnswerListener

using TgBot::EventBroadcaster::PollAnswerListener = std::function<void(std::shared_ptr<PollAnswer>)>

Definition at line 32 of file EventBroadcaster.h.

◆ PollListener

using TgBot::EventBroadcaster::PollListener = std::function<void(std::shared_ptr<Poll>)>

Definition at line 31 of file EventBroadcaster.h.

◆ PreCheckoutQueryListener

using TgBot::EventBroadcaster::PreCheckoutQueryListener = std::function<void(std::shared_ptr<PreCheckoutQuery>)>

Definition at line 30 of file EventBroadcaster.h.

◆ ShippingQueryListener

using TgBot::EventBroadcaster::ShippingQueryListener = std::function<void(std::shared_ptr<ShippingQuery>)>

Definition at line 29 of file EventBroadcaster.h.

◆ SuccessfulPaymentListener

using TgBot::EventBroadcaster::SuccessfulPaymentListener = std::function<void(std::shared_ptr<Message>, std::shared_ptr<SuccessfulPayment>)>

Definition at line 37 of file EventBroadcaster.h.

Member Function Documentation

◆ onAnyMessage()

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

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

Parameters
listenerListener.

◆ onCallbackQuery()

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

Registers listener which receives new incoming callback queries.

Parameters
listenerListener.

◆ onChatJoinRequest()

void TgBot::EventBroadcaster::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.

Parameters
listenerListener.

◆ onChatMember()

void TgBot::EventBroadcaster::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.

Parameters
listenerListener.

◆ onChosenInlineResult()

void TgBot::EventBroadcaster::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.

Parameters
listenerListener.

◆ onCommand() [1/2]

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

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

◆ onCommand() [2/2]

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

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

◆ onEditedMessage()

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

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

Parameters
listenerListener.

◆ onInlineQuery()

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

Registers listener which receives new incoming inline queries.

Parameters
listenerListener.

◆ onMessageReaction()

void TgBot::EventBroadcaster::onMessageReaction ( const MessageReactionUpdatedListener & listener)

Registers listener which receives new incoming message reaction update event.

Parameters
listenerListener.

◆ onMessageReactionCount()

void TgBot::EventBroadcaster::onMessageReactionCount ( const MessageReactionCountUpdatedListener & listener)

Registers listener which receives new incoming message reaction count update event.

Parameters
listenerListener.

◆ onMyChatMember()

void TgBot::EventBroadcaster::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.

Parameters
listenerListener.

◆ onNonCommandMessage()

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

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

Parameters
listenerListener.

◆ onPoll()

void TgBot::EventBroadcaster::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.

Parameters
listenerListener.

◆ onPollAnswer()

void TgBot::EventBroadcaster::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.

Parameters
listenerListener.

◆ onPreCheckoutQuery()

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

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

Parameters
listenerListener.

◆ onShippingQuery()

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

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

Parameters
listenerListener.

◆ onSuccessfulPayment()

void TgBot::EventBroadcaster::onSuccessfulPayment ( const SuccessfulPaymentListener & listener)

Registers listener which receives information about successful payments. This listener is triggered when a successful payment is received by the bot.

Parameters
listenerListener.

◆ onUnknownCommand()

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

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

Parameters
listenerListener.

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