52 _onAnyMessageListeners.push_back(listener);
62 _onCommandListeners[commandName] = listener;
64 _onCommandListeners.erase(commandName);
75 for (
const auto& command : commandsList) {
76 _onCommandListeners[command] = listener;
79 for (
const auto& command : commandsList) {
80 _onCommandListeners.erase(command);
90 _onUnknownCommandListeners.push_back(listener);
98 _onNonCommandMessageListeners.push_back(listener);
106 _onEditedMessageListeners.push_back(listener);
114 _onInlineQueryListeners.push_back(listener);
124 _onChosenInlineResultListeners.push_back(listener);
132 _onCallbackQueryListeners.push_back(listener);
142 _onShippingQueryListeners.push_back(listener);
152 _onPreCheckoutQueryListeners.push_back(listener);
162 _onPollListeners.push_back(listener);
172 _onPollAnswerListeners.push_back(listener);
182 _onMyChatMemberListeners.push_back(listener);
192 _onChatMemberListeners.push_back(listener);
202 _onChatJoinRequestListeners.push_back(listener);
206 template<
typename ListenerType,
typename ObjectType>
207 inline void broadcast(
const std::vector<ListenerType>& listeners,
const ObjectType
object)
const {
211 for (
const ListenerType& item : listeners) {
216 inline void broadcastAnyMessage(
const Message::Ptr& message)
const {
217 broadcast<MessageListener, Message::Ptr>(_onAnyMessageListeners, message);
220 inline bool broadcastCommand(
const std::string& command,
const Message::Ptr& message)
const {
221 auto iter = _onCommandListeners.find(command);
222 if (iter == _onCommandListeners.end()) {
225 iter->second(message);
229 inline void broadcastUnknownCommand(
const Message::Ptr& message)
const {
230 broadcast<MessageListener, Message::Ptr>(_onUnknownCommandListeners, message);
233 inline void broadcastNonCommandMessage(
const Message::Ptr& message)
const {
234 broadcast<MessageListener, Message::Ptr>(_onNonCommandMessageListeners, message);
237 inline void broadcastEditedMessage(
const Message::Ptr& message)
const {
238 broadcast<MessageListener, Message::Ptr>(_onEditedMessageListeners, message);
241 inline void broadcastInlineQuery(
const InlineQuery::Ptr& query)
const {
242 broadcast<InlineQueryListener, InlineQuery::Ptr>(_onInlineQueryListeners, query);
245 inline void broadcastChosenInlineResult(
const ChosenInlineResult::Ptr& result)
const {
246 broadcast<ChosenInlineResultListener, ChosenInlineResult::Ptr>(_onChosenInlineResultListeners, result);
249 inline void broadcastCallbackQuery(
const CallbackQuery::Ptr& result)
const {
250 broadcast<CallbackQueryListener, CallbackQuery::Ptr>(_onCallbackQueryListeners, result);
253 inline void broadcastShippingQuery(
const ShippingQuery::Ptr& result)
const {
254 broadcast<ShippingQueryListener, ShippingQuery::Ptr>(_onShippingQueryListeners, result);
257 inline void broadcastPreCheckoutQuery(
const PreCheckoutQuery::Ptr& result)
const {
258 broadcast<PreCheckoutQueryListener, PreCheckoutQuery::Ptr>(_onPreCheckoutQueryListeners, result);
261 inline void broadcastPoll(
const Poll::Ptr& result)
const {
262 broadcast<PollListener, Poll::Ptr>(_onPollListeners, result);
265 inline void broadcastPollAnswer(
const PollAnswer::Ptr& result)
const {
266 broadcast<PollAnswerListener, PollAnswer::Ptr>(_onPollAnswerListeners, result);
269 inline void broadcastMyChatMember(
const ChatMemberUpdated::Ptr& result)
const {
270 broadcast<ChatMemberUpdatedListener, ChatMemberUpdated::Ptr>(_onMyChatMemberListeners, result);
273 inline void broadcastChatMember(
const ChatMemberUpdated::Ptr& result)
const {
274 broadcast<ChatMemberUpdatedListener, ChatMemberUpdated::Ptr>(_onChatMemberListeners, result);
277 inline void broadcastChatJoinRequest(
const ChatJoinRequest::Ptr& result)
const {
278 broadcast<ChatJoinRequestListener, ChatJoinRequest::Ptr>(_onChatJoinRequestListeners, result);
281 std::vector<MessageListener> _onAnyMessageListeners;
282 std::unordered_map<std::string, MessageListener> _onCommandListeners;
283 std::vector<MessageListener> _onUnknownCommandListeners;
284 std::vector<MessageListener> _onNonCommandMessageListeners;
285 std::vector<MessageListener> _onEditedMessageListeners;
286 std::vector<InlineQueryListener> _onInlineQueryListeners;
287 std::vector<ChosenInlineResultListener> _onChosenInlineResultListeners;
288 std::vector<CallbackQueryListener> _onCallbackQueryListeners;
289 std::vector<ShippingQueryListener> _onShippingQueryListeners;
290 std::vector<PreCheckoutQueryListener> _onPreCheckoutQueryListeners;
291 std::vector<PollListener> _onPollListeners;
292 std::vector<PollAnswerListener> _onPollAnswerListeners;
293 std::vector<ChatMemberUpdatedListener> _onMyChatMemberListeners;
294 std::vector<ChatMemberUpdatedListener> _onChatMemberListeners;
295 std::vector<ChatJoinRequestListener> _onChatJoinRequestListeners;