mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-02-12 10:10:25 +00:00
fix gs tts
This commit is contained in:
@@ -2,6 +2,7 @@ package aireply
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"sync"
|
||||
|
||||
@@ -131,9 +132,9 @@ func getReplyMode(ctx *zero.Ctx) (name string) {
|
||||
***********************tts************************************
|
||||
*************************************************************/
|
||||
type ttsmode struct {
|
||||
sync.RWMutex
|
||||
apikey string
|
||||
mode map[int64]int64
|
||||
sync.RWMutex `json:"-"`
|
||||
APIKey string
|
||||
mode map[int64]int64
|
||||
}
|
||||
|
||||
func list(list []string, num int) string {
|
||||
@@ -165,8 +166,16 @@ func newttsmode() *ttsmode {
|
||||
return tts
|
||||
}
|
||||
|
||||
func (tts *ttsmode) getAPIKey() string {
|
||||
return tts.apikey
|
||||
func (tts *ttsmode) getAPIKey(ctx *zero.Ctx) string {
|
||||
if tts.APIKey == "" {
|
||||
m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
|
||||
gid := ctx.Event.GroupID
|
||||
if gid == 0 {
|
||||
gid = -ctx.Event.UserID
|
||||
}
|
||||
_ = m.Manager.GetExtra(gid, &tts)
|
||||
}
|
||||
return url.QueryEscape(tts.APIKey)
|
||||
}
|
||||
|
||||
func (tts *ttsmode) setAPIKey(ctx *zero.Ctx, key string) error {
|
||||
@@ -179,7 +188,7 @@ func (tts *ttsmode) setAPIKey(ctx *zero.Ctx, key string) error {
|
||||
if err != nil {
|
||||
return errors.New("内部错误")
|
||||
}
|
||||
tts.apikey = key
|
||||
tts.APIKey = key
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user