Skip to content

Commit

Permalink
Identify the type of message received
Browse files Browse the repository at this point in the history
  • Loading branch information
fphpr committed Feb 2, 2020
1 parent 8efb853 commit 5d10fb4
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions BotFire.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,33 @@ private static function initChatUserInfo($ob)

}

public static function getMessageType(){
if (isset(self::$json->message->text)) {
return ['type'=>'text','data'=>self::$json->message->text];
}
elseif (isset(self::$json->message->photo)) {
return ['type'=>'photo','data'=>self::$json->message->photo];
}
elseif (isset(self::$json->message->video)) {
return ['type'=>'video','data'=>self::$json->message->video];
}
elseif (isset(self::$json->message->video_note)) {
return ['type'=>'video_note','data'=>self::$json->message->video_note];
}
elseif (isset(self::$json->message->voice)) {
return ['type'=>'voice','data'=>self::$json->message->voice];
}
elseif (isset(self::$json->message->animation)) {
return ['type'=>'animation','data'=>self::$json->message->animation];
}
elseif (isset(self::$json->message->document)) {
return ['type'=>'document','data'=>self::$json->message->document];
}
else {
return ['type'=>false,'data'=>self::$json];
}
}

/**
*
*/
Expand Down

0 comments on commit 5d10fb4

Please sign in to comment.