✨ Add Help command
This commit is contained in:
35
bot/Commands/Help.php
Normal file
35
bot/Commands/Help.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Shikiryu\Bot\Commands;
|
||||
|
||||
use Shikiryu\Bot\Bot;
|
||||
|
||||
class Help implements Icommands
|
||||
{
|
||||
|
||||
public static function getMessage(Bot $bot, array $data): void
|
||||
{
|
||||
$message = 'Voici la liste de mes commandes : '."\n";
|
||||
foreach ($bot->listCommands() as $command) {
|
||||
$message .= sprintf(
|
||||
'%s : %s (%s)%s',
|
||||
$command,
|
||||
call_user_func([$command, 'getDescription']),
|
||||
call_user_func([$command, 'getPattern']),
|
||||
"\n"
|
||||
);
|
||||
}
|
||||
|
||||
$bot->replyPolitely($message);
|
||||
}
|
||||
|
||||
public static function getDescription(): string
|
||||
{
|
||||
return 'Affiche les commandes à lancer';
|
||||
}
|
||||
|
||||
public static function getPattern(): string
|
||||
{
|
||||
return '^(help|aide|liste des commandes)$';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user