StrideBot is a production-oriented Telegram assistant for crypto and macro market intelligence. It combines real-time market data, AI-generated analysis, watchlists, alerts, premium subscriptions, coupon workflows, scheduled channel publishing, and an HTTP dashboard/health API.
- What StrideBot Does
- Core Capabilities
- Architecture
- Project Structure
- Requirements
- Configuration
- Run Locally
- Telegram Commands
- HTTP Health + Dashboard API
- Data Storage
- Background Jobs and Channel Posting
- Operational Notes
- Testing
- Troubleshooting
StrideBot is designed to be more than a simple “/price” bot:
- Handles free, premium, and admin user flows.
- Provides AI responses, analysis, and summaries.
- Tracks user conversation history and preferences.
- Supports price alerts and personal watchlists.
- Exposes web endpoints for live stats, rates, and status.
- Runs scheduler-driven content workflows for channel intelligence posts.
/price,/top10,/marketupdatefor market snapshots./analysis,/summary,/forexanalysis,/polymarketfor AI-assisted market interpretation./watch,/watchlist,/unwatchfor tracked assets./alert,/myalerts,/cancelalertfor alerting./news,/rates,/forex,/stockfor cross-asset information.
- Premium command scopes and plan gating.
- Telegram Stars payment support and payment record tracking.
- Coupon creation + redemption workflows.
- Broadcast and user-management commands.
- Persistent analytics and audit logging.
- Health/dashboard HTTP service with multiple JSON endpoints.
- Sentry integration, structured logging, and graceful process termination behavior.
StrideBot is a Python application centered around python-telegram-bot:
bot/bot.pyinitializes environment, logging, signal handlers, Telegram app, command scopes, middleware, scheduler, and health server.bot/handlers/contains command and interaction handlers split by domain (core,market,alerts,premium,admin).bot/ai.pyand prompt modules (bot/prompts/*.py) drive model responses and formatting.bot/crypto.py,bot/news_sources.py, and related modules fetch market/news signals.bot/scheduler.pygenerates recurring channel intelligence posts and breaking-news workflows.bot/health.pyruns an HTTP server for dashboard and monitoring endpoints.bot/database.pyprovides DB initialization and persistence functions with Postgres-first + SQLite fallback.
bot/
bot.py # Main runtime entrypoint
handlers/
core.py # Shared UX + general command flows
market.py # Market commands
alerts.py # Alert workflows
premium.py # Premium-specific features
admin.py # Admin-only controls
ai/ # AI integration package
client.py # Main response functions
tiers.py # Tier configuration
search.py # Tavily search
pipeline.py # Mode detection + response shaping
context.py # Token budgeting
background.py # Background thinking
core/
config.py # Centralized env var loading
database/ # Domain modules
connection.py # Connection pool
schema.py # DB initialization
users.py, history.py, premium.py, alerts.py, watchlist.py,
predictions.py, memory.py, analytics.py, scheduler_state.py,
security.py, narrative.py, referrals.py
intelligence/ # Market intelligence modules
whale.py # Whale tracking
polymarket.py # Prediction markets
trends.py # Trend detection
market_regime.py # Market regime analysis
news_sources.py # News feeds
providers/ # Provider adapters
protocols.py # Protocol interfaces
adapters/ # GroqAdapter, CryptoAdapter, NewsAdapter
events/ # Event bus system
scheduler/ # Timed posting + automation
prompts/ # Prompt builders by feature
tests/ # All test files
health.py # HTTP health/dashboard APIs
README.md # This file
pyproject.toml # Python project metadata + dependencies
requirements.txt # Pip install requirements
uv.lock # Locked dependency graph
- Python 3.11+
- Telegram bot token
- AI provider/API credentials used by your deployment mode
- Optional: PostgreSQL
DATABASE_URL(otherwise SQLite fallback is used)
Install dependencies (pick one method):
pip install -r requirements.txtor
uv syncCreate a .env file (typically in project root or bot/, depending on your launch context) with at least:
TELEGRAM_BOT_TOKEN=...
ADMIN_USER_ID=...Commonly used variables in this codebase include:
TELEGRAM_BOT_TOKEN– required.ADMIN_USER_ID– required for admin command scope.CHANNEL_ID– optional channel posting target.DATABASE_URL– enables PostgreSQL mode.LOG_LEVEL– defaultINFO.DAILY_AI_CAP– global daily AI request cap.SENTRY_DSN– error monitoring.CMC_API_KEY– optional CoinMarketCap-backed fear/greed source.BOT_USERNAME– optional handler behavior tuning.
Note: The repository includes integrations that rely on additional provider keys depending on which features you actively use (AI/news/market extensions). Ensure all required secrets for your enabled paths are set before production deploys.
From repo root:
python bot/bot.pyAlternative (if your env is under bot/ and you run there):
cd bot
python bot.pyAt runtime, StrideBot starts:
- Telegram long-polling bot.
- Background scheduler jobs.
- HTTP health/dashboard server.
Command availability is tier-based (free/premium/admin). Current command registration in bot/bot.py includes:
/start, /help, /price, /top10, /marketupdate, /analysis, /watch, /polymarket, /unwatch, /watchlist, /alert, /myalerts, /cancelalert, /news, /summary, /premium, /redeem, /forex, /forexanalysis, /rates, /clear, /about
/stock, /myplan (plus premium-extended command descriptions)
/stats, /broadcast, /listusers, /addpremium, /removepremium, /createcoupon, /listcoupons, /testpost, /trending, /approvetrend
bot/health.py exposes operational endpoints for monitoring and front-end dashboard use.
Examples:
/– liveness text response./dashboard– dashboard page./api/health/all– aggregate service health./api/stats– dashboard stats payload./api/prices– multi-asset price snapshot./api/news– latest article feed./api/feargreed– market sentiment value./api/rates– FX rate payload./api/leaderboard– prediction leaderboard./api/prediction/open-price– cached daily BTC open./api/security-log,/api/flags,/api/flags/set– ops/security controls.
The persistence layer supports:
- PostgreSQL when
DATABASE_URLis available andpsycopg2is installed. - SQLite fallback (
stridebot.db) otherwise.
Schema initialization in init_db() includes tables such as:
users,historyalerts,watchlistpremium_users,premium_subscriptionspayment_records,coupons,coupon_redemptionsadmin_audit_log,analyticsscheduler_cooldowns,posted_contentpredictions
Scheduler logic in bot/scheduler.py powers:
- recurring briefing/digest style posts,
- AI-composed market narratives,
- breaking-news trigger detection with cooldown handling,
- generated post-header images (Pillow-based rendering),
- anti-duplicate posting controls via cooldown and content-hash storage.
- SIGTERM/SIGINT are trapped early to ensure fast old-instance shutdown during deploy rollovers.
- Webhooks are proactively cleared to avoid polling/webhook conflicts.
- Logging writes to console and rotating
bot.log. - Global error handler reports non-transient failures and can notify admin chat.
- Message and redeem rate limiting are applied in handlers.
uv run pytest bot/tests/ -vIf your environment lacks optional dependencies or credentials, focus on unit paths that do not require external APIs.
TELEGRAM_BOT_TOKEN is missing: ensure env file is loaded in the same working directory context used to run the bot.- Admin commands unavailable: confirm
ADMIN_USER_IDis set and parseable as integer. - Unexpected SQLite use: set
DATABASE_URLand installpsycopg2. - Polling conflicts: ensure only one active bot process is running for the token.
- Feature responses look degraded: verify external provider keys and network reachability.
If you are extending StrideBot, start with bot/bot.py (startup orchestration), bot/handlers/ (feature routing), and bot/database.py (persistent model).