interact: use RemoveKeyboard from interact.KeyboardController

This commit is contained in:
c9s 2022-01-23 14:13:47 +08:00
parent ef84742eb7
commit 7b572120a1
3 changed files with 14 additions and 7 deletions

View File

@ -92,12 +92,15 @@ func (m *PositionInteraction) Commands(i *interact.Interact) {
case "yes": case "yes":
m.closePositionTask.confirmed = true m.closePositionTask.confirmed = true
reply.Message(fmt.Sprintf("Your %s position is closed", m.closePositionTask.symbol)) reply.Message(fmt.Sprintf("Your %s position is closed", m.closePositionTask.symbol))
reply.RemoveKeyboard()
default: default:
} }
// call position close // call position close
if kc, ok := reply.(interact.KeyboardController); ok {
kc.RemoveKeyboard()
}
// reply result // reply result
return nil return nil

View File

@ -127,7 +127,10 @@ func (it *CoreInteraction) Commands(i *interact.Interact) {
} }
} }
reply.RemoveKeyboard() if kc, ok := reply.(interact.KeyboardController) ; ok {
kc.RemoveKeyboard()
}
return nil return nil
}) })
@ -172,7 +175,9 @@ func (it *CoreInteraction) Commands(i *interact.Interact) {
if position.Base == 0 { if position.Base == 0 {
reply.Message("No opened position") reply.Message("No opened position")
reply.RemoveKeyboard() if kc, ok := reply.(interact.KeyboardController) ; ok {
kc.RemoveKeyboard()
}
return fmt.Errorf("no opened position") return fmt.Errorf("no opened position")
} }
} }
@ -191,7 +196,9 @@ func (it *CoreInteraction) Commands(i *interact.Interact) {
return err return err
} }
reply.RemoveKeyboard() if kc, ok := reply.(interact.KeyboardController) ; ok {
kc.RemoveKeyboard()
}
err = it.closePositionContext.closer.ClosePosition(context.Background(), percentage) err = it.closePositionContext.closer.ClosePosition(context.Background(), percentage)
if err != nil { if err != nil {

View File

@ -41,9 +41,6 @@ type Reply interface {
// Choose(prompt string, options ...Option) // Choose(prompt string, options ...Option)
// Confirm shows the confirm dialog or confirm button in the user interface // Confirm shows the confirm dialog or confirm button in the user interface
// Confirm(prompt string) // Confirm(prompt string)
// RemoveKeyboard hides the keyboard from the client user interface
RemoveKeyboard()
} }
// KeyboardController is used when messenger supports keyboard controls // KeyboardController is used when messenger supports keyboard controls