Skip to main content

Simple TCP client impl to interact with the irc bot and build remote plugins.

Project description

RPC Module

Installing from PyPi

pip3 install lotek_rpc

Example implementation

import asyncio
import lotek_rpc.api as api


class Impl(api.IrcImpl):
    async def on_message(self, target, by, message):
        print(target, by, message)
        # do some shit like
        if message == 'hack_a_gibson':
            await self.rpc.send_message(target, 'hacking gibson from RPC')
        elif message.startswith('dieplz'):
            await self.rpc.disconnect()
            exit(1)


async def main():
    # endless loop to always try and connect
    while True:
        try:
            tcp = api.TcpClient(
                '127.0.0.1',  # use your bots host ip
                12345,
                Impl(),
                cafile='path/to/yourcafile.cert' # optional. remove this line if using hosted bot
            )
            await tcp.connect()
            await tcp.read()
        except (asyncio.TimeoutError, ConnectionError) as e:
            print(f"Connection error occurred: {e}")
            await asyncio.sleep(5)
        except Exception as e:
            print(f"Unexpected error: {e}")
            await asyncio.sleep(5)


loop = asyncio.get_event_loop()

try:
    loop.run_until_complete(main())
except KeyboardInterrupt:
    print("Bot terminated by user.")


🚨Important info before starting to implement your own client not using this library🚨

Messages are terminated by a nullbyte 0x00. This means at the end of any message you send, add 0x00 byte. Any message you receive from the server will be ended with 0x00

Info for those who want to implement their own client

Supported Messages you can send from the client

  1. Sending a message to a channel or user
    • CLIENT_CMD:SEND_MESSAGE:{"target": "#channel/user", "message": "hello world:"}
  2. Telling the server you are disconnecting
    • CLIENT_END:

Supported Message you can receive from the server

  1. On message in a channel or from user
    • SERVER_EVENT:ON_MESSAGE:{"target": "#channel/user", "by": "user_who_sent_msg", "message": "hello world"}
  2. On RPC Server restarting
    • SERVER_EVENT:RESTARTING


Building wheel + src

# https://packaging.python.org/tutorials/packaging-projects/
python3.9 -m pip install --upgrade build
python3.9 -m build
python3.9 -m twine upload --repository testpypi dist/*

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

lotek_rpc-1.0.10.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

lotek_rpc-1.0.10-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file lotek_rpc-1.0.10.tar.gz.

File metadata

  • Download URL: lotek_rpc-1.0.10.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/8.6.1 pkginfo/1.12.1.2 requests/2.32.3 requests-toolbelt/1.0.0 tqdm/4.67.1 CPython/3.10.15

File hashes

Hashes for lotek_rpc-1.0.10.tar.gz
Algorithm Hash digest
SHA256 aa1b7773cc2204a272221b04a4ea3cfdae51f8a22d9aea3ebe912ac74352be25
MD5 bbc3efd3e56bc4f0b1573f2bf754ef87
BLAKE2b-256 a1f90fde8de2beb0c6429ce36be823c50f3e9d0781b56a45f123ae04b7a8ecf5

See more details on using hashes here.

File details

Details for the file lotek_rpc-1.0.10-py3-none-any.whl.

File metadata

  • Download URL: lotek_rpc-1.0.10-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/8.6.1 pkginfo/1.12.1.2 requests/2.32.3 requests-toolbelt/1.0.0 tqdm/4.67.1 CPython/3.10.15

File hashes

Hashes for lotek_rpc-1.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 12c7996de7835be9b5ab7d907073714f6425658cdbf531ea9091420a73fa63cd
MD5 b68fe469a71d0af79b47b49d3a460287
BLAKE2b-256 f35e3ce02aead16605993e8cc0e5257455bff4e9f6c6468bff6822b5dc75cd4c

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