Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

Commit

Permalink
Now getCommand() method in Message object return null if text p…
Browse files Browse the repository at this point in the history
…roperty isn't a command.
  • Loading branch information
Lukasss93 committed Sep 17, 2017
1 parent 5b421de commit 63b03c4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog
All notable changes to this project will be documented in this file.

## [1.6.1]
### Changed
- Now `getCommand()` method in Message object return `null` if `text` property isn't a command.

## [1.6.0]
### Changed
- Updated to Telegram Bot API 3.3
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Framework for Telegram Bot API",
"license": "MIT",
"type": "project",
"version": "1.6.0",
"version": "1.6.1",
"authors": [
{
"name": "Luca Patera",
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,6 @@ Changelog
All notable changes to this project will be documented [here](https://github.com/Lukasss93/telegrambot-php/blob/master/CHANGELOG.md).

### Recent changes
## [1.6.0]
## [1.6.1]
### Changed
- Updated to Telegram Bot API 3.3
- Now `getCommand()` method in Message object return `null` if `text` property isn't a command.
14 changes: 10 additions & 4 deletions src/Types/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,16 @@ public function getCommand()
{
if($this->text!==null)
{
$commandArray=explode(' ', $this->text);
$command=array_shift($commandArray);
$command=preg_replace('/@.*/','',$command);
return $command;
$result=preg_match('/^(\/\w+)@\w+$/',$this->text,$matches);

if(!$result)
{
return null;
}
else
{
return $matches[1];
}
}
return null;
}
Expand Down

0 comments on commit 63b03c4

Please sign in to comment.