mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
bbgo: wrap keyboard removal in defer func
This commit is contained in:
parent
1d1ec12417
commit
b855267604
|
@ -283,6 +283,12 @@ func (it *CoreInteraction) Commands(i *interact.Interact) {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}).Next(func(signature string, reply interact.Reply) error {
|
}).Next(func(signature string, reply interact.Reply) error {
|
||||||
|
defer func() {
|
||||||
|
if kc, ok := reply.(interact.KeyboardController); ok {
|
||||||
|
kc.RemoveKeyboard()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
strategy, ok := it.exchangeStrategies[signature]
|
strategy, ok := it.exchangeStrategies[signature]
|
||||||
if !ok {
|
if !ok {
|
||||||
reply.Message("Strategy not found")
|
reply.Message("Strategy not found")
|
||||||
|
@ -297,10 +303,6 @@ func (it *CoreInteraction) Commands(i *interact.Interact) {
|
||||||
|
|
||||||
status := controller.GetStatus()
|
status := controller.GetStatus()
|
||||||
|
|
||||||
if kc, ok := reply.(interact.KeyboardController); ok {
|
|
||||||
kc.RemoveKeyboard()
|
|
||||||
}
|
|
||||||
|
|
||||||
if status == types.StrategyStatusRunning {
|
if status == types.StrategyStatusRunning {
|
||||||
reply.Message(fmt.Sprintf("Strategy %s is running.", signature))
|
reply.Message(fmt.Sprintf("Strategy %s is running.", signature))
|
||||||
} else if status == types.StrategyStatusStopped {
|
} else if status == types.StrategyStatusStopped {
|
||||||
|
@ -321,6 +323,12 @@ func (it *CoreInteraction) Commands(i *interact.Interact) {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}).Next(func(signature string, reply interact.Reply) error {
|
}).Next(func(signature string, reply interact.Reply) error {
|
||||||
|
defer func() {
|
||||||
|
if kc, ok := reply.(interact.KeyboardController); ok {
|
||||||
|
kc.RemoveKeyboard()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
strategy, ok := it.exchangeStrategies[signature]
|
strategy, ok := it.exchangeStrategies[signature]
|
||||||
if !ok {
|
if !ok {
|
||||||
reply.Message("Strategy not found")
|
reply.Message("Strategy not found")
|
||||||
|
@ -339,16 +347,12 @@ func (it *CoreInteraction) Commands(i *interact.Interact) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if kc, ok := reply.(interact.KeyboardController); ok {
|
|
||||||
kc.RemoveKeyboard()
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := controller.Suspend(); err != nil {
|
if err := controller.Suspend(); err != nil {
|
||||||
reply.Message(fmt.Sprintf("Failed to suspend the strategy, %s", err.Error()))
|
reply.Message(fmt.Sprintf("Failed to suspend the strategy, %s", err.Error()))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
reply.Message(fmt.Sprintf("Strategy %s suspended.", signature))
|
reply.Message(fmt.Sprintf("Strategy %s is now suspended.", signature))
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -363,6 +367,12 @@ func (it *CoreInteraction) Commands(i *interact.Interact) {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}).Next(func(signature string, reply interact.Reply) error {
|
}).Next(func(signature string, reply interact.Reply) error {
|
||||||
|
defer func() {
|
||||||
|
if kc, ok := reply.(interact.KeyboardController); ok {
|
||||||
|
kc.RemoveKeyboard()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
strategy, ok := it.exchangeStrategies[signature]
|
strategy, ok := it.exchangeStrategies[signature]
|
||||||
if !ok {
|
if !ok {
|
||||||
reply.Message("Strategy not found")
|
reply.Message("Strategy not found")
|
||||||
|
@ -381,16 +391,12 @@ func (it *CoreInteraction) Commands(i *interact.Interact) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if kc, ok := reply.(interact.KeyboardController); ok {
|
|
||||||
kc.RemoveKeyboard()
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := controller.Resume(); err != nil {
|
if err := controller.Resume(); err != nil {
|
||||||
reply.Message(fmt.Sprintf("Failed to resume the strategy, %s", err.Error()))
|
reply.Message(fmt.Sprintf("Failed to resume the strategy, %s", err.Error()))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
reply.Message(fmt.Sprintf("Strategy %s resumed.", signature))
|
reply.Message(fmt.Sprintf("Strategy %s is now resumed.", signature))
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user