150 lines
4.5 KiB
Python
150 lines
4.5 KiB
Python
|
#!/usr/bin/env python3
|
||
|
"""
|
||
|
CLI entry point for Marcus Scambaiter Bot
|
||
|
"""
|
||
|
import argparse
|
||
|
import asyncio
|
||
|
import sys
|
||
|
from pathlib import Path
|
||
|
import os
|
||
|
|
||
|
from .bot import main as bot_main, ScambaiterBot
|
||
|
from .conversation import ConversationAnalyzer
|
||
|
from .persona import load_persona, get_persona_path
|
||
|
|
||
|
|
||
|
def check_env_file():
|
||
|
"""Check if .env file exists and has required variables"""
|
||
|
if not Path(".env").exists():
|
||
|
print("❌ No .env file found!")
|
||
|
print("📝 Please create a .env file with your credentials.")
|
||
|
print("📖 See README.md for setup instructions.")
|
||
|
return False
|
||
|
|
||
|
required_vars = ['TELEGRAM_API_ID', 'TELEGRAM_API_HASH', 'TELEGRAM_PHONE', 'GROK_API_KEY']
|
||
|
missing_vars = []
|
||
|
|
||
|
# Load .env manually to check
|
||
|
try:
|
||
|
with open('.env', 'r') as f:
|
||
|
env_content = f.read()
|
||
|
for var in required_vars:
|
||
|
if f"{var}=" not in env_content:
|
||
|
missing_vars.append(var)
|
||
|
except Exception:
|
||
|
pass
|
||
|
|
||
|
if missing_vars:
|
||
|
print(f"❌ Missing environment variables: {', '.join(missing_vars)}")
|
||
|
print("📝 Please add them to your .env file.")
|
||
|
return False
|
||
|
|
||
|
return True
|
||
|
|
||
|
|
||
|
def show_stats():
|
||
|
"""Show conversation statistics"""
|
||
|
try:
|
||
|
analyzer = ConversationAnalyzer()
|
||
|
stats = analyzer.get_conversation_summary()
|
||
|
|
||
|
print("📊 Marcus Scambaiter Statistics")
|
||
|
print("=" * 40)
|
||
|
print(f"Total scammers engaged: {stats['total_scammers_engaged']}")
|
||
|
print(f"Total messages received: {stats['total_messages_received']}")
|
||
|
print(f"Time wasted (minutes): {stats['total_time_wasted_minutes']:.1f}")
|
||
|
print(f"Average messages per scammer: {stats['average_messages_per_scammer']:.1f}")
|
||
|
|
||
|
if stats['scammer_types']:
|
||
|
print("\nScammer Types Detected:")
|
||
|
for scam_type, count in stats['scammer_types'].items():
|
||
|
print(f" {scam_type}: {count}")
|
||
|
|
||
|
except Exception as e:
|
||
|
print(f"❌ Error reading statistics: {e}")
|
||
|
|
||
|
|
||
|
def show_persona():
|
||
|
"""Show Marcus's persona"""
|
||
|
try:
|
||
|
persona = load_persona()
|
||
|
print("🎭 Marcus's Persona")
|
||
|
print("=" * 40)
|
||
|
print(persona)
|
||
|
except Exception as e:
|
||
|
print(f"❌ Error loading persona: {e}")
|
||
|
|
||
|
|
||
|
def main():
|
||
|
"""Main CLI entry point"""
|
||
|
parser = argparse.ArgumentParser(
|
||
|
description="Marcus - Telegram Scambaiting Bot",
|
||
|
epilog="For more information, visit: https://retoor.molodetz.nl/retoor/"
|
||
|
)
|
||
|
|
||
|
subparsers = parser.add_subparsers(dest='command', help='Available commands')
|
||
|
|
||
|
# Start command
|
||
|
start_parser = subparsers.add_parser('start', help='Start the scambaiting bot')
|
||
|
start_parser.add_argument('--check-only', action='store_true',
|
||
|
help='Only check configuration, don\'t start bot')
|
||
|
|
||
|
# Stats command
|
||
|
subparsers.add_parser('stats', help='Show conversation statistics')
|
||
|
|
||
|
# Persona command
|
||
|
subparsers.add_parser('persona', help='Show Marcus\'s personality')
|
||
|
|
||
|
# Config command
|
||
|
config_parser = subparsers.add_parser('config', help='Configuration utilities')
|
||
|
config_parser.add_argument('--check', action='store_true', help='Check configuration')
|
||
|
|
||
|
args = parser.parse_args()
|
||
|
|
||
|
if not args.command:
|
||
|
parser.print_help()
|
||
|
return
|
||
|
|
||
|
print("🎭 Marcus Scambaiter Bot v1.0.0")
|
||
|
print("By retoor - https://retoor.molodetz.nl/retoor/")
|
||
|
print()
|
||
|
|
||
|
if args.command == 'start':
|
||
|
if not check_env_file():
|
||
|
sys.exit(1)
|
||
|
|
||
|
if args.check_only:
|
||
|
print("✅ Configuration looks good!")
|
||
|
print("🚀 Run 'marcus start' to begin scambaiting!")
|
||
|
return
|
||
|
|
||
|
print("🎯 Starting Marcus...")
|
||
|
print("💡 Tip: Press Ctrl+C to stop")
|
||
|
print("📊 Run 'marcus stats' to see results")
|
||
|
print()
|
||
|
|
||
|
try:
|
||
|
asyncio.run(bot_main())
|
||
|
except KeyboardInterrupt:
|
||
|
print("\n👋 Marcus stopped. Goodbye!")
|
||
|
except Exception as e:
|
||
|
print(f"❌ Error: {e}")
|
||
|
sys.exit(1)
|
||
|
|
||
|
elif args.command == 'stats':
|
||
|
show_stats()
|
||
|
|
||
|
elif args.command == 'persona':
|
||
|
show_persona()
|
||
|
|
||
|
elif args.command == 'config':
|
||
|
if args.check:
|
||
|
if check_env_file():
|
||
|
print("✅ Configuration is valid!")
|
||
|
else:
|
||
|
sys.exit(1)
|
||
|
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
main()
|