@@ -44,7 +44,7 @@ friend EventHandler;
44
44
typedef std::function<void (const PollAnswer::Ptr )> PollAnswerListener;
45
45
typedef std::function<void (const ChatMemberUpdated::Ptr )> ChatMemberUpdatedListener;
46
46
typedef std::function<void (const ChatJoinRequest::Ptr )> ChatJoinRequestListener;
47
- typedef std::function<void (const SuccessfulPayment::Ptr )> SuccessfulPaymentListener;
47
+ typedef std::function<void (const Message:: Ptr , const SuccessfulPayment::Ptr )> SuccessfulPaymentListener;
48
48
49
49
/* *
50
50
* @brief Registers listener which receives new incoming message of any kind - text, photo, sticker, etc.
@@ -214,6 +214,9 @@ friend EventHandler;
214
214
_onSuccessfulPaymentListeners.push_back (listener);
215
215
}
216
216
217
+
218
+
219
+
217
220
private:
218
221
template <typename ListenerType, typename ObjectType>
219
222
inline void broadcast (const std::vector<ListenerType>& listeners, const ObjectType object) const {
@@ -290,10 +293,16 @@ friend EventHandler;
290
293
broadcast<ChatJoinRequestListener, ChatJoinRequest::Ptr >(_onChatJoinRequestListeners, result);
291
294
}
292
295
293
- inline void broadcastSuccessfulPayment (const SuccessfulPayment::Ptr & payment) const {
294
- broadcast<SuccessfulPaymentListener, SuccessfulPayment::Ptr >(_onSuccessfulPaymentListeners, payment);
296
+ inline void broadcastSuccessfulPayment (const Message::Ptr & message) const {
297
+ if (!message || !message->successfulPayment ) {
298
+ return ;
299
+ }
300
+ for (const auto & listener : _onSuccessfulPaymentListeners) {
301
+ listener (message, message->successfulPayment );
302
+ }
295
303
}
296
304
305
+
297
306
std::vector<MessageListener> _onAnyMessageListeners;
298
307
std::unordered_map<std::string, MessageListener> _onCommandListeners;
299
308
std::vector<MessageListener> _onUnknownCommandListeners;
0 commit comments