-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go
62 lines (55 loc) · 1.45 KB
/
types.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package main
import (
"github.com/go-telegram-bot-api/telegram-bot-api"
)
// Store is an interface for the persistent storage
// should allow easier swapping of databases
type Store interface {
Close()
AddMsgToPoll(pollid int, messageid int, chatid int64) error
AddInlineMsgToPoll(pollid int, inlinemessageid string) error
RemoveInlineMsg(inlinemessageid string) error
GetPoll(pollid int) (*poll, error)
GetUser(userid int) (*tgbotapi.User, error)
GetPollsByUser(userid int) ([]*poll, error)
GetPollID(messageid int) (int, error)
GetPollNewer(pollid int, userid int) (*poll, error)
GetPollOlder(pollid int, userid int) (*poll, error)
GetAllPollMsg(pollid int) ([]pollident, error)
GetAllPollInlineMsg(pollid int) ([]pollident, error)
GetState(userid int) (state int, pollid int, err error)
SaveState(userid int, pollid int, state int) error
SaveUser(*tgbotapi.User) error
SavePoll(*poll) (int, error)
SaveOptions([]option) error
SaveAnswer(*poll, answer) (unvoted bool, err error)
}
type answer struct {
ID int
PollID int
UserID int
OptionID int
}
type option struct {
ID int
PollID int
Text string
Ctr int
}
type poll struct {
ID int
MessageID int
UserID int
Question string
Inactive int
Private int
Type int
Options []option
Answers []answer
}
func isInactive(poll *poll) bool {
return poll.Inactive == inactive
}
func isMultipleChoice(poll *poll) bool {
return poll.Type == multipleChoice
}