codebydante commited on
Commit
b4fc3aa
·
verified ·
1 Parent(s): 75bcc1b

Upload 113 files

Browse files
Files changed (1) hide show
  1. internal/commands/add_token.go +15 -10
internal/commands/add_token.go CHANGED
@@ -83,16 +83,21 @@ func (c *command) HandleBotTokenMessage(d dispatcher.Dispatcher) {
83
  return replyErr
84
  }
85
 
86
- // 2. Add it to the dynamic worker pool
87
- err = StartWorkerFunc(token)
88
- if err != nil {
89
- c.log.Error("Failed to start worker with new token", zap.Error(err))
90
- _, replyErr := ctx.Reply(u, ext.ReplyTextString("⚠️ El token se guardó, pero falló al conectarse a Telegram (¿Token inválido?): "+err.Error()), nil)
91
- return replyErr
92
- }
93
-
94
- _, replyErr := ctx.Reply(u, ext.ReplyTextString("✅ ¡Token verificado y guardado en la base de datos! El bot extra ya está activo en tu servidor."), nil)
95
- return replyErr
 
 
 
 
 
96
 
97
  }), -1) // Group -1 para que atrape los mensajes ANTES que el handler de streams del Group 0
98
  }
 
83
  return replyErr
84
  }
85
 
86
+ // Respond immediately to stop the webhook from retrying and causing duplicates
87
+ _, _ = ctx.Reply(u, ext.ReplyTextString("⏳ El token ha sido guardado exitosamente en Firebase. Conectando al Servidor de Telegram..."), nil)
88
+
89
+ // 2. Add it to the dynamic worker pool in the background
90
+ go func(t string) {
91
+ startErr := StartWorkerFunc(t)
92
+ if startErr != nil {
93
+ c.log.Error("Failed to start worker with new token", zap.Error(startErr))
94
+ _, _ = ctx.Reply(u, ext.ReplyTextString("⚠️ El bot se guardó, pero falló al unirse (¿Token inválido?): "+startErr.Error()), nil)
95
+ } else {
96
+ _, _ = ctx.Reply(u, ext.ReplyTextString("✅ ¡Bot en línea y conectado a la red File Stream satisfactoriamente!"), nil)
97
+ }
98
+ }(token)
99
+
100
+ return nil
101
 
102
  }), -1) // Group -1 para que atrape los mensajes ANTES que el handler de streams del Group 0
103
  }