]>
jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/blob - lib/Channel.php
8 class Channel
implements Contracts\User
11 public Connection
$connection;
13 public function __construct(string $uri, string $api_login, array $options)
15 $this->connection
= new Connection($uri, $api_login, $options);
19 * Return a list of channels users.
24 public function get(): stdClass
26 $id = random_int(100, 1000);
28 $response = $this->connection
->query('channel.list');
30 if($id !== $response->id
) {
31 throw new Exception('Invalid ID. This is not the expected reply.');
34 if(!is_bool($response)) {
38 throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');
42 * Return a channel object
44 * @param array $params
48 public function show(array $params): stdClass
50 $id = random_int(100, 1000);
52 $response = $this->connection
->query('channel.get', ['channel' => $params['channel']]);
54 if($id !== $response->id
) {
55 throw new Exception('Invalid ID. This is not the expected reply.');
58 if (!is_bool($response)) {
62 throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');