Python library for unrealIRCD json-rpc
Project description
UNREALIRCD-RPC-PY
If you are using Python3, this package can help you to parse all json responses it does all the work for you.
How to use this package
$ pip3 install unrealircd_rpc_py
How to work with (remotly)
This package allows easy interfacing with UnrealIRCd through regular Python3 code, such as:
from unrealircd_rpc_py.Loader import Loader
# Initialize your connexion to unrealircd
rpc = Loader(
req_method='requests', # you can also use 'socket'
url='https://your.irc.domaine.org:8600/api',
username='apiname',
password='apiPASSWORD'
)
# Enjoy the power of JSON-RPC
User = rpc.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.DB_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)
How to work with (using unix socket locally)
This package allows easy interfacing with UnrealIRCd through regular Python3 code, such as:
from unrealircd_rpc_py.Loader import Loader
# Initialize your connexion to unrealircd
rpc = Loader(
req_method='unixsocket',
path_to_socket_file='/path/to/unrealircd/data/rpc.socket'
)
# Enjoy the power of JSON-RPC
User = rpc.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.DB_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)
How to work with (using Live unix socket)
from unrealircd_rpc_py.Live import Live
# This is un callback class that will recieve the response
from TestObject import TestObject
InitCallbackClass = TestObject()
# The Callback method must always have 1 parameter as string
liveRpc = Live(
path_to_socket_file='/path/to/unrealircd/data/rpc.socket',
callback_object_instance=InitCallbackClass,
callback_method_name='your_method_name'
)
# This method will run forever and will send to your callback method the response
# in SimpleNameSpace type that you can parse
liveRpc.execute_async_method()
Exemple of a Callback Class
class CallbackObject:
def __init__(self) -> None:
pass
def run(self, json_response) -> bool:
print(json_response)
if type(json_response.result) != bool:
print(json_response.result.channel)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
unrealircd_rpc_py-0.1.0.tar.gz
(20.4 kB
view details)
Built Distribution
File details
Details for the file unrealircd_rpc_py-0.1.0.tar.gz
.
File metadata
- Download URL: unrealircd_rpc_py-0.1.0.tar.gz
- Upload date:
- Size: 20.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | faccd77d224a703f83bd0add01eea79252c81a8b69f955e17a46ff37bf2c2767 |
|
MD5 | 26e0ca2abf64510998807342466ac8f8 |
|
BLAKE2b-256 | e57057efc19d88bcb6350f281380d18e73fed370b09453c5ec6e601afdd492c1 |
File details
Details for the file unrealircd_rpc_py-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: unrealircd_rpc_py-0.1.0-py3-none-any.whl
- Upload date:
- Size: 30.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a653d14dce1b2de30f007c08df31d49117b033e91a8a19ceb23bf0362327c0a |
|
MD5 | 616c2681066d5ef38174927f7a7d2820 |
|
BLAKE2b-256 | 4d89bd6c178406ea6a0055d17147bf8d652450ca8ab88bac7a630e1b69a399ba |