mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-20 14:30:10 +08:00
fix tts
This commit is contained in:
parent
ed7cef7566
commit
d76a65ec07
@ -178,15 +178,10 @@ func (tts *ttsmode) getAPIKey(ctx *zero.Ctx) string {
|
|||||||
return url.QueryEscape(tts.APIKey)
|
return url.QueryEscape(tts.APIKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tts *ttsmode) setAPIKey(ctx *zero.Ctx, key string) error {
|
func (tts *ttsmode) setAPIKey(m *ctrl.Control[*zero.Ctx], grp int64, key string) error {
|
||||||
gid := ctx.Event.GroupID
|
err := m.Manager.SetExtra(grp, &key)
|
||||||
if gid == 0 {
|
|
||||||
gid = -ctx.Event.UserID
|
|
||||||
}
|
|
||||||
m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
|
|
||||||
err := m.Manager.SetExtra(gid, &key)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("内部错误")
|
return err
|
||||||
}
|
}
|
||||||
tts.APIKey = key
|
tts.APIKey = key
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -27,7 +27,7 @@ func init() { // 插件主体
|
|||||||
"- 设置语音模式[原神人物]\n" +
|
"- 设置语音模式[原神人物]\n" +
|
||||||
"- 设置默认语音模式[原神人物]\n" +
|
"- 设置默认语音模式[原神人物]\n" +
|
||||||
"- 恢复成默认语音模式\n" +
|
"- 恢复成默认语音模式\n" +
|
||||||
"- 设置原神语音 api key xxxxxx (key请加开发群获得)\n" +
|
"- 为群 xxx 设置原神语音 api key xxxxxx (key请加开发群获得)\n" +
|
||||||
"当前适用的原神人物含有以下:\n" + list(soundList[:], 5),
|
"当前适用的原神人物含有以下:\n" + list(soundList[:], 5),
|
||||||
})
|
})
|
||||||
tts := newttsmode()
|
tts := newttsmode()
|
||||||
@ -143,8 +143,9 @@ func init() { // 插件主体
|
|||||||
index := tts.getSoundMode(ctx)
|
index := tts.getSoundMode(ctx)
|
||||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("设置成功,当前为", soundList[index]))
|
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("设置成功,当前为", soundList[index]))
|
||||||
})
|
})
|
||||||
ent.OnRegex(`^设置原神语音\s*api\s*key\s*([0-9a-zA-Z-_]{54}==)$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
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) {
|
||||||
err := tts.setAPIKey(ctx, ctx.State["regex_matched"].([]string)[1])
|
grp, _ := strconv.ParseInt(ctx.State["regex_matched"].([]string)[1], 10, 64)
|
||||||
|
err := tts.setAPIKey(ctx.State["manager"].(*ctrl.Control[*zero.Ctx]), grp, ctx.State["regex_matched"].([]string)[2])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.SendChain(message.Text("ERROR: ", err))
|
ctx.SendChain(message.Text("ERROR: ", err))
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user