diff --git a/examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/JoinEventHandler.php b/examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/JoinEventHandler.php index 568b51fa..64817a1d 100644 --- a/examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/JoinEventHandler.php +++ b/examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/JoinEventHandler.php @@ -46,9 +46,18 @@ public function __construct($bot, $logger, JoinEvent $joinEvent) public function handle() { + if ($this->joinEvent->isGroupEvent()) { + $id = $this->joinEvent->getGroupId(); + } elseif ($this->joinEvent->isRoomEvent()) { + $id = $this->joinEvent->getRoomId(); + } else { + $this->logger->error("Unknown event type"); + return; + } + $this->bot->replyText( $this->joinEvent->getReplyToken(), - sprintf('Joined %s %s', $this->joinEvent->getType(), $this->joinEvent->getUserId()) + sprintf('Joined %s %s', $this->joinEvent->getType(), $id) ); } } diff --git a/examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/LeaveEventHandler.php b/examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/LeaveEventHandler.php index 90fcc96c..5c659c07 100644 --- a/examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/LeaveEventHandler.php +++ b/examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/LeaveEventHandler.php @@ -46,9 +46,15 @@ public function __construct($bot, $logger, LeaveEvent $leaveEvent) public function handle() { - $this->bot->replyText( - $this->leaveEvent->getReplyToken(), - sprintf('Leaved %s %s', $this->leaveEvent->getType(), $this->leaveEvent->getUserId()) - ); + if ($this->leaveEvent->isGroupEvent()) { + $id = $this->leaveEvent->getGroupId(); + } elseif ($this->leaveEvent->isRoomEvent()) { + $id = $this->leaveEvent->getRoomId(); + } else { + $this->logger->error("Unknown event type"); + return; + } + + $this->logger->info(sprintf('Leaved %s %s', $this->leaveEvent->getType(), $id)); } } diff --git a/src/LINEBot/Constant/Meta.php b/src/LINEBot/Constant/Meta.php index e59cb745..da674e2b 100644 --- a/src/LINEBot/Constant/Meta.php +++ b/src/LINEBot/Constant/Meta.php @@ -20,5 +20,5 @@ class Meta { - const VERSION = '1.1.0'; + const VERSION = '1.2.0'; }