From: Bram Matthys Date: Fri, 31 Mar 2023 11:56:40 +0000 (+0200) Subject: Add $conn->rpc->info() and $conn->rpc->set_issuer("NameOfLoggedInUser") X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-rpc-php.git/commitdiff_plain/c6e7dd34de3d34ac1552fed648c24b8e25357a72?hp=249f865d50d543087288a4fae426a444fd39ec24 Add $conn->rpc->info() and $conn->rpc->set_issuer("NameOfLoggedInUser") The latter requires UnrealIRCd 6.0.8+ --- diff --git a/lib/Connection.php b/lib/Connection.php index 37272b6..1f37c7e 100644 --- a/lib/Connection.php +++ b/lib/Connection.php @@ -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 index 0000000..721ba45 --- /dev/null +++ b/lib/Rpc.php @@ -0,0 +1,39 @@ +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, + ]); + } +}