]>
jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/blob - lib/NameBan.php
0447d89ecd37c1dd038bea721597cbeabf889199
11 public Connection
$connection;
13 public function __construct(Connection
$conn)
15 $this->connection
= $conn;
19 * Add a name ban (QLine).
22 * @param string $reason
23 * @param string $duration Optional
24 * @param string $set_by Optional
25 * @return stdClass|array|bool
28 public function add(string $name, string $reason, string $duration = NULL, $set_by = NULL): stdClass
|array|bool
33 'duration_string' => $duration ?? '0',
37 $query['set_by'] = $set_by;
39 $response = $this->connection
->query('name_ban.add', $query);
41 if (is_bool($response))
44 if (property_exists($response, 'tkl'))
45 return $response->tkl
;
53 * @return stdClass|array|bool
56 public function delete(string $name): stdClass
|array|bool
58 $response = $this->connection
->query('name_ban.del', [
62 if (is_bool($response))
65 if (property_exists($response, 'tkl'))
66 return $response->tkl
;
71 * Return a list of all bans.
73 * @return stdClass|array|bool
76 public function getAll(): stdClass
|array|bool
78 $response = $this->connection
->query('name_ban.list');
80 if (!is_bool($response)) {
81 return $response->list;
84 throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');
91 * @return stdClass|array|bool
94 public function get(string $name): stdClass
|array|bool
96 $response = $this->connection
->query('name_ban.get', [
100 if (!is_bool($response)) {
101 return $response->tkl
;
104 throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');