Skip to main content

package for building bots that run on multiple platforms, like discord and telegram

Project description

logo with a label 'one bot codebase - multiple platforms'

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

install

install the base library:

pip install wiring

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

pip install wiring[discord] wiring[telegram]

usage example

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())

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

wiring-0.1.2.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

wiring-0.1.2-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

Details for the file wiring-0.1.2.tar.gz.

File metadata

  • Download URL: wiring-0.1.2.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/5.15.0-118-generic

File hashes

Hashes for wiring-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f71e551caa294f04fe082afbedc60175163935e0a0e2586610a3a611cce14db5
MD5 cf7ab5e5a4b005f28b3bdafc8f9dd0cf
BLAKE2b-256 30d9dd9e25d8e1ea77d279dcf2fcafd130416bae845fac25bf43a5b282eec38d

See more details on using hashes here.

File details

Details for the file wiring-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: wiring-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 18.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/5.15.0-118-generic

File hashes

Hashes for wiring-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b879f88469fe7d1397407df9310c8180eb9faa520c0303cb855288103f403c4a
MD5 f9e7ecc788e6c648dc49abccb089bf2f
BLAKE2b-256 365cd758102ab84bc7042642e67a7aa738f3f1f25be05183f108f92677bf4b43

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page