Edoruin commited on
Commit
aed5249
·
1 Parent(s): b1bc7d6

solving ERR_Conection

Browse files
Files changed (1) hide show
  1. app/main.py +13 -7
app/main.py CHANGED
@@ -62,10 +62,13 @@ def main(page: ft.Page):
62
  GIT_GROUP = os.getenv("GITLAB_GROUP_ID")
63
 
64
  # --- CONFIGURACIÓN DE PROXY PARA TODO EL BOT ---
65
- if TG_TOKEN:
66
- # Redirigimos todas las llamadas de la librería al Proxy de Google
67
- # Importante: El script de Google debe ser capaz de procesar el PATH o el TOKEN
68
- telebot.apihelper.API_URL = GOOGLE_PROXY_URL + "?path={1}&token={0}"
 
 
 
69
 
70
  # Inicializar bot
71
  bot = telebot.TeleBot(TG_TOKEN) if TG_TOKEN else None
@@ -86,12 +89,15 @@ def main(page: ft.Page):
86
  markup.add(btn_aceptar, btn_declinar)
87
 
88
  try:
89
- # Ahora bot.send_message usará automáticamente el Proxy de Google
90
  bot.send_message(TG_CHAT_ID, mensaje, reply_markup=markup, parse_mode="Markdown")
91
  return "OK"
92
  except Exception as e:
93
- print(f"Error enviando via Bot: {e}")
94
- return "ERR_CONN"
 
 
 
 
95
 
96
  # --- BOT CALLBACK HANDLER ---
97
  if bot:
 
62
  GIT_GROUP = os.getenv("GITLAB_GROUP_ID")
63
 
64
  # --- CONFIGURACIÓN DE PROXY PARA TODO EL BOT ---
65
+ if TG_TOKEN and GOOGLE_PROXY_URL:
66
+ # Asegurarnos de que el formato sea correcto
67
+ base_url = GOOGLE_PROXY_URL.split('?')[0] # Limpiar parámetros previos
68
+ telebot.apihelper.API_URL = base_url + "?path={1}&token={0}"
69
+ # Aumentar timeouts para Google Apps Script (que a veces es lento)
70
+ telebot.apihelper.CONNECT_TIMEOUT = 30
71
+ telebot.apihelper.READ_TIMEOUT = 30
72
 
73
  # Inicializar bot
74
  bot = telebot.TeleBot(TG_TOKEN) if TG_TOKEN else None
 
89
  markup.add(btn_aceptar, btn_declinar)
90
 
91
  try:
 
92
  bot.send_message(TG_CHAT_ID, mensaje, reply_markup=markup, parse_mode="Markdown")
93
  return "OK"
94
  except Exception as e:
95
+ error_msg = str(e)
96
+ print(f"Error detallado: {error_msg}")
97
+ # Si el error contiene 'Max retries', es un problema de red real
98
+ if "Max retries" in error_msg:
99
+ return f"ERR_DNS: {error_msg[:50]}"
100
+ return f"ERR_CONN: {error_msg[:100]}"
101
 
102
  # --- BOT CALLBACK HANDLER ---
103
  if bot: