38 lines
955 B
PHP
38 lines
955 B
PHP
<?php
|
|
|
|
namespace Shikiryu\Bot\Commands;
|
|
|
|
use Shikiryu\Bot\Bot;
|
|
|
|
class Help implements Icommands
|
|
{
|
|
|
|
public static function getMessage(Bot $bot, array $data): void
|
|
{
|
|
$bot->replyPolitely('Voici la liste de mes commandes');
|
|
|
|
$message = '|Nom|Description|Pattern|'."\n";
|
|
$message .= '|---|---|---|'."\n";
|
|
foreach ($bot->listCommands() as $command) {
|
|
$message .= sprintf(
|
|
'|%s|%s|`%s`|%s',
|
|
end(explode('\\', $command)),
|
|
call_user_func([$command, 'getDescription']),
|
|
str_replace('|', '\|', call_user_func([$command, 'getPattern'])),
|
|
"\n"
|
|
);
|
|
}
|
|
|
|
$bot->reply($message);
|
|
}
|
|
|
|
public static function getDescription(): string
|
|
{
|
|
return 'Affiche les commandes à lancer';
|
|
}
|
|
|
|
public static function getPattern(): string
|
|
{
|
|
return '^(help|aide|liste des commandes)$';
|
|
}
|
|
} |