]>
Commit | Line | Data |
---|---|---|
8d5a112f D |
1 | <?php |
2 | ||
3 | namespace UnrealIRCd; | |
4 | ||
5 | use Exception; | |
80bc3098 | 6 | use stdClass; |
8d5a112f | 7 | |
78796043 | 8 | class Channel |
8d5a112f D |
9 | { |
10 | ||
11 | public Connection $connection; | |
12 | ||
7c7017a2 | 13 | public function __construct(Connection $conn) |
8d5a112f | 14 | { |
7c7017a2 | 15 | $this->connection = $conn; |
8d5a112f D |
16 | } |
17 | ||
18 | /** | |
19 | * Return a list of channels users. | |
20 | * | |
93f8a3ee | 21 | * @return stdClass|array|bool |
8d5a112f D |
22 | * @throws Exception |
23 | */ | |
93f8a3ee | 24 | public function getAll(): stdClass|array|bool |
8d5a112f | 25 | { |
267b314e | 26 | $response = $this->connection->query('channel.list'); |
8d5a112f | 27 | |
8d5a112f | 28 | if(!is_bool($response)) { |
93f8a3ee | 29 | return $response->list; |
8d5a112f D |
30 | } |
31 | ||
32 | throw new Exception('Invalid JSON Response from UnrealIRCd RPC.'); | |
33 | } | |
34 | ||
35 | /** | |
7c7017a2 | 36 | * Get a channel object |
8d5a112f | 37 | * |
93f8a3ee | 38 | * @return stdClass|array|bool |
8d5a112f D |
39 | * @throws Exception |
40 | */ | |
93f8a3ee | 41 | public function get(string $channel): stdClass|array|bool |
8d5a112f | 42 | { |
f979c1e0 | 43 | $response = $this->connection->query('channel.get', ['channel' => $channel]); |
8d5a112f | 44 | |
8d5a112f D |
45 | if (!is_bool($response)) { |
46 | return $response; | |
47 | } | |
48 | ||
49 | throw new Exception('Invalid JSON Response from UnrealIRCd RPC.'); | |
50 | } | |
51 | } |