]>
jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/blob - lib/Server.php
11 public Connection
$connection;
13 public function __construct(Connection
$conn)
15 $this->connection
= $conn;
19 * Return a list of all servers.
23 public function getAll(): stdClass
|array|bool
25 $response = $this->connection
->query('server.list');
27 if(!is_bool($response)) {
28 return $response->list;
31 throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');
35 * Return a server object
37 * @return stdClass|array|bool
40 public function get(string $server = null): stdClass
|array|bool
42 $response = $this->connection
->query('server.get', ['server' => $server]);
44 if (!is_bool($response)) {
45 return $response->server
;
48 return false; // not found
54 * @return stdClass|array|bool
57 public function rehash(string $serv): stdClass
|array|bool
59 return $this->connection
->query('server.rehash', ["server" => $serv]);
65 * @param string $name The name of the server, e.g; irc.example.com
66 * @return stdClass|array|bool
69 public function connect(string $name): stdClass
|array|bool
71 return $this->connection
->query('server.connect', [
77 * Disconnects a server
79 * @param string $name The name of the server, e.g; irc.example.com
80 * @return stdClass|array|bool
83 public function disconnect(string $name, string $reason = "No reason"): stdClass
|array|bool
85 return $this->connection
->query('server.disconnect', [
93 * List modules on the server
95 * @return stdClass|array|bool
98 public function module_list($name = NULL): stdClass
|array|bool
102 $arr['server'] = $name;
104 return $this->connection
->query('server.module_list', $arr);