ninjabot
ninjabot copied to clipboard
Telegram `/stop` is not working
Telegram's command /stop
is not working. We define the logic here:
https://github.com/rodrigo-brito/ninjabot/blob/1a3585bedbaf66ba35e9377635877aa688e5a1e0/order/controller.go#L293-L300
The idea is:
- The bot will only execute orders when it is in
running
status. But it is not working.
@rodrigo-brito rough guess, but could it be that the c.finish
case is not prioritised over ticker.C
?
func (c *Controller) Start() {
if c.status != StatusRunning {
c.status = StatusRunning
go func() {
ticker := time.NewTicker(c.tickerInterval)
for {
select {
case <-ticker.C:
c.updateOrders()
case <-c.finish:
ticker.Stop()
return
}
}
}()
log.Info("Bot started.")
}
}
Hi @ngqinzhe, thanks for the suggestion.
I don't know. It is inside an infinite loop, if we have the signal of c.finish
together with ticker.C
, it will run ticker.C, but in the next iteration it will execute c.finish
.
It can be replaced by this feature: https://github.com/rodrigo-brito/ninjabot/issues/131
This ticker
is a workaround to update pending orders.