Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/MiroslavRosenov/better-ipc
High-performance inter-process communication library designed to work with the latest version of discord.py
https://github.com/MiroslavRosenov/better-ipc
asyncio discord-py ipc python python3
Last synced: 11 days ago
JSON representation
High-performance inter-process communication library designed to work with the latest version of discord.py
- Host: GitHub
- URL: https://github.com/MiroslavRosenov/better-ipc
- Owner: MiroslavRosenov
- License: gpl-3.0
- Created: 2022-03-28T15:50:49.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-08T09:14:57.000Z (3 months ago)
- Last Synced: 2024-09-09T14:38:10.026Z (2 months ago)
- Topics: asyncio, discord-py, ipc, python, python3
- Language: Python
- Homepage: https://docs.better-ipc.com
- Size: 445 KB
- Stars: 40
- Watchers: 3
- Forks: 13
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-discordpy - MiroslavRosenov/better-ipc - High-performance inter-process communication library designed to work with the latest version of discord.py. (Libraries and Extensions / Inter-Process Communication)
README
# Better IPC
## 📢 Announcement: Repository Archived 📢
I am announcing that as of today (08.10.2024) the GitHub repository better-ipc is now archived.
This project has served its purpose, and after careful consideration, I’ve decided to archive it to preserve the repository in its current state. While it will no longer be actively maintained or accept new contributions, it will remain available for reference and historical purposes.
I want to extend my sincere gratitude to everyone who has provided feedback and supported this project. Your involvement has been invaluable, and I hope that the repository continues to serve as a helpful resource for the community.
Feel free to continue exploring and forking the repository if you find it useful. For any future projects or improvements, stay tuned!
## Better IPC
This library is *based* on [discord-ext-ipc](https://github.com/Ext-Creators/discord-ext-ipc), which is no longer maintained.
# Installation
> ### Stable version
#### For Linux
```shell
python3 -m pip install -U better-ipc
```
#### For Windows
```shell
py -m pip install -U better-ipc
```> ### Development version
#### For Linux
```shell
python3 -m pip install -U git+https://github.com/MiroslavRosenov/better-ipc
```
#### For Windows
```shell
py -m pip install -U git+https://github.com/MiroslavRosenov/better-ipc
```# Support
[Support server](https://discord.gg/Rpg7zjFYsh)
[Official documentation](https://docs.better-ipc.com)
# Examples
### Client example
```python
import discord
from typing import Dict
from discord.ext import commands, ipc
from discord.ext.ipc.server import Server
from discord.ext.ipc.objects import ClientPayloadclass MyBot(commands.Bot):
def __init__(self) -> None:
intents = discord.Intents.all()super().__init__(
command_prefix="$.",
intents=intents,
)self.ipc = ipc.Server(self, secret_key="🐼")
async def setup_hook(self) -> None:
await self.ipc.start()@Server.route()
async def get_user_data(self, data: ClientPayload) -> Dict:
user = self.get_user(data.user_id)
return user._to_minimal_user_json()
```### Cog example
```python
from typing import Dict
from discord.ext import commands, ipc
from discord.ext.ipc.server import Server
from discord.ext.ipc.errors import IPCError
from discord.ext.ipc.objects import ClientPayloadclass Routes(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
if not hasattr(bot, "ipc"):
bot.ipc = ipc.Server(self.bot, secret_key="🐼")
async def cog_load(self) -> None:
await self.bot.ipc.start()async def cog_unload(self) -> None:
await self.bot.ipc.stop()
self.bot.ipc = None@Server.route()
async def get_user_data(self, data: ClientPayload) -> Dict:
user = self.bot.get_user(data.user_id)
return user._to_minimal_user_json()async def setup(bot):
await bot.add_cog(Routes(bot))
```### Inside your web application
```python
from quart import Quart
from discord.ext.ipc import Clientapp = Quart(__name__)
ipc = Client(secret_key="🐼")@app.route('/')
async def main():
resp = await ipc.request("get_user_data", user_id=383946213629624322)
return str(resp.response)if __name__ == '__main__':
app.run()
```