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:
tcp = api.TcpClient(
'127.0.0.1', # use your bots host ip
12345,
Impl(),
cafile='path/to/yourcafile.cert'
)
await tcp.connect()
await tcp.read()
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
🚨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
- Sending a message to a channel or user
CLIENT_CMD:SEND_MESSAGE:{"target": "#channel/user", "message": "hello world:"}
- Telling the server you are disconnecting
CLIENT_END:
Supported Message you can receive from the server
- On message in a channel or from user
SERVER_EVENT:ON_MESSAGE:{"target": "#channel/user", "by": "user_who_sent_msg", "message": "hello world"}
- 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.9.tar.gz
(6.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lotek_rpc-1.0.9.tar.gz.
File metadata
- Download URL: lotek_rpc-1.0.9.tar.gz
- Upload date:
- Size: 6.2 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a550f3e10f06eb6781ef21bc1d93d497e9138fadf5bb16290f888cb9092f195
|
|
| MD5 |
6ece3588195af1c66c7d654d0eb4ec19
|
|
| BLAKE2b-256 |
eed3f72e459c6c46a053a00e1a1f0f859eaa1ded43af26e26b77354644485751
|
File details
Details for the file lotek_rpc-1.0.9-py3-none-any.whl.
File metadata
- Download URL: lotek_rpc-1.0.9-py3-none-any.whl
- Upload date:
- Size: 6.0 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c08cde78c06a8d967c7d365d50bd217006765cf784b0aedf6a6ea5d729b12bae
|
|
| MD5 |
ef296b1b0b8dda67f5fc12347a5f2bb0
|
|
| BLAKE2b-256 |
c22f44a72fe5fd5509f2491a6c1d94d5375f49eefb0f7b8709facdbadacf74e8
|