X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-rpc-php.git/blobdiff_plain/93f8a3ee8d1ab65e34e8f551d0018db8961955f8..94e1459d52b429e3e5d43d36fabada6d0801bdc5:/lib/Channel.php?ds=sidebyside diff --git a/lib/Channel.php b/lib/Channel.php index 96ba35d..7a6a68e 100644 --- a/lib/Channel.php +++ b/lib/Channel.php @@ -21,9 +21,11 @@ class Channel * @return stdClass|array|bool * @throws Exception */ - public function getAll(): stdClass|array|bool + public function getAll(int $object_detail_level=1): stdClass|array|bool { - $response = $this->connection->query('channel.list'); + $response = $this->connection->query('channel.list', [ + 'object_detail_level' => $object_detail_level, + ]); if(!is_bool($response)) { return $response->list; @@ -36,16 +38,61 @@ class Channel * Get a channel object * * @return stdClass|array|bool - * @throws Exception */ - public function get(string $channel): stdClass|array|bool + public function get(string $channel, int $object_detail_level=3): stdClass|array|bool { - $response = $this->connection->query('channel.get', ['channel' => $channel]); + $response = $this->connection->query('channel.get', [ + 'channel' => $channel, + 'object_detail_level' => $object_detail_level, + ]); if (!is_bool($response)) { - return $response; + return $response->channel; } + return false; /* eg user not found */ + } - throw new Exception('Invalid JSON Response from UnrealIRCd RPC.'); + /** + * Set and unset modes on a channel. + * + * @return stdClass|array|bool + */ + public function set_mode(string $channel, string $modes, string $parameters): stdClass|array|bool + { + return $this->connection->query('channel.set_mode', [ + 'channel' => $channel, + 'modes' => $modes, + 'parameters' => $parameters, + ]); + } + + /** + * Set the channel topic. + * + * @return stdClass|array|bool + */ + public function set_topic(string $channel, string $topic, + string $set_by=null, string $set_at=null): stdClass|array|bool + { + return $this->connection->query('channel.set_topic', [ + 'channel' => $channel, + 'topic' => $topic, + 'set_by' => $set_by, + 'set_at' => $set_at, + ]); + } + + /** + * Kick a user from the channel. + * + * @return stdClass|array|bool + */ + public function kick(string $channel, string $nick, string $reason): stdClass|array|bool + { + return $this->connection->query('channel.kick', [ + 'nick' => $nick, + 'channel' => $channel, + 'reason' => $reason, + ]); } }