]>
jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/blob - lib/Ban.php
8 class Ban
implements Contracts\Ban
11 public Connection
$connection;
13 public function __construct(string $uri, string $api_login, array $options)
15 $this->connection
= new Connection($uri, $api_login, $options);
22 * @param array $params
26 public function add(string $user, array $params): stdClass
28 return $this->connection
->query('server_ban.add', [
30 'type' => $params['type'],
31 'reason' => $params['reason'],
32 'duration_string' => $params['length'] ?? '1d',
40 * @param array $params
44 public function delete(string $user, array $params): stdClass
46 return $this->connection
->query('server_ban.del', [
48 'type' => $params['type'],
53 * Return a list of all bans.
58 public function get(): stdClass
60 $response = $this->connection
->query('server_ban.list');
62 if (!is_bool($response)) {
66 throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');
70 * Show a specific ban.
72 * @param array $params
76 public function show(array $params): stdClass
78 $response = $this->connection
->query('server_ban.get', [
79 'name' => $params['name'],
80 'type' => $params['type']
83 if (!is_bool($response)) {
87 throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');