Pycord-IPC


NamePycord-IPC JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/sampathgujarathi/pycord-ipc
SummaryA high-performance inter-process communication library designed to work with the latest version of py-cord
upload_time2023-10-25 06:22:50
maintainer
docs_urlNone
authorSampath
requires_python>=3.8.0
licenseMIT License
keywords pycord-ipc ipc python py-cord
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Pycord IPC

<a href="https://pypi.org/project/pycord-ipc/" target="_blank"><img src="https://img.shields.io/pypi/v/pycord-ipc"></a>
<img src="https://img.shields.io/pypi/pyversions/pycord-ipc">

## High-performance inter-process communication library designed to work with the latest version of [Pycord](https://github.com/Pycord-Development/pycord)

This library is *based* on [Better-IPC](https://github.com/MiroslavRosenov/better-ipc).

# Installation
> ### Stable version
#### For Linux
```shell
python3 -m pip install -U pycord-ipc
```
#### For Windows
```shell
py -m pip install -U pycord-ipc
```

# Examples

### Client example
```python
import asyncio
import websockets
import discord
from discord.ext import commands
from ipc.server import Server
from ipc.objects import ClientPayload

intents = discord.Intents.all()

bot = discord.Bot(intents=intents)
ipc = Server(bot, secret_key="🐼")

@bot.event
async def on_ready():
    print(f'Logged in as {bot.user.name}')


@Server.route()
async def get_user_data(self,data: ClientPayload):
    user = bot.get_user(int(data.user_id))
    return user._to_minimal_user_json()

async def main():
    await ipc.start()
    await bot.start('BOT_TOKEN')

if __name__ == "__main__":
    asyncio.run(main())
```


### 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 ClientPayload

class 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):
        await self.bot.ipc.start()

    async def cog_unload(self):
        await self.bot.ipc.stop()
        self.bot.ipc = None

    @Server.route()
    async def get_user_data(self, data: ClientPayload):
        user = self.bot.get_user(int(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 Client

app = Quart(__name__)
ipc = Client(secret_key="🐼")

@app.route('/user/<user>')
async def main(user):
    resp = await ipc.request("get_user_data", user_id=user)
    return str(resp.response)

if __name__ == '__main__':
    app.run()
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/sampathgujarathi/pycord-ipc",
    "name": "Pycord-IPC",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8.0",
    "maintainer_email": "",
    "keywords": "pycord-ipc,ipc,python,py-cord",
    "author": "Sampath",
    "author_email": "gujarathisampath@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/b0/39/ab6f5f619597bd3e2c5548c353a8f87c1ff8be94c66fd10498de280ae944/Pycord-IPC-1.0.0.tar.gz",
    "platform": null,
    "description": "# Pycord IPC\r\n\r\n<a href=\"https://pypi.org/project/pycord-ipc/\" target=\"_blank\"><img src=\"https://img.shields.io/pypi/v/pycord-ipc\"></a>\r\n<img src=\"https://img.shields.io/pypi/pyversions/pycord-ipc\">\r\n\r\n## High-performance inter-process communication library designed to work with the latest version of [Pycord](https://github.com/Pycord-Development/pycord)\r\n\r\nThis library is *based* on [Better-IPC](https://github.com/MiroslavRosenov/better-ipc).\r\n\r\n# Installation\r\n> ### Stable version\r\n#### For Linux\r\n```shell\r\npython3 -m pip install -U pycord-ipc\r\n```\r\n#### For Windows\r\n```shell\r\npy -m pip install -U pycord-ipc\r\n```\r\n\r\n# Examples\r\n\r\n### Client example\r\n```python\r\nimport asyncio\r\nimport websockets\r\nimport discord\r\nfrom discord.ext import commands\r\nfrom ipc.server import Server\r\nfrom ipc.objects import ClientPayload\r\n\r\nintents = discord.Intents.all()\r\n\r\nbot = discord.Bot(intents=intents)\r\nipc = Server(bot, secret_key=\"\ud83d\udc3c\")\r\n\r\n@bot.event\r\nasync def on_ready():\r\n    print(f'Logged in as {bot.user.name}')\r\n\r\n\r\n@Server.route()\r\nasync def get_user_data(self,data: ClientPayload):\r\n    user = bot.get_user(int(data.user_id))\r\n    return user._to_minimal_user_json()\r\n\r\nasync def main():\r\n    await ipc.start()\r\n    await bot.start('BOT_TOKEN')\r\n\r\nif __name__ == \"__main__\":\r\n    asyncio.run(main())\r\n```\r\n\r\n\r\n### Cog example\r\n```python\r\nfrom typing import Dict\r\nfrom discord.ext import commands, ipc\r\nfrom discord.ext.ipc.server import Server\r\nfrom discord.ext.ipc.errors import IPCError\r\nfrom discord.ext.ipc.objects import ClientPayload\r\n\r\nclass Routes(commands.Cog):\r\n    def __init__(self, bot: commands.Bot):\r\n        self.bot = bot\r\n        if not hasattr(bot, \"ipc\"):\r\n            bot.ipc = ipc.Server(self.bot, secret_key=\"\ud83d\udc3c\")\r\n    \r\n    async def cog_load(self):\r\n        await self.bot.ipc.start()\r\n\r\n    async def cog_unload(self):\r\n        await self.bot.ipc.stop()\r\n        self.bot.ipc = None\r\n\r\n    @Server.route()\r\n    async def get_user_data(self, data: ClientPayload):\r\n        user = self.bot.get_user(int(data.user_id))\r\n        return user._to_minimal_user_json()\r\n\r\nasync def setup(bot):\r\n    await bot.add_cog(Routes(bot))\r\n```\r\n\r\n\r\n### Inside your web application\r\n```python\r\nfrom quart import Quart\r\nfrom discord.ext.ipc import Client\r\n\r\napp = Quart(__name__)\r\nipc = Client(secret_key=\"\ud83d\udc3c\")\r\n\r\n@app.route('/user/<user>')\r\nasync def main(user):\r\n    resp = await ipc.request(\"get_user_data\", user_id=user)\r\n    return str(resp.response)\r\n\r\nif __name__ == '__main__':\r\n    app.run()\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "A high-performance inter-process communication library designed to work with the latest version of py-cord",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://github.com/sampathgujarathi/pycord-ipc",
        "Source": "https://github.com/sampathgujarathi/pycord-ipc"
    },
    "split_keywords": [
        "pycord-ipc",
        "ipc",
        "python",
        "py-cord"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "253c82b6afe2ef09c0bfb648b097200db99b71011f09e8173bd3aa7ee1a95177",
                "md5": "b6d5b29da92bbd5fc61e6be564a07d7d",
                "sha256": "a2fff8a731822392b777ed43c157a644baa8b225d82758b6b0a9c866fc8c906b"
            },
            "downloads": -1,
            "filename": "pycord_ipc-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b6d5b29da92bbd5fc61e6be564a07d7d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.0",
            "size": 9158,
            "upload_time": "2023-10-25T06:20:44",
            "upload_time_iso_8601": "2023-10-25T06:20:44.987359Z",
            "url": "https://files.pythonhosted.org/packages/25/3c/82b6afe2ef09c0bfb648b097200db99b71011f09e8173bd3aa7ee1a95177/pycord_ipc-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0f932982891f3dffb623beee48e7aabeb2e258fcf0654bbbe4f7dd9c30c08c63",
                "md5": "9664970e8f4c00555df4692d80d6adb5",
                "sha256": "7c13c0fe461106292ea7b7f3c1aef5eecc8ef6c21e8040821f6d5bd558b3beb5"
            },
            "downloads": -1,
            "filename": "Pycord_IPC-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9664970e8f4c00555df4692d80d6adb5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.0",
            "size": 9164,
            "upload_time": "2023-10-25T06:22:49",
            "upload_time_iso_8601": "2023-10-25T06:22:49.227084Z",
            "url": "https://files.pythonhosted.org/packages/0f/93/2982891f3dffb623beee48e7aabeb2e258fcf0654bbbe4f7dd9c30c08c63/Pycord_IPC-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b039ab6f5f619597bd3e2c5548c353a8f87c1ff8be94c66fd10498de280ae944",
                "md5": "ee56b999ec292e504344463f9960c457",
                "sha256": "08c8c2c6c54c6ea9f2f349b5214ca93caa550537eadb895097a54f897e479937"
            },
            "downloads": -1,
            "filename": "Pycord-IPC-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ee56b999ec292e504344463f9960c457",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.0",
            "size": 7957,
            "upload_time": "2023-10-25T06:22:50",
            "upload_time_iso_8601": "2023-10-25T06:22:50.579152Z",
            "url": "https://files.pythonhosted.org/packages/b0/39/ab6f5f619597bd3e2c5548c353a8f87c1ff8be94c66fd10498de280ae944/Pycord-IPC-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-25 06:22:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sampathgujarathi",
    "github_project": "pycord-ipc",
    "github_not_found": true,
    "lcname": "pycord-ipc"
}
        
Elapsed time: 0.12676s