-
Notifications
You must be signed in to change notification settings - Fork 1
/
states.go
35 lines (29 loc) Β· 940 Bytes
/
states.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package states
import (
"github.com/botscommunity/vkgo/api"
"github.com/botscommunity/vkgo/internal/pkg/responses"
"github.com/botscommunity/vkgo/scene"
"github.com/botscommunity/vkgo/update"
)
type Messages struct {
TS any `json:"ts,omitempty"`
Updates [][]any `json:"updates,omitempty"`
Failed int `json:"failed,omitempty"`
MaxVersion int `json:"max_version"`
MinVersion int `json:"min_version"`
}
type state func(bot *api.Bot, session *responses.LongPollServer, messages Messages, scenes scene.Scenes) update.Updates
func ExecuteState(bot *api.Bot, session *responses.LongPollServer, messages Messages, scenes scene.Scenes) update.Updates {
states := map[int]state{
0: standard,
1: outdated,
2: expired,
3: lost,
4: invalid,
}
updates := update.Updates{}
if state := states[updates.Failed]; state != nil {
updates = state(bot, session, messages, scenes)
}
return updates
}