14
14
Bot * telego.Bot
15
15
BotUsername string // 没有 @
16
16
ChannelChatID telego.ChatID
17
+ GroupChatID telego.ChatID // 附属群组
17
18
)
18
19
19
20
func InitBot () {
@@ -33,6 +34,10 @@ func InitBot() {
33
34
ChannelChatID = telegoutil .ID (config .Cfg .Telegram .ChatID )
34
35
}
35
36
37
+ if config .Cfg .Telegram .GroupID != 0 {
38
+ GroupChatID = telegoutil .ID (config .Cfg .Telegram .GroupID )
39
+ }
40
+
36
41
me , err := Bot .GetMe ()
37
42
if err != nil {
38
43
Logger .Errorf ("Error when getting bot info: %s" , err )
@@ -111,11 +116,25 @@ func InitBot() {
111
116
},
112
117
}
113
118
114
- Bot .SetMyCommands (& telego.SetMyCommandsParams {
115
- Commands : append (commonCommands , adminCommands ... ),
116
- Scope : & telego.BotCommandScopeChat {
117
- Type : telego .ScopeTypeChat ,
118
- ChatID : telegoutil .ID (config .Cfg .Telegram .Admins [0 ]),
119
- },
120
- })
119
+ adminCommands = append (adminCommands , commonCommands ... )
120
+
121
+ for _ , adminID := range config .Cfg .Telegram .Admins {
122
+ Bot .SetMyCommands (& telego.SetMyCommandsParams {
123
+ Commands : adminCommands ,
124
+ Scope : & telego.BotCommandScopeChat {
125
+ Type : telego .ScopeTypeChat ,
126
+ ChatID : telegoutil .ID (adminID ),
127
+ },
128
+ })
129
+ if config .Cfg .Telegram .GroupID == 0 {
130
+ continue
131
+ }
132
+ Bot .SetMyCommands (& telego.SetMyCommandsParams {
133
+ Commands : adminCommands ,
134
+ Scope : & telego.BotCommandScopeChat {
135
+ Type : telego .ScopeTypeChat ,
136
+ ChatID : telegoutil .ID (adminID ),
137
+ },
138
+ })
139
+ }
121
140
}
0 commit comments