diff --git a/src/LINEBot/Event/MessageEvent.php b/src/LINEBot/Event/MessageEvent.php index 940bbd23..e5226a68 100644 --- a/src/LINEBot/Event/MessageEvent.php +++ b/src/LINEBot/Event/MessageEvent.php @@ -51,4 +51,14 @@ public function getMessageId() { return $this->message['id']; } + + /** + * Returns the type of the message. + * + * @return string + */ + public function getMessageType() + { + return $this->message['type']; + } } diff --git a/tests/LINEBot/EventRequestParserTest.php b/tests/LINEBot/EventRequestParserTest.php index c14f1282..be81ff55 100644 --- a/tests/LINEBot/EventRequestParserTest.php +++ b/tests/LINEBot/EventRequestParserTest.php @@ -206,6 +206,7 @@ public function testParseEventRequest() /** @var TextMessage $event */ $this->assertEquals('replytoken', $event->getReplyToken()); $this->assertEquals('contentid', $event->getMessageId()); + $this->assertEquals('text', $event->getMessageType()); $this->assertEquals('message', $event->getText()); } @@ -218,6 +219,7 @@ public function testParseEventRequest() $this->assertInstanceOf('LINE\LINEBot\Event\MessageEvent\ImageMessage', $event); /** @var ImageMessage $event */ $this->assertEquals('replytoken', $event->getReplyToken()); + $this->assertEquals('image', $event->getMessageType()); } { @@ -229,6 +231,7 @@ public function testParseEventRequest() $this->assertInstanceOf('LINE\LINEBot\Event\MessageEvent\VideoMessage', $event); /** @var VideoMessage $event */ $this->assertEquals('replytoken', $event->getReplyToken()); + $this->assertEquals('video', $event->getMessageType()); } { @@ -237,6 +240,7 @@ public function testParseEventRequest() $this->assertInstanceOf('LINE\LINEBot\Event\MessageEvent\AudioMessage', $event); /** @var AudioMessage $event */ $this->assertEquals('replytoken', $event->getReplyToken()); + $this->assertEquals('audio', $event->getMessageType()); } { @@ -245,6 +249,7 @@ public function testParseEventRequest() $this->assertInstanceOf('LINE\LINEBot\Event\MessageEvent\LocationMessage', $event); /** @var LocationMessage $event */ $this->assertEquals('replytoken', $event->getReplyToken()); + $this->assertEquals('location', $event->getMessageType()); $this->assertEquals('label', $event->getTitle()); $this->assertEquals('tokyo', $event->getAddress()); $this->assertEquals('-34.12', $event->getLatitude()); @@ -257,6 +262,7 @@ public function testParseEventRequest() $this->assertInstanceOf('LINE\LINEBot\Event\MessageEvent\StickerMessage', $event); /** @var StickerMessage $event */ $this->assertEquals('replytoken', $event->getReplyToken()); + $this->assertEquals('sticker', $event->getMessageType()); $this->assertEquals(1, $event->getPackageId()); $this->assertEquals(2, $event->getStickerId()); }