Skip to main content

A minimalist framework for building Telegram bots rapidly

Project description

Mothership - Python Edition

A minimalist framework for building Telegram bots rapidly with clean abstractions and zero boilerplate.

Features

  • Simple Bot Definition: Define bots with minimal code
  • Storage Abstraction: Automatic fallback between Firestore and in-memory storage
  • Flexible Deployment: Support for local (polling), webhooks, and serverless platforms
  • Type-Safe: Full type hints support
  • Structured Logging: Built-in colored, leveled logging
  • Firebase Integration: Optional Firestore persistence

Installation

# Using uv (recommended)
uv pip install mothership-bot

# Or using pip
pip install mothership-bot

Quick Start

1. Create a bot file (bot.py)

from mothership import BotDefinition, Update, ContextTypes, create_logger

logger = create_logger('my-bot')

async def handle_start(update: Update, context: ContextTypes.DEFAULT_TYPE):
    await update.message.reply_text('Hello! I am your bot.')

bot: BotDefinition = {
    'config': {
        'name': 'my-bot',
        'description': 'My awesome bot'
    },
    'commands': [
        {
            'command': 'start',
            'description': 'Start the bot',
            'handler': handle_start
        }
    ]
}

2. Set your bot token

export BOT_TOKEN=your_token_here

3. Run your bot

# Using the CLI
mothership run bot.py

# Or using Python directly
python -c "from mothership.cli import run_bot; import asyncio; asyncio.run(run_bot('bot.py'))"

CLI Usage

The mothership CLI provides an easy way to run and manage your bots:

# Run a bot from a file
mothership run bot.py

# Run a bot from bots directory (looks for bots/ping_bot/__init__.py)
mothership run ping_bot

# Run on a custom port
mothership run ping_bot --port 8080

# List available bots in bots/ directory
mothership list

# Get help
mothership --help

Requirements

  • Python >= 3.8
  • Telegram Bot Token (from @BotFather)

Environment Variables

  • BOT_TOKEN - Required: Telegram bot token
  • FIREBASE_PROJECT_ID - Optional: Enable persistent storage
  • LOG_LEVEL - Optional: Logging level (debug|info|warn|error)

Documentation

See the main Mothership repository for full documentation.

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

mothership_bot-0.0.1.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mothership_bot-0.0.1-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

Details for the file mothership_bot-0.0.1.tar.gz.

File metadata

  • Download URL: mothership_bot-0.0.1.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.5

File hashes

Hashes for mothership_bot-0.0.1.tar.gz
Algorithm Hash digest
SHA256 7f3d3d88b06a1b1450ab2ab4d2de8a9a5ec98650dc9b51b92d024cfe2b379a53
MD5 b8cd46c38df4f81783924e40d83637eb
BLAKE2b-256 3e8df37022a38171ee745127825cec36ee09f48da84bb19b8c1a9cdb626b409a

See more details on using hashes here.

File details

Details for the file mothership_bot-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mothership_bot-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 339bee1fe7bd87b536c3a3dc94b6d30fd7411676b26bc3958c2011a685eb0cd8
MD5 f2263c90696e3f1bcc2fa63b35f3a6cb
BLAKE2b-256 99ac1d156213b9af52c0ed2672caedc713812c83a24705a3d279bba2fa785e9c

See more details on using hashes here.

Supported by

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