wiring


Namewiring JSON
Version 0.1.2 PyPI version JSON
download
home_pagehttps://github.com/crucials/wiring
Summarypackage for building bots that run on multiple platforms, like discord and telegram
upload_time2024-08-21 08:32:59
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT
keywords wiring discord.py bot python-telegram-bot twitchio
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![logo with a label 'one bot codebase - multiple platforms'](https://i.ibb.co/1QGmCQx/343200157-4b987f42-1718-4a83-83b1-dc5556da28af.png)

seamless api for developing bots that run on multiple platforms.
**discord**, **telegram** and **twitch** are supported

works with asyncio

learn more in the sections below or **[docs](https://github.com/crucials/wiring/wiki)**

## install

install the base library:

```sh
pip install wiring
```

then choose extra dependencies for platforms that you want your bot to run on

```sh
pip install wiring[discord] wiring[telegram]
```

## usage example

```python
import asyncio

from wiring import (Bot, MultiPlatformMessage, MultiPlatformBot, MultiPlatformUser,
                    Command)
from wiring.platforms.discord import DiscordBot
from wiring.platforms.telegram import TelegramBot


DISCORD_TOKEN = 'place your token here or better load it from enviroment variables'
TELEGRAM_TOKEN = 'place your token here or better load it from enviroment variables'

async def send_commands_list(bot: Bot, message: MultiPlatformMessage,
                             args: list[str]):
    commands_list = '\n'.join(['/' + str(command.name) for command
                               in bot.commands])

    await bot.send_message(
        message.chat.id,
        'available commands:\n' + commands_list,
        reply_message_id=message.id
    )


async def start_bots():
    bot = MultiPlatformBot()

    bot.platform_bots = [
        DiscordBot(DISCORD_TOKEN),
        TelegramBot(TELEGRAM_TOKEN)
    ]

    async with bot:
        await bot.setup_commands([
            Command('help', send_commands_list)
        ])

        # blocks the execution
        await bot.listen_to_events()


asyncio.run(start_bots())
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/crucials/wiring",
    "name": "wiring",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "wiring, discord.py, bot, python-telegram-bot, twitchio",
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/30/d9/dd9e25d8e1ea77d279dcf2fcafd130416bae845fac25bf43a5b282eec38d/wiring-0.1.2.tar.gz",
    "platform": null,
    "description": "![logo with a label 'one bot codebase - multiple platforms'](https://i.ibb.co/1QGmCQx/343200157-4b987f42-1718-4a83-83b1-dc5556da28af.png)\n\nseamless api for developing bots that run on multiple platforms.\n**discord**, **telegram** and **twitch** are supported\n\nworks with asyncio\n\nlearn more in the sections below or **[docs](https://github.com/crucials/wiring/wiki)**\n\n## install\n\ninstall the base library:\n\n```sh\npip install wiring\n```\n\nthen choose extra dependencies for platforms that you want your bot to run on\n\n```sh\npip install wiring[discord] wiring[telegram]\n```\n\n## usage example\n\n```python\nimport asyncio\n\nfrom wiring import (Bot, MultiPlatformMessage, MultiPlatformBot, MultiPlatformUser,\n                    Command)\nfrom wiring.platforms.discord import DiscordBot\nfrom wiring.platforms.telegram import TelegramBot\n\n\nDISCORD_TOKEN = 'place your token here or better load it from enviroment variables'\nTELEGRAM_TOKEN = 'place your token here or better load it from enviroment variables'\n\nasync def send_commands_list(bot: Bot, message: MultiPlatformMessage,\n                             args: list[str]):\n    commands_list = '\\n'.join(['/' + str(command.name) for command\n                               in bot.commands])\n\n    await bot.send_message(\n        message.chat.id,\n        'available commands:\\n' + commands_list,\n        reply_message_id=message.id\n    )\n\n\nasync def start_bots():\n    bot = MultiPlatformBot()\n\n    bot.platform_bots = [\n        DiscordBot(DISCORD_TOKEN),\n        TelegramBot(TELEGRAM_TOKEN)\n    ]\n\n    async with bot:\n        await bot.setup_commands([\n            Command('help', send_commands_list)\n        ])\n\n        # blocks the execution\n        await bot.listen_to_events()\n\n\nasyncio.run(start_bots())\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "package for building bots that run on multiple platforms, like discord and telegram",
    "version": "0.1.2",
    "project_urls": {
        "Documentation": "https://github.com/crucials/wiring/wiki",
        "Homepage": "https://github.com/crucials/wiring",
        "Repository": "https://github.com/crucials/wiring",
        "report an issues": "https://github.com/crucials/wiring/issues"
    },
    "split_keywords": [
        "wiring",
        " discord.py",
        " bot",
        " python-telegram-bot",
        " twitchio"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "365cd758102ab84bc7042642e67a7aa738f3f1f25be05183f108f92677bf4b43",
                "md5": "f9e7ecc788e6c648dc49abccb089bf2f",
                "sha256": "b879f88469fe7d1397407df9310c8180eb9faa520c0303cb855288103f403c4a"
            },
            "downloads": -1,
            "filename": "wiring-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f9e7ecc788e6c648dc49abccb089bf2f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 18028,
            "upload_time": "2024-08-21T08:32:57",
            "upload_time_iso_8601": "2024-08-21T08:32:57.859625Z",
            "url": "https://files.pythonhosted.org/packages/36/5c/d758102ab84bc7042642e67a7aa738f3f1f25be05183f108f92677bf4b43/wiring-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "30d9dd9e25d8e1ea77d279dcf2fcafd130416bae845fac25bf43a5b282eec38d",
                "md5": "cf7ab5e5a4b005f28b3bdafc8f9dd0cf",
                "sha256": "f71e551caa294f04fe082afbedc60175163935e0a0e2586610a3a611cce14db5"
            },
            "downloads": -1,
            "filename": "wiring-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "cf7ab5e5a4b005f28b3bdafc8f9dd0cf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 12705,
            "upload_time": "2024-08-21T08:32:59",
            "upload_time_iso_8601": "2024-08-21T08:32:59.355777Z",
            "url": "https://files.pythonhosted.org/packages/30/d9/dd9e25d8e1ea77d279dcf2fcafd130416bae845fac25bf43a5b282eec38d/wiring-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-21 08:32:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "crucials",
    "github_project": "wiring",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "wiring"
}
        
Elapsed time: 0.34298s