summaryrefslogtreecommitdiff
path: root/src/Bot/Application.php
blob: 2b8dae04853f0c7235e4af29e72370ae8602a7cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php

namespace FBeans\Beansbot\Bot;

use FBeans\BlaIRC\Command;
use FBeans\BlaIRC\Application As BlaApplication;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Process\Process;

class Application extends BlaApplication
{
    public function commands(): Array
    {
        $command = new Command;
        $command->setName('bot:list');

        $command->setExecuteCallback(
            function (InputInterface $input, OutputInterface $output) {
                $output->writeLn(
                    $this->getCommands()
                );

                return Command::SUCCESS;
            }
        );

        $command2 = new Command;
        $command2->setName('bot:reload');

        $command2->setExecuteCallback(
            function (InputInterface $input, OutputInterface $output) {

                $output->writeLn(
                    'Config reloaded'
                );

                return Command::SUCCESS;
            }
        );

        return [$command, $command2];
    }

    protected function getCommands()
    {
        return implode(', ', array_keys(parse_ini_file(__DIR__ . '/../../Blatech.ini', true)));
    }
}