]> jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/summary
 
descriptionUnnamed repository; edit this file 'description' to name the repository.
ownerJohn Runyon
last changeMon, 8 May 2023 06:28:24 +0000 (08:28 +0200)
readme

UnrealIRCd RPC

This allows PHP scripts to control UnrealIRCd via the JSON-RPC interface.

This library is used by the UnrealIRCd webpanel.

If you are interested in helping out or would like to discuss API capabilities, join us at #unreal-webpanel at irc.unrealircd.org (IRC with TLS on port 6697).

Installation

composer require unrealircd/unrealircd-rpc:dev-main

UnrealIRCd setup

UnrealIRCd 6.0.6 or later is needed and you need to enable JSON-RPC in it. After doing that, be sure to rehash the IRCd.

Usage

For this example, create a file like src/rpctest.php with:

<?php
    require dirname(__DIR__) . '/vendor/autoload.php';

    use UnrealIRCd\Connection;

    $api_login = 'api:apiPASSWORD'; // same as in the rpc-user block in UnrealIRCd

    $rpc = new UnrealIRCd\Connection("wss://127.0.0.1:8600/",
                        $api_login,
                        Array("tls_verify"=>FALSE));

    $bans = $rpc->serverban()->getAll();
    foreach ($bans as $ban)
        echo "There's a $ban->type on $ban->name\n";

    $users = $rpc->user()->getAll();
    foreach ($users as $user)
        echo "User $user->name\n";

    $channels = $rpc->channel()->getAll();
    foreach ($channels as $channel)
        echo "Channel $channel->name ($channel->num_users user[s])\n";

Then, run it on the command line with php src/rpctest.php

If the example does not work, then make sure you have configured your UnrealIRCd correctly, with the same API username and password you use here, with an allowed IP, and changing the wss://127.0.0.1:8600/ too if needed.

shortlog
2023-05-08  Bram MatthysReturn from $rpc->eventloop() after 2 seconds instead... main origin/HEAD origin/main
2023-05-05  Bram Matthys$rpc->log()->getAll() now has a $sources argument which...
2023-04-27  Bram MatthysWhoops.. i was wrong.. microtime() w/$as_float=true...
2023-04-27  Bram MatthysThis fix-for-endless-exception used <1ms while it shoul...
2023-04-27  Bram MatthysFix wrong function arguments (well, will be changed...
2023-04-27  Bram MatthysActually return ->list...
2023-04-27  Bram MatthysAdd log.list (yeah that is in progress :D)
2023-04-27  Bram Matthysquery(): handle replies for different id, for errors...
2023-04-27  Bram MatthysUpdate composer dependencies. End users need to run...
2023-04-27  Bram MatthysMake query() throw an error when the request timed...
2023-04-27  Bram MatthysOn new connection, call rpc.set_issuer but don't wait...
2023-04-27  Bram MatthysAllow setting "issuer" in UnrealIRCd\Connection options...
2023-04-12  Bram MatthysAdd $rpc->rpc()->add_timer(); and ->del_timer()
2023-04-12  Bram MatthysActually return something ;)
2023-04-12  Bram MatthysAdd $rpc->stats()->get();
2023-04-10  Bram MatthysWorkaround library bug in eventloop(). Apparently if...
...
heads
12 months ago main
remotes
origin
12 months ago HEAD
12 months ago main