Skip to content

whereismyguts/chat_transport_interface

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chat Transport Interface

A Python library providing an abstracted interface for chat transports on platforms such as Telegram and Discord, facilitating cross-platform bot development.

Purpose

This project simplifies integrating bots with multiple messaging services through a common API.

Features

  • Support for Telegram and Discord bots.
  • Environment-based configuration via .env files.
  • Asynchronous runtime with asyncio.
  • Command-line execution options.
  • Basic unit tests.

Installation

  1. Create a virtual environment:
    python -m venv venv

  2. Activate the virtual environment:
    On Windows: venv\Scripts\activate
    On Unix or MacOS: source venv/bin/activate

  3. Install the dependencies:
    pip install -r requirements.txt

  4. Configuration:
    Copy .env.example to .env and fill in your Discord and Telegram bot tokens and chat IDs.

Usage in Code

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

Run from Command Line

To run the Telegram bot:
python chat_base.py --telegram

To run the Discord bot:
python chat_base.py --discord

Run Tests

python -m unittest tests_basics.py

License

MIT

About

Python interface for abstracting chat transports across platforms like Telegram and Discord, enabling unified bot development with configuration and testing support.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages