]> jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/blobdiff - lib/Channel.php
Return from $rpc->eventloop() after 2 seconds instead of 10.
[irc/unrealircd/unrealircd-rpc-php.git] / lib / Channel.php
index b0814319317c0a94924a8b1ba399ca32015f6a88..7a6a68e81b0d83d77b5ddeb8dc59d0c8d6c1397d 100644 (file)
@@ -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,24 +38,24 @@ 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;
         }
-
-        throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');
+        return false; /* eg user not found */
     }
 
     /**
      * Set and unset modes on a channel.
      *
      * @return stdClass|array|bool
-     * @throws Exception
      */
     public function set_mode(string $channel, string $modes, string $parameters): stdClass|array|bool
     {
@@ -68,7 +70,6 @@ class Channel
      * Set the channel topic.
      *
      * @return stdClass|array|bool
-     * @throws Exception
      */
     public function set_topic(string $channel, string $topic,
                               string $set_by=null, string $set_at=null): stdClass|array|bool
@@ -85,11 +86,10 @@ class Channel
      * Kick a user from the channel.
      *
      * @return stdClass|array|bool
-     * @throws Exception
      */
     public function kick(string $channel, string $nick, string $reason): stdClass|array|bool
     {
-        return $this->connection->query('user.kick', [
+        return $this->connection->query('channel.kick', [
             'nick' => $nick,
             'channel' => $channel,
             'reason' => $reason,