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.4.tar.gz (14.6 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.4-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pycord_inter_process-0.1.4.tar.gz
  • Upload date:
  • Size: 14.6 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.4.tar.gz
Algorithm Hash digest
SHA256 b3d837985bda49dd3fbbe142fd4589462d519486ec2cc436bbd310c890c284b3
MD5 cc14491d5602113d78e3704a26e2edc5
BLAKE2b-256 5f48cfa2dfbd3ab8a9cd99e04d052d7feed7fa4ee655362495e7e5605741be48

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycord_inter_process-0.1.4.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.4-py3-none-any.whl.

File metadata

File hashes

Hashes for pycord_inter_process-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9a0f2731c870bcc682b75368b343acaec502aff99ddc33ba2288b4cbd2de4065
MD5 b0115b4534e765462ca7d8a531e6d299
BLAKE2b-256 84f88b2c841e8ae83b779314cbbef6ef4891eded368d7341987d2a291460cfc5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycord_inter_process-0.1.4-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