If you are using Python3, this package can help you to parse all json responses it does all the work for you.
pip3 install unrealircd_rpc_pyNote
I recommend installing a virtual environment and then installing the package within it.
from unrealircd_rpc_py.ConnectionFactory import ConnectionFactory
# Define your connection string
connection_string = {
'url': 'https://your.irc.domaine.org:8600/api',
'username':'API_USERNAME',
'password':'API_PASSWORD'
}
# Use the factory to create your connection object
conn = ConnectionFactory().get('http')
conn.setup(connection_string) from unrealircd_rpc_py.ConnectionFactory import ConnectionFactory
# Define your connection string
connection_string = {
'path_to_socket_file': '/path/to/unrealircd/data/rpc.socket'
}
# Use the factory to create your connection object
conn = ConnectionFactory().get('unixsocket')
conn.setup(connection_string)This package allows easy interfacing with UnrealIRCd through regular Python3 code, such as:
# Enjoy the power of JSON-RPC
User = conn.User
response = User.get('adator')
print(f'Nickname: {response.name}')
print(f'Ip: {response.ip}')
Channels = rpc.Channel
response = Channels.list_(_object_detail_level=3)
for chan in Channels:
print(f'-' * 16)
print(f'Channel: {chan.name}')
print(f'Created on: {chan.creation_time}')
print(f'Bans: {chan.bans}')
print(f'Members: {chan.members}')
print(f'-' * 16) # After connecting using one of the methods listed above.
rpc = conn
Channel = rpc.Channel
Name_ban = rpc.Name_ban
Server_ban_exception = rpc.Server_ban_exception
Server_ban = rpc.Server_ban
Spamfilter = rpc.Spamfilter
Stats = rpc.Stats
User = rpc.User
Whowas = rpc.Whowas
Log = rpc.Log # This feature requires unrealIRCd 6.1.8 or higher from unrealircd_rpc_py.LiveConnectionFactory import LiveConnectionFactory
# Live Connection (Local only) using unix socket
liverpc = LiveConnectionFactory().get('unixsocket')
liverpc.setup({
'path_to_socket_file': '/path/to/unrealircd/data/rpc.socket',
'callback_object_instance' : callback_function_instance,
'callback_method_or_function_name': 'your_method_name'
}) from unrealircd_rpc_py.LiveConnectionFactory import LiveConnectionFactory
# Live Connection (Local Or Remote) using websocket
liverpc = LiveConnectionFactory().get('http')
liverpc.setup({
'url': 'https://your.irc.domaine.org:8600/api',
'username': 'Your-api-username',
'password': 'Your-api-password',
'callback_object_instance' : callback_function_instance,
'callback_method_or_function_name': 'your_method_name'
})- Class: see how_to_use_it_live_class.py
- Function: see how_to_use_it_live_func.py