#!/usr/bin/env python3 """ πŸ§ͺ TEST TELEGRAM BOT - Without MT5 dependency Testet ob Telegram Bot grundsΓ€tzlich funktioniert """ import asyncio from datetime import datetime from telegram import Update from telegram.ext import Application, CommandHandler, ContextTypes import json # Load config with open('telegram_config.json', 'r') as f: config = json.load(f) bot_token = config['bot_token'] chat_id = config['chat_id'] print("="*70) print("πŸ§ͺ TELEGRAM BOT TEST") print("="*70) print(f"Bot Token: {bot_token[:20]}...") print(f"Chat ID: {chat_id}") print() # Simple command handlers (no MT5 required) async def cmd_start(update: Update, context: ContextTypes.DEFAULT_TYPE): """Handle /start""" message = ( "πŸ€– *Telegram Bot Test*\n\n" "βœ… Bot is running!\n\n" "Send /help to see commands" ) await update.message.reply_text(message, parse_mode='Markdown') async def cmd_help(update: Update, context: ContextTypes.DEFAULT_TYPE): """Handle /help""" message = """ πŸ“š *Test Commands* /start - Test bot connection /help - Show this help /ping - Test response /time - Show current time βœ… If you see this, the bot is working! """ await update.message.reply_text(message, parse_mode='Markdown') async def cmd_ping(update: Update, context: ContextTypes.DEFAULT_TYPE): """Handle /ping""" await update.message.reply_text("πŸ“ Pong! Bot is alive! βœ…") async def cmd_time(update: Update, context: ContextTypes.DEFAULT_TYPE): """Handle /time""" now = datetime.now().strftime('%Y-%m-%d %H:%M:%S') await update.message.reply_text(f"πŸ• Current time: {now}") async def main(): """Main function""" print("πŸš€ Creating bot application...") # Create application application = Application.builder().token(bot_token).build() # Add handlers application.add_handler(CommandHandler("start", cmd_start)) application.add_handler(CommandHandler("help", cmd_help)) application.add_handler(CommandHandler("ping", cmd_ping)) application.add_handler(CommandHandler("time", cmd_time)) print("βœ… Handlers registered") print("πŸš€ Starting bot...") print("πŸ“± Go to Telegram and send /help to test") print() # Send startup message await application.bot.send_message( chat_id=chat_id, text="πŸ§ͺ *Test Bot Started*\n\nSend /help to test commands", parse_mode='Markdown' ) # Start polling await application.initialize() await application.start() await application.updater.start_polling() print("βœ… Bot is running!") print("Press Ctrl+C to stop") print() # Keep running try: while True: await asyncio.sleep(1) except KeyboardInterrupt: print("\n⏸️ Stopping bot...") await application.stop() await application.shutdown() if __name__ == "__main__": try: asyncio.run(main()) except KeyboardInterrupt: print("\nβœ… Bot stopped")