mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
Merge pull request #946 from c9s/fix/telegram-error
bbgo: fix telegram message error, there must be one message to send
This commit is contained in:
commit
cfeb0ba97b
|
@ -145,16 +145,14 @@ func (it *CoreInteraction) Commands(i *interact.Interact) {
|
||||||
}
|
}
|
||||||
|
|
||||||
position := reader.CurrentPosition()
|
position := reader.CurrentPosition()
|
||||||
if position != nil {
|
if position == nil || position.Base.IsZero() {
|
||||||
reply.Send("Your current position:")
|
reply.Message(fmt.Sprintf("Strategy %q has no opened position", signature))
|
||||||
reply.Send(position.PlainText())
|
return fmt.Errorf("strategy %T has no opened position", strategy)
|
||||||
|
|
||||||
if position.Base.IsZero() {
|
|
||||||
reply.Message(fmt.Sprintf("Strategy %q has no opened position", signature))
|
|
||||||
return fmt.Errorf("strategy %T has no opened position", strategy)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reply.Send("Your current position:")
|
||||||
|
reply.Message(position.PlainText())
|
||||||
|
|
||||||
if kc, ok := reply.(interact.KeyboardController); ok {
|
if kc, ok := reply.(interact.KeyboardController); ok {
|
||||||
kc.RemoveKeyboard()
|
kc.RemoveKeyboard()
|
||||||
}
|
}
|
||||||
|
@ -285,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")
|
||||||
|
@ -299,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 {
|
||||||
|
@ -323,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")
|
||||||
|
@ -341,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
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -365,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")
|
||||||
|
@ -383,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
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,9 @@ func (tm *Telegram) Start(context.Context) {
|
||||||
|
|
||||||
if reply.set {
|
if reply.set {
|
||||||
reply.build()
|
reply.build()
|
||||||
checkSendErr(tm.Bot.Send(m.Chat, reply.message, reply.menu))
|
if len(reply.message) > 0 || reply.menu != nil {
|
||||||
|
checkSendErr(tm.Bot.Send(m.Chat, reply.message, reply.menu))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user