]>
Commit | Line | Data |
---|---|---|
562c96c0 BM |
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 | ||
f228c2d5 BM |
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 | ||
66eda38d BM |
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). | |
562c96c0 BM |
17 | |
18 | Installation | |
19 | ------------ | |
20 | ```bash | |
27d8a778 | 21 | composer require unrealircd/unrealircd-rpc:dev-main |
562c96c0 BM |
22 | ``` |
23 | ||
66eda38d BM |
24 | UnrealIRCd setup |
25 | ----------------- | |
f228c2d5 | 26 | UnrealIRCd 6.0.5 is needed and you need to configure it as explained in |
66eda38d BM |
27 | https://www.unrealircd.org/docs/JSON-RPC. |
28 | ||
f228c2d5 | 29 | After doing that, be sure to rehash the IRCd. |
66eda38d | 30 | |
562c96c0 BM |
31 | Usage |
32 | ----- | |
e3d9bcad | 33 | For this example, create a file like `src/rpctest.php` with: |
562c96c0 BM |
34 | ```php |
35 | <?php | |
36 | require dirname(__DIR__) . '/vendor/autoload.php'; | |
37 | ||
66eda38d | 38 | use UnrealIRCd\Connection; |
562c96c0 | 39 | |
66eda38d | 40 | $api_login = 'api:apiPASSWORD'; // same as in the rpc-user block in UnrealIRCd |
562c96c0 | 41 | |
66eda38d | 42 | $rpc = new UnrealIRCd\Connection("wss://127.0.0.1:8000/", |
562c96c0 BM |
43 | $api_login, |
44 | Array("tls_verify"=>FALSE)); | |
45 | ||
66eda38d | 46 | $bans = $rpc->serverban()->getAll(); |
93f8a3ee | 47 | foreach ($bans as $ban) |
66eda38d BM |
48 | echo "There's a $ban->type on $ban->name\n"; |
49 | ||
50 | $users = $rpc->user()->getAll(); | |
93f8a3ee | 51 | foreach ($users as $user) |
66eda38d BM |
52 | echo "User $user->name\n"; |
53 | ||
54 | $channels = $rpc->channel()->getAll(); | |
93f8a3ee | 55 | foreach ($channels as $channel) |
66eda38d | 56 | echo "Channel $channel->name ($channel->num_users user[s])\n"; |
562c96c0 | 57 | ``` |
e3d9bcad BM |
58 | And then run it on the command line with `php src/rpctest.php` |
59 | ||
66eda38d BM |
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. |