Update notebook and add telegram debug tools
Changes: - Notebook updated with latest telegram bot integration - Trade performance data updated - Added debug_telegram_bot.md - troubleshooting guide - Added test_telegram_bot.py - standalone test bot Note: Telegram Bot now working with fixes applied
This commit is contained in:
1 parent
d6ecc7605b
commit
d3a426edf4
4 files changed
+3258
-89
No files matched your search
@@ -0,0 +1,112 @@
|
||||
#!/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")
|
||||
Reference in new issue
Block a user