Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Telegram /stop is not working #122

Open
rodrigo-brito opened this issue Mar 29, 2022 · 2 comments
Open

Telegram /stop is not working #122

rodrigo-brito opened this issue Mar 29, 2022 · 2 comments
Labels
env/telegram good first issue Good for newcomers help wanted Extra attention is needed kind/bug Something isn't working

Comments

@rodrigo-brito
Copy link
Owner

Telegram's command /stop is not working. We define the logic here:

func (c *Controller) Stop() {
if c.status == StatusRunning {
c.status = StatusStopped
c.updateOrders()
c.finish <- true
log.Info("Bot stopped.")
}
}

The idea is:

  • The bot will only execute orders when it is in running status. But it is not working.
@rodrigo-brito rodrigo-brito added kind/bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers env/telegram labels Mar 29, 2022
@rodrigo-brito rodrigo-brito changed the title Telegram stop is not working Telegram /stop is not working Mar 31, 2022
@ngqinzhe
Copy link

ngqinzhe commented Apr 1, 2023

@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.")
	}
}

@rodrigo-brito
Copy link
Owner Author

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: #131
This ticker is a workaround to update pending orders.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
env/telegram good first issue Good for newcomers help wanted Extra attention is needed kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants