Skip to content

Fix deprecated Newchatmembers system command #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
### Deprecated
### Removed
### Fixed
- Deprecated system commands are now executed via `GenericmessageCommand`.
### Security

## [0.3.0] - 2019-07-30
Expand Down
53 changes: 53 additions & 0 deletions commands/GenericmessageCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php declare(strict_types=1);
/**
* This file is part of the PHP Telegram Support Bot.
*
* (c) PHP Telegram Bot Team (https://github.com/php-telegram-bot)
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Longman\TelegramBot\Commands\SystemCommands;

use Longman\TelegramBot\Commands\SystemCommand;
use Longman\TelegramBot\Entities\ServerResponse;
use Longman\TelegramBot\Exception\TelegramException;
use Longman\TelegramBot\Request;

/**
* Generic message command
*/
class GenericmessageCommand extends SystemCommand
{
/**
* @var string
*/
protected $name = 'genericmessage';

/**
* @var string
*/
protected $description = 'Handle generic message';

/**
* @var string
*/
protected $version = '0.1.0';

/**
* Execute command
*
* @return ServerResponse
* @throws TelegramException
*/
public function execute(): ServerResponse
{
// Handle new chat members.
if ($this->getMessage()->getNewChatMembers()) {
return $this->getTelegram()->executeCommand('newchatmembers');
}

return Request::emptyResponse();
}
}