-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbotoptions.go
54 lines (44 loc) · 1022 Bytes
/
botoptions.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
package telebot
import (
"log/slog"
)
type BotOptions struct {
stateStorage UserStateStorage
useStorage UserStorage
getAllUpdates bool
logger *slog.Logger
logRawUpdates bool
apiServerURL *string
onGetUpdateError func(err error) bool
}
func NewOptions() *BotOptions {
return &BotOptions{}
}
func (b *BotOptions) SetStateStorage(ss UserStateStorage) *BotOptions {
b.stateStorage = ss
return b
}
func (b *BotOptions) SetUserStorage(ss UserStorage) *BotOptions {
b.useStorage = ss
return b
}
func (b *BotOptions) GetAllUpdates() *BotOptions {
b.getAllUpdates = true
return b
}
func (b *BotOptions) SetLogger(logger *slog.Logger) *BotOptions {
b.logger = logger
return b
}
func (b *BotOptions) LogRawUpdates() *BotOptions {
b.logRawUpdates = true
return b
}
func (b *BotOptions) SetAPIServerURL(url string) *BotOptions {
b.apiServerURL = &url
return b
}
func (b *BotOptions) OnGetUpdateError(f func(err error) bool) *BotOptions {
b.onGetUpdateError = f
return b
}