File size: 1,059 Bytes
5d78239 509a8e2 5d78239 509a8e2 5d78239 509a8e2 5d78239 509a8e2 5d78239 509a8e2 5d78239 509a8e2 5d78239 509a8e2 5d78239 509a8e2 5d78239 509a8e2 53a691b 509a8e2 53a691b 509a8e2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | import os
import threading
import telebot
import gradio as gr
# --- DIAGNÓSTICO ---
TOKEN = os.environ.get("TELEGRAM_TOKEN")
print(f"STATUS DO TOKEN: {'Encontrado' if TOKEN else 'NÃO ENCONTRADO'}")
# --- BOT TELEGRAM SIMPLES ---
if TOKEN:
bot = telebot.TeleBot(TOKEN)
@bot.message_handler(func=lambda m: True)
def echo(message):
bot.reply_to(message, "Teste OK! O servidor está rodando.")
def runner():
print("Tentando iniciar o polling do Telegram...")
try:
bot.remove_webhook() # Garante que não tenha conflito
bot.infinity_polling()
except Exception as e:
print(f"ERRO CRÍTICO NO TELEGRAM: {e}")
# Inicia em background
threading.Thread(target=runner, daemon=True).start()
else:
print("ERRO: Configure o Secret TELEGRAM_TOKEN nas Settings.")
# --- SITE GRADIO (Só para manter o space vivo) ---
def greet(name):
return "Olá " + name
if __name__ == "__main__":
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
iface.launch() |