Websocket based IPC for discord.py bots
Project description
winerp
An IPC based on Websockets. Fast, Stable, and easy-to-use, for inter-communication between your processes or discord.py bots.
Key Features
- Fast with minimum recorded response time being
< 2ms
- Lightweight, Stable and Easy to integrate.
- No limitation on number of connected clients.
Installation
Stable:
pip install -U winerp
Main branch (can be unstable/buggy):
pip install git+https://www.github.com/BlackThunder01001/winerp
Working:
This library uses a central server for communication between multiple clients. You can connect a large number of clients for sharing data, and data can be shared between any connected client.
Example Usage:
Start the server on terminal using $ winerp --port 8080
. You can also start the server using winerp.Server
Client 1 (some-random-bot
):
import winerp
import discord
from discord.ext.commands import Bot
bot = Bot(command_prefix="!", intents=discord.Intents.all())
bot.ipc = winerp.Client(local_name = "some-random-bot", loop = bot.loop, port=8080)
@bot.command()
async def request(ctx):
# Fetching data from a client named "another-bot" using route "get_some_data"
data = await bot.ipc.request("get_some_data", source = "another-bot")
await ctx.send(data)
@bot.ipc.route()
async def get_formatted_data(user_id = None):
return f"<@{user_id}>"
@bot.ipc.event
async def on_winerp_ready():
print("Winerp Client is ready for connections")
bot.loop.create_task(bot.ipc.start())
bot.run("TOKEN")
Client 2 (another-bot
)
import winerp
import discord
from discord.ext.commands import Bot
bot = Bot(command_prefix="?", intents=discord.Intents.all())
bot.ipc = winerp.Client(local_name = "another-bot", loop = bot.loop, port=8080)
@bot.command()
async def format(ctx):
# Fetching data from a client named "some-random-bot" using route "get_formatted_data"
data = await bot.ipc.request("get_formatted_data", source = "some-random-bot", user_id = ctx.author.id)
await ctx.send(data)
@bot.ipc.route()
async def get_some_data():
return "You are very cool"
bot.loop.create_task(bot.ipc.start())
bot.run("TOKEN")
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
winerp-1.1.3.tar.gz
(11.0 kB
view details)
Built Distribution
winerp-1.1.3-py3-none-any.whl
(11.3 kB
view details)
File details
Details for the file winerp-1.1.3.tar.gz
.
File metadata
- Download URL: winerp-1.1.3.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f23ce80fa09f6ecb902967a312122b5b5f04c452a17157c51b0e6bf0447f0b16 |
|
MD5 | 3ca670331c91d076a16a786e5fa420cd |
|
BLAKE2b-256 | 3c419509acf25bcd18e6773785308098c786027ea9b530c198d31d0fa7a13023 |
File details
Details for the file winerp-1.1.3-py3-none-any.whl
.
File metadata
- Download URL: winerp-1.1.3-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7ea8c17488cddbf587ddcbc0239f2308a7abb682030e42f3204b10810436e8d |
|
MD5 | 2304913901e1f7b1fea6409f56dd95ae |
|
BLAKE2b-256 | 4251cfbf3c1c134190917f6bfd08b48f75d2f07c24225479f33c9e4b2b314f33 |