# pycord-ipc
A pycord extension for inter-process communication.
# Installation
Python >= 3.10.x is required.
```bash=
# Windows
pip install --upgrade pycord-inter-process
# Linux
pip3 install --upgrade pycord-inter-process
```
# Examples
### Server example
```py=
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
```py=
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)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/ParrotXray/pycord-ipc",
"name": "pycord-inter-process",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "discord, ipc, websocket, asyncio, py-cord",
"author": "ParrotXray",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/3a/93/71fc1c809c46b1b866157bb5147d32c451d1b4b4c3f3522b4fa4a57cb9f2/pycord_inter_process-0.1.1.tar.gz",
"platform": null,
"description": "# pycord-ipc\r\nA pycord extension for inter-process communication.\r\n\r\n# Installation \r\nPython >= 3.10.x is required.\r\n```bash=\r\n# Windows\r\npip install --upgrade pycord-inter-process\r\n\r\n# Linux\r\npip3 install --upgrade pycord-inter-process\r\n```\r\n\r\n# Examples\r\n### Server example \r\n```py= \r\nimport discord\r\nfrom pycord.ipc import Server\r\n\r\nprint(\"Bot starting...\")\r\n\r\nintents = discord.Intents.all()\r\nbot = discord.Bot(intents=intents)\r\nipc_server = Server(bot, secret_key=<\"your IPCSecret\">, host=<\"your IPCHost\">, port=63719)\r\n\r\n@bot.event\r\nasync def on_ready():\r\n await ipc_server.start()\r\n\r\n# @bot.event\r\n# async def on_ipc_ready():\r\n# \"\"\"Called upon the IPC Server being ready\"\"\"\r\n# print(f\"Starting IPC server\")\r\n\r\n@bot.event\r\nasync def on_ipc_error(endpoint, error):\r\n print(f\"{endpoint} raised {error}\")\r\n\r\n@ipc_server.route()\r\nasync def get_bot_stats(data):\r\n return {\r\n \"guild_count\": len(bot.guilds),\r\n \"channel_count\": sum(len(guild.channels) for guild in bot.guilds),\r\n \"member_count\": sum(len(guild.members) for guild in bot.guilds),\r\n }\r\n\r\nloop = asyncio.new_event_loop()\r\nasyncio.set_event_loop(loop)\r\n\r\nbot.run(<\"your Token\">)\r\n```\r\n\r\n### Client example\r\n```py= \r\nfrom quart import Quart, request, session, redirect, url_for, jsonify\r\nfrom pycord.ipc import Client\r\n\r\napp = Quart(__name__)\r\nipc_client = Client(secret_key=<\"your IPCSecret\">, host=<\"your IPC Server IP\">, port=<\"your IPC Server Port\">)\r\n\r\n@app.route(\"/api/bot/stats\", methods=[\"GET\"])\r\nasync def get_bot_stats():\r\n try:\r\n bot_stats = await ipc_client.request(\"get_bot_stats\")\r\n return jsonify({\r\n \"success\": True,\r\n \"data\": {\r\n \"guild_count\": bot_stats[\"guild_count\"],\r\n \"channel_count\": bot_stats[\"channel_count\"],\r\n \"member_count\": bot_stats[\"member_count\"]\r\n }\r\n })\r\n except Exception as e:\r\n return jsonify({\r\n \"success\": False,\r\n \"error\": str(e)\r\n }), 500\r\n\r\nif __name__ == \"__main__\":\r\n app.run(host=\"0.0.0.0\", port=8080, debug=True)\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A pycord extension for inter-process communication.",
"version": "0.1.1",
"project_urls": {
"Homepage": "https://github.com/ParrotXray/pycord-ipc",
"Issue Tracker": "https://github.com/ParrotXray/pycord-ipc/issues",
"Repository": "https://github.com/ParrotXray/pycord-ipc",
"Source": "https://github.com/ParrotXray/pycord-ipc"
},
"split_keywords": [
"discord",
" ipc",
" websocket",
" asyncio",
" py-cord"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "4e5c07be1e03d52ee35b3316f677feec5da30f20d29ae9fd9ba91d0cde344f37",
"md5": "2218f56343d3841cf6717a010fb1cdbf",
"sha256": "3a4e88e7145d424e14eb34eee412ac885bfe0a79cd36e0917d84c7af331139ff"
},
"downloads": -1,
"filename": "pycord_inter_process-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2218f56343d3841cf6717a010fb1cdbf",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 12623,
"upload_time": "2025-07-08T11:50:24",
"upload_time_iso_8601": "2025-07-08T11:50:24.356733Z",
"url": "https://files.pythonhosted.org/packages/4e/5c/07be1e03d52ee35b3316f677feec5da30f20d29ae9fd9ba91d0cde344f37/pycord_inter_process-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "3a9371fc1c809c46b1b866157bb5147d32c451d1b4b4c3f3522b4fa4a57cb9f2",
"md5": "34dcd014c12b8e369a86bb99d31fe12f",
"sha256": "e35e8bcecf12c6ef93f66cad46f678e85e97a34c4f0b1e93521c02abaf107736"
},
"downloads": -1,
"filename": "pycord_inter_process-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "34dcd014c12b8e369a86bb99d31fe12f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 14085,
"upload_time": "2025-07-08T11:50:25",
"upload_time_iso_8601": "2025-07-08T11:50:25.375595Z",
"url": "https://files.pythonhosted.org/packages/3a/93/71fc1c809c46b1b866157bb5147d32c451d1b4b4c3f3522b4fa4a57cb9f2/pycord_inter_process-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-08 11:50:25",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ParrotXray",
"github_project": "pycord-ipc",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "aiohttp",
"specs": []
},
{
"name": "typing-extensions",
"specs": []
},
{
"name": "py-cord",
"specs": []
}
],
"lcname": "pycord-inter-process"
}