36 lines
970 B
PHP
36 lines
970 B
PHP
<?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';
|
|
}
|
|
}
|