]> jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/commitdiff
Add all the new RPC calls in 6.0.6-git at the moment:
authorBram Matthys <redacted>
Sat, 7 Jan 2023 18:42:05 +0000 (19:42 +0100)
committerBram Matthys <redacted>
Sat, 7 Jan 2023 18:42:05 +0000 (19:42 +0100)
== channel ==
public function set_mode(string $channel, string $modes, string $parameters): stdClass|array|bool
public function set_topic(string $channel, string $topic,
                          string $set_by=null, string $set_at=null): stdClass|array|bool
public function kick(string $channel, string $nick, string $reason): stdClass|array|bool
See also https://www.unrealircd.org/docs/JSON-RPC:Channel

== user ==
public function set_nick(string $nick, string $newnick): stdClass|array|bool
public function set_username(string $nick, string $username): stdClass|array|bool
public function set_realname(string $nick, string $realname): stdClass|array|bool
public function set_vhost(string $nick, string $vhost): stdClass|array|bool
public function set_mode(string $nick, string $mode, bool $hidden = false): stdClass|array|bool
public function set_snomask(string $nick, string $snomask, bool $hidden = false): stdClass|array|bool
public function set_oper(string $nick, string $oper_account, string $oper_class,
                         string $class = null, string $modes = null,
                         string $snomask = null, string $vhost = null): stdClass|array|bool
public function join(string $nick, string $channel,
                     string $key = null, bool $force = false): stdClass|array|bool
public function part(string $nick, string $channel, bool $force = false): stdClass|array|bool
public function quit(string $nick, string $reason): stdClass|array|bool
public function kill(string $nick, string $reason): stdClass|array|bool
See also https://www.unrealircd.org/docs/JSON-RPC:User

lib/Channel.php
lib/User.php

index 96ba35d8e9d46622c37aad889d2f10c8c88bde5f..b0814319317c0a94924a8b1ba399ca32015f6a88 100644 (file)
@@ -48,4 +48,51 @@ class Channel
 
         throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');
     }
+
+    /**
+     * 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
+    {
+        return $this->connection->query('channel.set_mode', [
+            'channel' => $channel,
+            'modes' => $modes,
+            'parameters' => $parameters,
+        ]);
+    }
+
+    /**
+     * 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
+    {
+        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
+     * @throws Exception
+     */
+    public function kick(string $channel, string $nick, string $reason): stdClass|array|bool
+    {
+        return $this->connection->query('user.kick', [
+            'nick' => $nick,
+            'channel' => $channel,
+            'reason' => $reason,
+        ]);
+    }
 }
index 45158c789c319833fdd95a62e7b33e482f14bc7d..9cf6f7fc86816635d769fb58a7189f648155c58f 100644 (file)
@@ -47,4 +47,171 @@ class User
 
         throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');
     }
+
+    /**
+     * Set the nickname of a user (changes the nick)
+     *
+     * @return stdClass|array|bool
+     * @throws Exception
+     */
+    public function set_nick(string $nick, string $newnick): stdClass|array|bool
+    {
+        return $this->connection->query('user.set_nick', [
+            'nick' => $nick,
+            'newnick' => $newnick,
+        ]);
+    }
+
+    /**
+     * Set the username/ident of a user
+     *
+     * @return stdClass|array|bool
+     * @throws Exception
+     */
+    public function set_username(string $nick, string $username): stdClass|array|bool
+    {
+        return $this->connection->query('user.set_username', [
+            'nick' => $nick,
+            'username' => $username,
+        ]);
+    }
+
+    /**
+     * Set the realname/gecos of a user
+     *
+     * @return stdClass|array|bool
+     * @throws Exception
+     */
+    public function set_realname(string $nick, string $realname): stdClass|array|bool
+    {
+        return $this->connection->query('user.set_realname', [
+            'nick' => $nick,
+            'realname' => $realname,
+        ]);
+    }
+
+    /**
+     * Set a virtual host (vhost) on the user
+     *
+     * @return stdClass|array|bool
+     * @throws Exception
+     */
+    public function set_vhost(string $nick, string $vhost): stdClass|array|bool
+    {
+        return $this->connection->query('user.set_vhost', [
+            'nick' => $nick,
+            'vhost' => $vhost,
+        ]);
+    }
+
+    /**
+     * Change the user modes of a user.
+     *
+     * @return stdClass|array|bool
+     * @throws Exception
+     */
+    public function set_mode(string $nick, string $mode, bool $hidden = false): stdClass|array|bool
+    {
+        return $this->connection->query('user.set_mode', [
+            'nick' => $nick,
+            'modes' => $mode,
+            'hidden' => $hidden,
+        ]);
+    }
+
+    /**
+     * Change the snomask of a user (oper).
+     *
+     * @return stdClass|array|bool
+     * @throws Exception
+     */
+    public function set_snomask(string $nick, string $snomask, bool $hidden = false): stdClass|array|bool
+    {
+        return $this->connection->query('user.set_snomask', [
+            'nick' => $nick,
+            'snomask' => $snomask,
+            'hidden' => $hidden,
+        ]);
+    }
+
+    /**
+     * Make user an IRC Operator (oper).
+     *
+     * @return stdClass|array|bool
+     * @throws Exception
+     */
+    public function set_oper(string $nick, string $oper_account, string $oper_class,
+                             string $class = null, string $modes = null,
+                             string $snomask = null, string $vhost = null): stdClass|array|bool
+    {
+        return $this->connection->query('user.set_oper', [
+            'nick' => $nick,
+            'oper_account' => $oper_account,
+            'oper_class' => $oper_class,
+            'class' => $class,
+            'modes' => $modes,
+            'snomask' => $snomask,
+            'vhost' => $vhost,
+        ]);
+    }
+
+    /**
+     * Join a user to a channel.
+     *
+     * @return stdClass|array|bool
+     * @throws Exception
+     */
+    public function join(string $nick, string $channel,
+                         string $key = null, bool $force = false): stdClass|array|bool
+    {
+        return $this->connection->query('user.join', [
+            'nick' => $nick,
+            'channel' => $channel,
+            'key' => $key,
+            'force' => $force,
+        ]);
+    }
+
+    /**
+     * Part a user from a channel.
+     *
+     * @return stdClass|array|bool
+     * @throws Exception
+     */
+    public function part(string $nick, string $channel, bool $force = false): stdClass|array|bool
+    {
+        return $this->connection->query('user.part', [
+            'nick' => $nick,
+            'channel' => $channel,
+            'force' => $force,
+        ]);
+    }
+
+    /**
+     * Quit a user from IRC. Pretend it is a normal QUIT.
+     *
+     * @return stdClass|array|bool
+     * @throws Exception
+     */
+    public function quit(string $nick, string $reason): stdClass|array|bool
+    {
+        return $this->connection->query('user.quit', [
+            'nick' => $nick,
+            'reason' => $reason,
+        ]);
+    }
+
+    /**
+     * Kill a user from IRC. Show that the user is forcefully removed.
+     *
+     * @return stdClass|array|bool
+     * @throws Exception
+     */
+    public function kill(string $nick, string $reason): stdClass|array|bool
+    {
+        return $this->connection->query('user.kill', [
+            'nick' => $nick,
+            'reason' => $reason,
+        ]);
+    }
 }