Overview
MilesONerd AI Bot provides three core commands for user interaction. All commands are implemented as asynchronous handlers in thebot.py module.
Commands
/start
Initiates interaction with the bot and displays a welcome message. Handler Function:start() (bot.py:21-28)
Response:
- Personalizes greeting with user’s Telegram name
- Uses HTML formatting for mentions
- Introduces the bot’s capabilities
- Directs users to help command
/help
Displays comprehensive help information about bot capabilities and commands. Handler Function:help_command() (bot.py:30-47)
Response:
- Command List: All available bot commands
- Message Handling: How the bot processes different types of messages
- Features: Special keywords and capabilities
/about
Provides information about the bot’s features and technology stack. Handler Function:about_command() (bot.py:49-62)
Response:
- Bot Description: Overview of capabilities
- Key Features:
- Advanced language understanding
- Internet search integration
- Continuous learning from interactions
- Multiple AI models for different tasks
- Technology: python-telegram-bot and Hugging Face models
Message Handling
In addition to commands, the bot processes regular text messages intelligently. Handler Function:handle_message() (bot.py:64-114)
Message Routing
The bot routes messages to different AI models based on content:1. Long Messages (>100 words)
Processing:- BART model summarizes the message
- Llama generates response based on summary
- Max response length: 200 tokens
2. Summarization Requests
Keywords:summarize, summary, tldr
Processing:
- BART model generates summary
- Direct summarization without additional response
3. Chat/Conversation Queries
Keywords:chat, conversation, talk
Processing:
- Llama model for conversational responses
- Max response length: 200 tokens
4. Short Queries (Less Than 10 Words)
Processing:- Llama model for quick responses
- Max response length: 100 tokens
5. Regular Messages
Processing:- Llama model for comprehensive responses
- Max response length: 150 tokens
- Default handler for messages that don’t match other categories
Command Implementation
All commands are registered in themain() function:
CommandHandler: For/commandpatternsMessageHandler: For regular text messages (excludes commands)
filters.TEXT: Only processes text messages~filters.COMMAND: Excludes messages starting with/
Error Handling
All command handlers include error handling:- Logs errors for debugging
- Sends user-friendly error messages
- Prevents bot crashes from uncaught exceptions
- Shows typing indicator during processing
User Experience Features
Typing Indicator
The bot shows a “typing…” indicator while processing messages:HTML Formatting
The/start command uses HTML formatting for personalized mentions:
