genshin vits add api key

This commit is contained in:
源文雨
2022-12-03 16:35:14 +08:00
parent a93f4f68b4
commit 82608d01bb
3 changed files with 56 additions and 14 deletions

View File

@@ -16,7 +16,7 @@ import (
const (
jpapi = "https://moegoe.azurewebsites.net/api/speak?text=%s&id=%d"
krapi = "https://moegoe.azurewebsites.net/api/speakkr?text=%s&id=%d"
cnapi = "https://genshin.azurewebsites.net/api/speak?format=mp3&text=%s&id=%d"
cnapi = "https://genshin.azurewebsites.net/api/speak?format=mp3&text=%s&id=%d&code=%s"
)
var speakers = map[string]uint{
@@ -49,6 +49,21 @@ func init() {
Handle(func(ctx *zero.Ctx) {
text := ctx.State["regex_matched"].([]string)[2]
id := speakers[ctx.State["regex_matched"].([]string)[1]]
ctx.SendChain(message.Record(fmt.Sprintf(cnapi, url.QueryEscape(text), id)))
c, ok := control.Lookup("tts")
if !ok {
ctx.SendChain(message.Text("ERROR: plugin tts not found"))
return
}
var key string
gid := ctx.Event.GroupID
if gid == 0 {
gid = -ctx.Event.UserID
}
err := c.Manager.GetExtra(gid, &key)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Record(fmt.Sprintf(cnapi, url.QueryEscape(text), id, key)))
})
}