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.
Metadata
Release files for mothership-bot 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mothership_bot-1.0.0.tar.gz | 16.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mothership_bot-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.2 kB
Release files / mothership_bot-1.0.0.tar.gz
| Download URL | mothership_bot-1.0.0.tar.gz |
|---|---|
| Size | 16.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
452e55cdd085459daabfe8f819828af3fc7e802acad25f63f64e7e01eaabb69e
|
|
BLAKE2b-256 checksum How to use checksums |
f01a892a4d51b9c789643640932e78f2f5112d8979beea57a291b9cd41297b3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.5
|
Release files / mothership_bot-1.0.0-py3-none-any.whl
| Download URL | mothership_bot-1.0.0-py3-none-any.whl |
|---|---|
| Size | 18.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
66963abcbf1559f2dd64e0fc9f4a4056c03fcfbf054d23f232178506f8201a4f
|
|
BLAKE2b-256 checksum How to use checksums |
dd19e9ec8678b46a150a1d05773bff9a91a72eddd4bc1b35c32630c67f76ee56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.5
|
Security for mothership-bot 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.