]>
Commit | Line | Data |
---|---|---|
1 | UnrealIRCd RPC | |
2 | ============== | |
3 | ||
4 | This allows PHP scripts to control [UnrealIRCd](https://www.unrealircd.org/) | |
5 | via the [JSON-RPC interface](https://www.unrealircd.org/docs/JSON-RPC). | |
6 | ||
7 | WARNING: Both the UnrealIRCd-side and this PHP library are under heavy | |
8 | development so major API breakages are likely, such as changing the | |
9 | function names, arguments that need to be passed and the way things | |
10 | are returned. | |
11 | ||
12 | If you are interested in helping out or would like to discuss API | |
13 | capabilities, join us at `#unreal-webpanel` at irc.unrealircd.org | |
14 | (IRC with TLS on port 6697). | |
15 | ||
16 | See also [Looking for webdevs to make UnrealIRCd webpanel](https://forums.unrealircd.org/viewtopic.php?t=9257). | |
17 | ||
18 | Installation | |
19 | ------------ | |
20 | ```bash | |
21 | composer require unrealircd/unrealircd-rpc:dev-main | |
22 | ``` | |
23 | ||
24 | UnrealIRCd setup | |
25 | ----------------- | |
26 | UnrealIRCd 6.0.5 is needed and you need to configure it as explained in | |
27 | https://www.unrealircd.org/docs/JSON-RPC. | |
28 | ||
29 | After doing that, be sure to rehash the IRCd. | |
30 | ||
31 | Usage | |
32 | ----- | |
33 | For this example, create a file like `src/rpctest.php` with: | |
34 | ```php | |
35 | <?php | |
36 | require dirname(__DIR__) . '/vendor/autoload.php'; | |
37 | ||
38 | use UnrealIRCd\Connection; | |
39 | ||
40 | $api_login = 'api:apiPASSWORD'; // same as in the rpc-user block in UnrealIRCd | |
41 | ||
42 | $rpc = new UnrealIRCd\Connection("wss://127.0.0.1:8000/", | |
43 | $api_login, | |
44 | Array("tls_verify"=>FALSE)); | |
45 | ||
46 | $bans = $rpc->serverban()->getAll(); | |
47 | foreach ($bans as $ban) | |
48 | echo "There's a $ban->type on $ban->name\n"; | |
49 | ||
50 | $users = $rpc->user()->getAll(); | |
51 | foreach ($users as $user) | |
52 | echo "User $user->name\n"; | |
53 | ||
54 | $channels = $rpc->channel()->getAll(); | |
55 | foreach ($channels as $channel) | |
56 | echo "Channel $channel->name ($channel->num_users user[s])\n"; | |
57 | ``` | |
58 | And then run it on the command line with `php src/rpctest.php` | |
59 | ||
60 | If the example does not work, then make sure you have configured your | |
61 | UnrealIRCd correctly, with the same API username and password you use | |
62 | here, and with an allowed IP, and changing the `127.0.0.1:8000` too | |
63 | if needed. |