File tree Expand file tree Collapse file tree 2 files changed +7
-11
lines changed Expand file tree Collapse file tree 2 files changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -178,15 +178,10 @@ func (tts *ttsmode) getAPIKey(ctx *zero.Ctx) string {
178
178
return url .QueryEscape (tts .APIKey )
179
179
}
180
180
181
- func (tts * ttsmode ) setAPIKey (ctx * zero.Ctx , key string ) error {
182
- gid := ctx .Event .GroupID
183
- if gid == 0 {
184
- gid = - ctx .Event .UserID
185
- }
186
- m := ctx .State ["manager" ].(* ctrl.Control [* zero.Ctx ])
187
- err := m .Manager .SetExtra (gid , & key )
181
+ func (tts * ttsmode ) setAPIKey (m * ctrl.Control [* zero.Ctx ], grp int64 , key string ) error {
182
+ err := m .Manager .SetExtra (grp , & key )
188
183
if err != nil {
189
- return errors . New ( "内部错误" )
184
+ return err
190
185
}
191
186
tts .APIKey = key
192
187
return nil
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ func init() { // 插件主体
27
27
"- 设置语音模式[原神人物]\n " +
28
28
"- 设置默认语音模式[原神人物]\n " +
29
29
"- 恢复成默认语音模式\n " +
30
- "- 设置原神语音 api key xxxxxx (key请加开发群获得)\n " +
30
+ "- 为群 xxx 设置原神语音 api key xxxxxx (key请加开发群获得)\n " +
31
31
"当前适用的原神人物含有以下:\n " + list (soundList [:], 5 ),
32
32
})
33
33
tts := newttsmode ()
@@ -143,8 +143,9 @@ func init() { // 插件主体
143
143
index := tts .getSoundMode (ctx )
144
144
ctx .SendChain (message .Reply (ctx .Event .MessageID ), message .Text ("设置成功,当前为" , soundList [index ]))
145
145
})
146
- ent .OnRegex (`^设置原神语音\s*api\s*key\s*([0-9a-zA-Z-_]{54}==)$` , zero .OnlyPrivate , zero .SuperUserPermission ).SetBlock (true ).Handle (func (ctx * zero.Ctx ) {
147
- err := tts .setAPIKey (ctx , ctx .State ["regex_matched" ].([]string )[1 ])
146
+ ent .OnRegex (`^为群\s*(-?\d+)\s*设置原神语音\s*api\s*key\s*([0-9a-zA-Z-_]{54}==)$` , zero .OnlyPrivate , zero .SuperUserPermission ).SetBlock (true ).Handle (func (ctx * zero.Ctx ) {
147
+ grp , _ := strconv .ParseInt (ctx .State ["regex_matched" ].([]string )[1 ], 10 , 64 )
148
+ err := tts .setAPIKey (ctx .State ["manager" ].(* ctrl.Control [* zero.Ctx ]), grp , ctx .State ["regex_matched" ].([]string )[2 ])
148
149
if err != nil {
149
150
ctx .SendChain (message .Text ("ERROR: " , err ))
150
151
return
You can’t perform that action at this time.
0 commit comments