🎉 Hello world
This commit is contained in:
35
bot/Commands/TasksProjects.php
Normal file
35
bot/Commands/TasksProjects.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Shikiryu\Bot\Commands;
|
||||
|
||||
use JsonRPC\Client;
|
||||
use Shikiryu\Bot\Bot;
|
||||
|
||||
class TasksProjects implements Icommands
|
||||
{
|
||||
public static function getMessage(Bot $bot, array $data)
|
||||
{
|
||||
$config = $bot->getConfig();
|
||||
if (!array_key_exists('kanboard', $config)) {
|
||||
$bot->replyPolitely('Je n\'ai pas la configuration nécessaire');
|
||||
}
|
||||
$config = $config['kanboard'];
|
||||
$client = new Client($config['url']);
|
||||
$client->authentication('jsonrpc', $config['token']);
|
||||
|
||||
$projects = $client->getAllProjects();
|
||||
|
||||
$projects = array_filter($projects, function($project) { return $project['is_active']; });
|
||||
$projects = array_map(function($project) { return sprintf('%u: %s', $project['id'], $project['name']); }, $projects);
|
||||
|
||||
$bot->replyPolitely(sprintf('Voici vos différents projets : %s', implode(', ', $projects)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getDescription()
|
||||
{
|
||||
return 'Liste les projets de Kanboard';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user