]>
jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/blob - lib/NameBan.php
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
27 public function add(string $name, string $reason, string $duration = NULL, $set_by = NULL): stdClass
|array|bool
32 'duration_string' => $duration ?? '0',
36 $query['set_by'] = $set_by;
38 $response = $this->connection
->query('name_ban.add', $query);
40 if (is_bool($response))
43 if (property_exists($response, 'tkl'))
44 return $response->tkl
;
52 * @return stdClass|array|bool
54 public function delete(string $name): stdClass
|array|bool
56 $response = $this->connection
->query('name_ban.del', [
60 if (is_bool($response))
63 if (property_exists($response, 'tkl'))
64 return $response->tkl
;
69 * Return a list of all bans.
71 * @return stdClass|array|bool
74 public function getAll(): stdClass
|array|bool
76 $response = $this->connection
->query('name_ban.list');
78 if (!is_bool($response)) {
79 return $response->list;
82 throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');
89 * @return stdClass|array|bool
91 public function get(string $name): stdClass
|array|bool
93 $response = $this->connection
->query('name_ban.get', [
97 if (!is_bool($response)) {
98 return $response->tkl
;
101 return false; // not found