From 609fb407433f530670e3bde22528eb85ebbf12a7 Mon Sep 17 00:00:00 2001 From: Pavel Kharchenko Date: Thu, 27 Jul 2017 16:00:04 +0300 Subject: [PATCH 1/2] callbackQueryEvent --- src/Client.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/Client.php b/src/Client.php index dfbaf235..fd08d160 100644 --- a/src/Client.php +++ b/src/Client.php @@ -59,6 +59,11 @@ public function editedMessage(Closure $action) return $this->on(self::getEditedMessageEvent($action), self::getEditedMessageChecker()); } + public function callbackQuery(Closure $action) + { + return $this->on(self::getCallbackQueryEvent($action), self::getCallbackQueryChecker()); + } + public function channelPost(Closure $action) { return $this->on(self::getChannelPostEvent($action), self::getChannelPostChecker()); @@ -197,6 +202,19 @@ protected static function getChannelPostEvent(Closure $action) }; } + protected static function getCallbackQueryEvent(Closure $action) + { + return function (Update $update) use ($action) { + if (!$update->getCallbackQuery()) { + return true; + } + + $reflectionAction = new ReflectionFunction($action); + $reflectionAction->invokeArgs([$update->getCallbackQuery()]); + return false; + }; + } + protected static function getEditedChannelPostEvent(Closure $action) { return function (Update $update) use ($action) { @@ -307,6 +325,18 @@ protected static function getChannelPostChecker() }; } + /** + * Returns check function to handling the callbackQuery. + * + * @return Closure + */ + protected static function getCallbackQueryChecker() + { + return function (Update $update) { + return !is_null($update->getCallbackQuery()); + }; + } + /** * Returns check function to handling the edited channel post. * From 1aedaf66125c7d274e484e0dcea6f2739c7b7f2e Mon Sep 17 00:00:00 2001 From: Pavel Kharchenko Date: Thu, 27 Jul 2017 16:37:24 +0300 Subject: [PATCH 2/2] Change tabs to spaces --- src/Client.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Client.php b/src/Client.php index fd08d160..57fe0b14 100644 --- a/src/Client.php +++ b/src/Client.php @@ -59,10 +59,10 @@ public function editedMessage(Closure $action) return $this->on(self::getEditedMessageEvent($action), self::getEditedMessageChecker()); } - public function callbackQuery(Closure $action) - { - return $this->on(self::getCallbackQueryEvent($action), self::getCallbackQueryChecker()); - } + public function callbackQuery(Closure $action) + { + return $this->on(self::getCallbackQueryEvent($action), self::getCallbackQueryChecker()); + } public function channelPost(Closure $action) {