Skip to main content

Python library for unrealIRCD json-rpc

Project description

UNREALIRCD-RPC-PY

Static Badge Static Badge Dynamic JSON Badge Static Badge

Introduction

If you are using Python3, this package can help you to parse all json responses it does all the work for you.

How to install this package

    pip3 install unrealircd_rpc_py

[!NOTE] I recommend installing a virtual environment and then installing the package within it.

How to establish the link

    # Using requests method
    rpc = Loader(
            req_method='requests',
            url='https://your.irc.domaine.org:8600/api',
            username='apiname',
            password='apiPASSWORD'
        )

    # Using socket method
    rpc = Loader(
            req_method='socket',
            url='https://your.irc.domaine.org:8600/api',
            username='apiname',
            password='apiPASSWORD'
        )

    # Using unixsocket method (Local only)
    rpc = Loader(
            req_method='unixsocket',
            path_to_socket_file='/path/to/unrealircd/data/rpc.socket'
        )

    # Live Connection (Local only)
    LiveRpc = Live(
        path_to_socket_file='/path/to/unrealircd/data/rpc.socket',
        callback_object_instance=Callback_class_instance,
        callback_method_name='your_method_name'
    )

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:
        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)

    # The auto completion should help you to find all available attributes
    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)

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.subscribe()

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)

Object that you can use in a synchrone mode

    from unrealircd_rpc_py.Loader import Loader

    # Initialize your connexion to unrealircd using the unixsocket
    rpc = Loader(
            req_method='unixsocket',
            path_to_socket_file='/path/to/unrealircd/data/rpc.socket'
        )

    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

Project details


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-1.0.4.tar.gz (23.6 kB view details)

Uploaded Source

Built Distribution

unrealircd_rpc_py-1.0.4-py3-none-any.whl (34.2 kB view details)

Uploaded Python 3

File details

Details for the file unrealircd_rpc_py-1.0.4.tar.gz.

File metadata

  • Download URL: unrealircd_rpc_py-1.0.4.tar.gz
  • Upload date:
  • Size: 23.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.11

File hashes

Hashes for unrealircd_rpc_py-1.0.4.tar.gz
Algorithm Hash digest
SHA256 f3cefa75f2b05f2edd9bbc04f9149bc9b167eb394459dd30c642526e7901cf18
MD5 18420631f4670ef2f427dd6ebbd8ca65
BLAKE2b-256 3141b5190f4a688bca8f1cebf32a4b32c88ad051a84436a02d470085a13381e6

See more details on using hashes here.

File details

Details for the file unrealircd_rpc_py-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for unrealircd_rpc_py-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 84778f406562c6461fb270334f6b9e059f9c8258c7e35ce4c8ab73af09cae227
MD5 4fe2fec7aa17cc3692b625f0583241b3
BLAKE2b-256 c26cb02a9f9c62b1167c9750ca27886f0474eaaf3eaa33b1fe646afc5021119f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page