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 tokenFIREBASE_PROJECT_ID- Optional: Enable persistent storageLOG_LEVEL- Optional: Logging level (debug|info|warn|error)
Documentation
See the main Mothership repository for full documentation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mothership_bot-1.0.0.tar.gz.
File metadata
- Download URL: mothership_bot-1.0.0.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
452e55cdd085459daabfe8f819828af3fc7e802acad25f63f64e7e01eaabb69e
|
|
| MD5 |
0a3ba06dbc8e0ce3503504b7358b7c2e
|
|
| BLAKE2b-256 |
f01a892a4d51b9c789643640932e78f2f5112d8979beea57a291b9cd41297b3a
|
File details
Details for the file mothership_bot-1.0.0-py3-none-any.whl.
File metadata
- Download URL: mothership_bot-1.0.0-py3-none-any.whl
- Upload date:
- Size: 18.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66963abcbf1559f2dd64e0fc9f4a4056c03fcfbf054d23f232178506f8201a4f
|
|
| MD5 |
da8f9b812668f4f9ae757660ecc62c79
|
|
| BLAKE2b-256 |
dd19e9ec8678b46a150a1d05773bff9a91a72eddd4bc1b35c32630c67f76ee56
|