| | import os |
| | import threading |
| | import telebot |
| | import gradio as gr |
| |
|
| | |
| | TOKEN = os.environ.get("TELEGRAM_TOKEN") |
| | print(f"STATUS DO TOKEN: {'Encontrado' if TOKEN else 'NÃO ENCONTRADO'}") |
| |
|
| | |
| | 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() |
| | bot.infinity_polling() |
| | except Exception as e: |
| | print(f"ERRO CRÍTICO NO TELEGRAM: {e}") |
| |
|
| | |
| | threading.Thread(target=runner, daemon=True).start() |
| | else: |
| | print("ERRO: Configure o Secret TELEGRAM_TOKEN nas Settings.") |
| |
|
| | |
| | def greet(name): |
| | return "Olá " + name |
| |
|
| | if __name__ == "__main__": |
| | iface = gr.Interface(fn=greet, inputs="text", outputs="text") |
| | iface.launch() |