Total Complexity | 9 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
9 | class KickMessage extends IrcMessage |
||
10 | { |
||
11 | /** @var IrcChannel */ |
||
12 | public $channel; |
||
13 | |||
14 | /** @var string */ |
||
15 | public $message; |
||
16 | |||
17 | /** @var string */ |
||
18 | private $target; |
||
19 | |||
20 | /** @var string */ |
||
21 | public $user; |
||
22 | |||
23 | public function __construct(string $message) |
||
24 | { |
||
25 | parent::__construct($message); |
||
26 | |||
27 | [$this->target, $this->user] = explode(' ', $this->commandsuffix); |
||
28 | $this->message = $this->payload; |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * When the bot is kicked form a channel, it might need to auto rejoin. |
||
33 | */ |
||
34 | public function handle(IrcClient $client, bool $force = false): void |
||
35 | { |
||
36 | if ($this->handled && !$force) { |
||
37 | return; |
||
38 | } |
||
39 | |||
40 | if ($client->getNickname() === $this->user && $client->shouldAutoRejoin()) { |
||
41 | $client->join($this->target); |
||
42 | } |
||
43 | } |
||
44 | |||
45 | public function getEvents(): array |
||
46 | { |
||
47 | return [ |
||
48 | new Event('kick', [$this->channel, $this->user, $this->message]), |
||
49 | ]; |
||
50 | } |
||
51 | |||
52 | public function injectChannel(array $channels): void |
||
56 | } |
||
57 | } |
||
58 | } |
||
59 |