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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3d837985bda49dd3fbbe142fd4589462d519486ec2cc436bbd310c890c284b3
|
|
| MD5 |
cc14491d5602113d78e3704a26e2edc5
|
|
| BLAKE2b-256 |
5f48cfa2dfbd3ab8a9cd99e04d052d7feed7fa4ee655362495e7e5605741be48
|
Provenance
The following attestation bundles were made for pycord_inter_process-0.1.4.tar.gz:
Publisher:
publish.yml on ParrotXray/pycord-ipc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pycord_inter_process-0.1.4.tar.gz -
Subject digest:
b3d837985bda49dd3fbbe142fd4589462d519486ec2cc436bbd310c890c284b3 - Sigstore transparency entry: 488093916
- Sigstore integration time:
-
Permalink:
ParrotXray/pycord-ipc@81fe51be857df3e7ee458ff4a4fb64c36540ae44 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/ParrotXray
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@81fe51be857df3e7ee458ff4a4fb64c36540ae44 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pycord_inter_process-0.1.4-py3-none-any.whl.
File metadata
- Download URL: pycord_inter_process-0.1.4-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a0f2731c870bcc682b75368b343acaec502aff99ddc33ba2288b4cbd2de4065
|
|
| MD5 |
b0115b4534e765462ca7d8a531e6d299
|
|
| BLAKE2b-256 |
84f88b2c841e8ae83b779314cbbef6ef4891eded368d7341987d2a291460cfc5
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pycord_inter_process-0.1.4-py3-none-any.whl -
Subject digest:
9a0f2731c870bcc682b75368b343acaec502aff99ddc33ba2288b4cbd2de4065 - Sigstore transparency entry: 488093928
- Sigstore integration time:
-
Permalink:
ParrotXray/pycord-ipc@81fe51be857df3e7ee458ff4a4fb64c36540ae44 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/ParrotXray
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@81fe51be857df3e7ee458ff4a4fb64c36540ae44 -
Trigger Event:
release
-
Statement type: