]> jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/commitdiff
Add $conn->rpc->info() and $conn->rpc->set_issuer("NameOfLoggedInUser")
authorBram Matthys <redacted>
Fri, 31 Mar 2023 11:56:40 +0000 (13:56 +0200)
committerBram Matthys <redacted>
Fri, 31 Mar 2023 11:56:40 +0000 (13:56 +0200)
The latter requires UnrealIRCd 6.0.8+

lib/Connection.php
lib/Rpc.php [new file with mode: 0644]

index 37272b615d1db8ef178e72ddcd151b8d54653847..1f37c7e3be0fbb95dcbd0480f0db925492244903 100644 (file)
@@ -81,6 +81,11 @@ class Connection
         throw new Exception('Invalid JSON-RPC response from UnrealIRCd: not an error and not a result.');
     }
 
+    public function rpc(): Rpc
+    {
+        return new Rpc($this);
+    }
+
     public function user(): User
     {
         return new User($this);
diff --git a/lib/Rpc.php b/lib/Rpc.php
new file mode 100644 (file)
index 0000000..721ba45
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+
+namespace UnrealIRCd;
+
+use Exception;
+use stdClass;
+
+class Rpc
+{
+
+    public Connection $connection;
+
+    public function __construct(Connection $conn)
+    {
+        $this->connection = $conn;
+    }
+
+    /**
+     * Get information on all RPC modules loaded.
+     *
+     * @return stdClass|array|bool
+     */
+    public function info(string $nick, string $reason): stdClass|array|bool
+    {
+        return $this->connection->query('rpc.info');
+    }
+
+    /**
+     * Set the name of the issuer that will make all the following RPC request
+     * (eg. name of logged in user on a webpanel). Requires UnreaIRCd 6.0.8+.
+     * @return stdClass|array|bool
+     */
+    public function set_issuer(string $name): stdClass|array|bool
+    {
+        return $this->connection->query('rpc.set_issuer', [
+            'name' => $name,
+        ]);
+    }
+}