-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoption.go
69 lines (60 loc) · 1.24 KB
/
option.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
63
64
65
66
67
68
69
package gbot
type Option func(*option)
type option struct {
path string
server ServerConf
download DownloadConf
console ConsoleConf
session string
}
type ServerConf struct {
status bool
ip string
port int
}
type DownloadConf struct {
Image bool
Voice bool
Video bool
Emoticon bool
File bool
EmoticonPath string //' => $path.'emoticons',
}
type ConsoleConf struct {
output bool // 是否输出
message bool // 是否输出接收消息 (若上面为 false 此处无效)
}
func WithPath(path string) Option {
return func(o *option) {
o.path = path
}
}
func WithServer(ip string, port int, status bool) Option {
return func(o *option) {
o.server = ServerConf{
status: status,
ip: ip,
port: port,
}
}
}
func WithDownload(image, voice, video, emoticon, file bool, EmoticonPath string) Option {
return func(o *option) {
o.download = DownloadConf{
Image: image,
Voice: voice,
Video: video,
Emoticon: emoticon,
File: file,
EmoticonPath: o.path + EmoticonPath,
}
}
}
func WithConsole(output, message bool) Option {
return func(o *option) {
o.console = ConsoleConf{
output: output,
message: message,
}
}
}