Skip to main content

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


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

Uploaded Source

Built Distribution

winerp-1.1.2-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file winerp-1.1.2.tar.gz.

File metadata

  • Download URL: winerp-1.1.2.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.5

File hashes

Hashes for winerp-1.1.2.tar.gz
Algorithm Hash digest
SHA256 3a04efd2b5b3ddd6dcb7c41bca38cc1e12f0de27c6783a2378982a7dab9dfd38
MD5 2b0f3d8ca22b40aba019b7b04a149676
BLAKE2b-256 cd06de81c50cef10873dda4c09ee9260406b6f6d9e56c7f69e2a0e4cea16c460

See more details on using hashes here.

File details

Details for the file winerp-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: winerp-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.5

File hashes

Hashes for winerp-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4a33519905c2cfcadd235018217c6f4f761b92afb86972621b4b40501d742304
MD5 7ed4fb6c90317274494f0c5bed685b3d
BLAKE2b-256 f4f2f6fa1439364a43d44b40e889a014a615115fb0615b5841bf40fbe19f6504

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