Skip to main content

A pycord extension for inter-process communication.

Project description

pycord-ipc

A pycord extension for inter-process communication.

Installation

Python >= 3.10.x is required.

# Windows
pip install --upgrade pycord-inter-process

# Linux
pip3 install --upgrade pycord-inter-process

Examples

Server example

import discord
from pycord.ipc import Server

print("Bot starting...")

intents = discord.Intents.all()
bot = discord.Bot(intents=intents)
ipc_server = Server(bot, secret_key=<"your IPCSecret">, host=<"your IPCHost">, port=63719)

@bot.event
async def on_ready():
    await ipc_server.start()

# @bot.event
# async def on_ipc_ready():
#     """Called upon the IPC Server being ready"""
#     print(f"Starting IPC server")

@bot.event
async def on_ipc_error(endpoint, error):
    print(f"{endpoint} raised {error}")

@ipc_server.route()
async def get_bot_stats(data):
    return {
        "guild_count": len(bot.guilds),
        "channel_count": sum(len(guild.channels) for guild in bot.guilds),
        "member_count": sum(len(guild.members) for guild in bot.guilds),
    }

loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)

bot.run(<"your Token">)

Client example

from quart import Quart, request, session, redirect, url_for, jsonify
from pycord.ipc import Client

app = Quart(__name__)
ipc_client = Client(secret_key=<"your IPCSecret">, host=<"your IPC Server IP">, port=<"your IPC Server Port">)

@app.route("/api/bot/stats", methods=["GET"])
async def get_bot_stats():
    try:
        bot_stats = await ipc_client.request("get_bot_stats")
        return jsonify({
            "success": True,
            "data": {
                "guild_count": bot_stats["guild_count"],
                "channel_count": bot_stats["channel_count"],
                "member_count": bot_stats["member_count"]
            }
        })
    except Exception as e:
        return jsonify({
            "success": False,
            "error": str(e)
        }), 500

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=8080, debug=True)

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

pycord_inter_process-0.1.5.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

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

pycord_inter_process-0.1.5-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file pycord_inter_process-0.1.5.tar.gz.

File metadata

  • Download URL: pycord_inter_process-0.1.5.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pycord_inter_process-0.1.5.tar.gz
Algorithm Hash digest
SHA256 281df03112d671dc2c7c25b4ea89a465a092dfa554da0d5f87198a8868ca7c3a
MD5 35fdebc744921f740eba8c63c092a383
BLAKE2b-256 228d826eb6e7d073643d5fb837ed6d40f205b569964ced1b828d03ad34fd7c56

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycord_inter_process-0.1.5.tar.gz:

Publisher: publish.yml on ParrotXray/pycord-ipc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycord_inter_process-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for pycord_inter_process-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ff059ad6c6c55d3122c272d6c75e7d4c03d9657056a991482d6f513689f7fa4b
MD5 2007414de193496b570cbb4cc6765233
BLAKE2b-256 e36545f927fd3554f45a80b457b6e59721cead4e26db88a491b02cc8a3964a36

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycord_inter_process-0.1.5-py3-none-any.whl:

Publisher: publish.yml on ParrotXray/pycord-ipc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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