refactor
This commit is contained in:
@@ -103,6 +103,11 @@ func (b *Bot) SetState(s State, mode RenderMode) {
|
||||
Str("mode", fmt.Sprintf("%v", mode)).
|
||||
Msg("State transition")
|
||||
|
||||
// Вызываем Exit() у старого состояния для cleanup (например, отмены горутин)
|
||||
if b.CurrentState != nil {
|
||||
b.CurrentState.Exit()
|
||||
}
|
||||
|
||||
b.CurrentState = s
|
||||
|
||||
if b.exec != nil {
|
||||
|
||||
@@ -14,6 +14,7 @@ type State interface {
|
||||
HandleCallback(*Bot, *echotron.Update)
|
||||
HandleMessage(*Bot, *echotron.Update)
|
||||
Handle(*Bot, *echotron.Update)
|
||||
Exit() // Вызывается при выходе из состояния для cleanup (например, отмены горутин)
|
||||
}
|
||||
|
||||
type Session struct {
|
||||
|
||||
Reference in New Issue
Block a user