160 lines
6.1 KiB
Python
160 lines
6.1 KiB
Python
from typing import Dict, List, Union, Optional
|
|
from datetime import datetime
|
|
|
|
class ResponseFormatter:
|
|
"""Handles formatting of all bot responses"""
|
|
|
|
@staticmethod
|
|
def format_token_analysis(analysis: Dict, tier: str) -> str:
|
|
"""Format token analysis response"""
|
|
sections = []
|
|
|
|
# Header
|
|
sections.append("๐ Token Analysis Report")
|
|
sections.append("=" * 25)
|
|
|
|
# Basic Analysis (All Tiers)
|
|
basic = analysis.get("basic", {})
|
|
sections.extend([
|
|
"๐ Basic Metrics",
|
|
f"โข Price: ${basic.get('price', 'N/A'):,.4f}",
|
|
f"โข 24h Volume: ${basic.get('volume', 'N/A'):,.2f}",
|
|
f"โข Market Cap: ${basic.get('market_cap', 'N/A'):,.2f}",
|
|
""
|
|
])
|
|
|
|
# Advanced Analysis (Pro & Premium)
|
|
if tier in ["pro", "premium"] and "advanced" in analysis:
|
|
advanced = analysis["advanced"]
|
|
sections.extend([
|
|
"๐ Advanced Analysis",
|
|
f"โข Liquidity: ${advanced.get('liquidity', 'N/A'):,.2f}",
|
|
f"โข 24h Change: {advanced.get('price_change', 'N/A')}%",
|
|
"โข Pattern: " + advanced.get('patterns', 'No patterns detected'),
|
|
""
|
|
])
|
|
|
|
# Premium Analysis
|
|
if tier == "premium" and "premium" in analysis:
|
|
premium = analysis["premium"]
|
|
sections.extend([
|
|
"๐ฏ AI Insights",
|
|
f"โข Signal: {premium.get('signals', 'N/A')}",
|
|
f"โข Strength: {premium.get('signal_strength', 'N/A')}",
|
|
f"โข Recommendation: {premium.get('recommendation', 'N/A')}",
|
|
""
|
|
])
|
|
|
|
return "\n".join(sections)
|
|
|
|
@staticmethod
|
|
def format_alert_message(alert: Dict) -> str:
|
|
"""Format price alert message"""
|
|
return (
|
|
"๐จ Price Alert!\n\n"
|
|
f"Token: {alert.get('token_symbol', 'Unknown')}\n"
|
|
f"Price: ${alert.get('current_price', 0):,.4f}\n"
|
|
f"Change: {alert.get('price_change', 0):+.2f}%\n"
|
|
f"Time: {datetime.now().strftime('%Y-%m-%d %H:%M:%S UTC')}"
|
|
)
|
|
|
|
@staticmethod
|
|
def format_subscription_plans(plans: List[Dict], current_tier: str) -> str:
|
|
"""Format subscription plans message"""
|
|
sections = ["๐ฑ Available Subscription Plans\n"]
|
|
|
|
for plan in plans:
|
|
# Plan header
|
|
if plan['tier'] == current_tier:
|
|
sections.append(f"โ
{plan['tier'].upper()} (Current Plan)")
|
|
else:
|
|
sections.append(f"๐ {plan['tier'].upper()}")
|
|
|
|
# Plan details
|
|
sections.extend([
|
|
f"Price: ${plan['price']}/month",
|
|
"Features:"
|
|
])
|
|
|
|
# Plan features
|
|
for feature in plan['features']:
|
|
sections.append(f" โข {feature}")
|
|
sections.append("") # Empty line between plans
|
|
|
|
return "\n".join(sections)
|
|
|
|
@staticmethod
|
|
def format_monitor_status(monitors: List[Dict]) -> str:
|
|
"""Format monitoring status message"""
|
|
if not monitors:
|
|
return "๐ No active monitors. Use /monitor to start tracking tokens!"
|
|
|
|
sections = ["๐ Active Monitors\n"]
|
|
|
|
for monitor in monitors:
|
|
sections.extend([
|
|
f"Token: {monitor.get('symbol', 'Unknown')}",
|
|
f"Price: ${monitor.get('current_price', 0):,.4f}",
|
|
f"Alert Threshold: {monitor.get('alert_threshold', 0)}%",
|
|
f"Started: {monitor.get('start_time', 'Unknown')}\n"
|
|
])
|
|
|
|
return "\n".join(sections)
|
|
|
|
@staticmethod
|
|
def format_error_message(error: str, suggestion: Optional[str] = None) -> str:
|
|
"""Format error message with optional suggestion"""
|
|
message = f"โ Error: {error}"
|
|
if suggestion:
|
|
message += f"\n๐ก Suggestion: {suggestion}"
|
|
return message
|
|
|
|
@staticmethod
|
|
def format_success_message(action: str) -> str:
|
|
"""Format success message"""
|
|
return f"โ
Success: {action}"
|
|
|
|
@staticmethod
|
|
def format_welcome_message(username: str) -> str:
|
|
"""Format welcome message for new users"""
|
|
return (
|
|
f"๐ Welcome {username}!\n\n"
|
|
"I'm your crypto trading assistant. Here's what I can do:\n\n"
|
|
"๐ Token Analysis:\n"
|
|
"โข /analyze <token_address> - Analyze any token\n"
|
|
"โข /monitor <token_address> - Track price changes\n"
|
|
"โข /alerts - View your active alerts\n\n"
|
|
"๐ Account & Settings:\n"
|
|
"โข /subscribe - View subscription plans\n"
|
|
"โข /status - Check your account status\n"
|
|
"โข /help - Get detailed help\n\n"
|
|
"Start with /analyze to check your first token!"
|
|
)
|
|
|
|
@staticmethod
|
|
def format_help_message() -> str:
|
|
"""Format help message"""
|
|
return (
|
|
"๐ Command Reference\n\n"
|
|
"Analysis Commands:\n"
|
|
"โข /analyze <token> - Get token analysis\n"
|
|
"โข /monitor <token> - Start price tracking\n"
|
|
"โข /alerts - View active alerts\n\n"
|
|
"Account Commands:\n"
|
|
"โข /subscribe - View/change subscription\n"
|
|
"โข /status - Account status\n"
|
|
"โข /settings - Bot settings\n\n"
|
|
"Need help? Contact @support"
|
|
)
|
|
|
|
@staticmethod
|
|
def format_status_message(user_data: Dict) -> str:
|
|
"""Format user status message"""
|
|
return (
|
|
"๐ Your Account Status\n\n"
|
|
f"Plan: {user_data.get('tier', 'Free')}\n"
|
|
f"Analyses Today: {user_data.get('analyses_today', 0)}/{user_data.get('daily_limit', 3)}\n"
|
|
f"Active Monitors: {user_data.get('active_monitors', 0)}/{user_data.get('monitor_limit', 1)}\n"
|
|
f"Member Since: {user_data.get('joined_date', 'Unknown')}\n\n"
|
|
"Use /subscribe to upgrade your plan!"
|
|
) |