]>
jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/blob - lib/Channel.php
7 class Channel
implements Contracts\User
10 public Connection
$connection;
12 public function __construct(string $uri, string $api_login, array $options)
14 $this->connection
= new Connection($uri, $api_login, $options);
18 * Return a list of channels users.
22 public function get(): array
24 $id = random_int(100, 1000);
26 $response = $this->connection
->query($id, 'channel.list');
28 if($id !== $response->id
) {
29 throw new Exception('Invalid ID. This is not the expected reply.');
32 if(!is_bool($response)) {
36 throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');
40 * Return a channel object
42 * @param array $params
46 public function show(array $params): object|bool
48 $id = random_int(100, 1000);
50 $response = $this->connection
->query($id, 'channel.get', ['channel' => $params['channel']]);
52 if($id !== $response->id
) {
53 throw new Exception('Invalid ID. This is not the expected reply.');
56 if (!is_bool($response)) {
60 throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');