Skip to content

Commit 730ec25

Browse files
authored
Merge pull request #33 from noplanman/fix_deprecated_system_commands
Fix deprecated Newchatmembers system command
2 parents 98065d5 + 6eff04b commit 730ec25

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
99
### Deprecated
1010
### Removed
1111
### Fixed
12+
- Deprecated system commands are now executed via `GenericmessageCommand`.
1213
### Security
1314

1415
## [0.3.0] - 2019-07-30

commands/GenericmessageCommand.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php declare(strict_types=1);
2+
/**
3+
* This file is part of the PHP Telegram Support Bot.
4+
*
5+
* (c) PHP Telegram Bot Team (https://github.com/php-telegram-bot)
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
namespace Longman\TelegramBot\Commands\SystemCommands;
12+
13+
use Longman\TelegramBot\Commands\SystemCommand;
14+
use Longman\TelegramBot\Entities\ServerResponse;
15+
use Longman\TelegramBot\Exception\TelegramException;
16+
use Longman\TelegramBot\Request;
17+
18+
/**
19+
* Generic message command
20+
*/
21+
class GenericmessageCommand extends SystemCommand
22+
{
23+
/**
24+
* @var string
25+
*/
26+
protected $name = 'genericmessage';
27+
28+
/**
29+
* @var string
30+
*/
31+
protected $description = 'Handle generic message';
32+
33+
/**
34+
* @var string
35+
*/
36+
protected $version = '0.1.0';
37+
38+
/**
39+
* Execute command
40+
*
41+
* @return ServerResponse
42+
* @throws TelegramException
43+
*/
44+
public function execute(): ServerResponse
45+
{
46+
// Handle new chat members.
47+
if ($this->getMessage()->getNewChatMembers()) {
48+
return $this->getTelegram()->executeCommand('newchatmembers');
49+
}
50+
51+
return Request::emptyResponse();
52+
}
53+
}

0 commit comments

Comments
 (0)