Skip to main content

Python library for UnrealIRCd json-rpc

Project description

UNREALIRCD-RPC-PY

Static Badge Static Badge Static Badge Static Badge Dynamic TOML 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 module

    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)

Using unixsocket method (Local only)

    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)

How to work with it

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)

Object that you can use in a synchrone mode

    # 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
    Message = rpc.Message # This feat requires unrealIRCd 6.2.2 or higher
    Connthrottle = rpc.ConnThrottle # This feat requires unrealIRCd 6.2.2 or higher
    SecurityGroup = rpc.SecurityGroup # This feat requires unrealIRCd 6.2.2 or higher

Live Connection using UnixSocket (Local Only)

    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'
    })

Live connection using Websocket (Local or Remote)

    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'
    })

Live Connection via unixsocket or websocket

How to work with

JSON-RPC TO SQL

    from unrealircd_rpc_py.modules.tosql.tosql import ToSql
    # PROVIDE YOUR SQL CREDENTIALS HERE
    # engine_name: you can choose between 3 sql engines
    #   postgresql, mysql or sqlite
    sql = ToSql(engine_name='postgresql',
        db_hostname='127.0.0.1',
        db_name='YOUR_DB_NAME',
        db_username='YOUR_DB_USERNAME',
        db_password='YOUR_DB_PASSWORD',
        db_port=0) # If you use default port leave the db_port to 0
    
    # PROVIDE YOUR RPC CREDENTIALS HERE
    sql.rpc_credentials.url='https://your.rpc.link:PORT/api'
    sql.rpc_credentials.username='YOUR-RPC-USER'
    sql.rpc_credentials.password='YOUR-RPC-PASSWORD'

    # FINALLY RUN THE COPY
    sql.run()

If you want to use sqlite please use the syntax below:

    from unrealircd_rpc_py.modules.tosql.tosql import ToSql

    sql = ToSql(engine_name='sqlite')

    # PROVIDE YOUR RPC CREDENTIALS HERE
    sql.rpc_credentials.url='https://your.rpc.link:PORT/api'
    sql.rpc_credentials.username='YOUR-RPC-USER'
    sql.rpc_credentials.password='YOUR-RPC-PASSWORD'

    # FINALLY RUN THE COPY
    sql.run()

How to work with JSON-RPC TO SQL

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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

unrealircd_rpc_py-3.1.7-py3-none-any.whl (58.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: unrealircd_rpc_py-3.1.7.tar.gz
  • Upload date:
  • Size: 38.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.1 CPython/3.10.11 Windows/10

File hashes

Hashes for unrealircd_rpc_py-3.1.7.tar.gz
Algorithm Hash digest
SHA256 3a9c8ccda92dc5eeddce3c1a99840762ee88d3ad69f4e5eefbedd600230fa004
MD5 2a711f62bee46c7e3eea185f51b01ae5
BLAKE2b-256 19c0518da45db3971848e806c6547f5b5282dc34609653a05604bdc682a8f267

See more details on using hashes here.

File details

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

File metadata

  • Download URL: unrealircd_rpc_py-3.1.7-py3-none-any.whl
  • Upload date:
  • Size: 58.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.1 CPython/3.10.11 Windows/10

File hashes

Hashes for unrealircd_rpc_py-3.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 5de3985a2b49a5439fafea4fbd398bfff75d7c2054bbf7b1b1a2df6662896019
MD5 050f633acf15e89e7c4da70368150c51
BLAKE2b-256 9441e660b369e3664a9e86ad7d5cca913e44e2962ee1946123c200f1ac3dfead

See more details on using hashes here.

Supported by

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