A Python library providing an abstracted interface for chat transports on platforms such as Telegram and Discord, facilitating cross-platform bot development.
This project simplifies integrating bots with multiple messaging services through a common API.
- Support for Telegram and Discord bots.
- Environment-based configuration via .env files.
- Asynchronous runtime with asyncio.
- Command-line execution options.
- Basic unit tests.
-
Create a virtual environment:
python -m venv venv -
Activate the virtual environment:
On Windows:venv\Scripts\activate
On Unix or MacOS:source venv/bin/activate -
Install the dependencies:
pip install -r requirements.txt -
Configuration:
Copy.env.exampleto.envand fill in your Discord and Telegram bot tokens and chat IDs.
from chat_base import ChatTransportDiscord, ChatTransportTelegram
# Start polling Telegram bot
transport = ChatTransportTelegram(TELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID)
# Or start polling Discord bot
# transport = ChatTransportDiscord(DISCORD_BOT_TOKEN, DISCORD_CHAT_ID)
# Start the bot
bot = BusinessLogicController(transport)
asyncio.run(bot.run())To run the Telegram bot:
python chat_base.py --telegram
To run the Discord bot:
python chat_base.py --discord
python -m unittest tests_basics.py
MIT