From fef6cc7c9df07f965f90591b3143ffd0a1d5c9cb Mon Sep 17 00:00:00 2001 From: liyp Date: Tue, 2 Jul 2024 13:21:29 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8D=E6=9D=83=E9=99=90?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E9=97=AE=E9=A2=98=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?Master=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test.go | 2 +- utils/router.go | 3 +++ workers/ai.go | 6 +++--- workers/core.go | 2 ++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/test/test.go b/test/test.go index 0d1618e..0deeb30 100644 --- a/test/test.go +++ b/test/test.go @@ -22,7 +22,7 @@ func main() { } parms := strings.Fields(raw_msg) - worker := workers.NewWorker(parms, "794508986", "111", "111", "222", raw_msg) + worker := workers.NewWorker(parms, "794508986", "874769998", "111", "222", raw_msg) fmt.Println("TestPermission:", worker.CheckPermission()) message := worker.GetMsg() fmt.Println("message:", message) diff --git a/utils/router.go b/utils/router.go index 2bc834e..e105e00 100644 --- a/utils/router.go +++ b/utils/router.go @@ -37,9 +37,12 @@ func Router(data map[string]interface{}) { // ans := NewStdAns(parms[0], fmt.Sprintf("%d", int(uid)), fmt.Sprintf("%d", int(gid)), role, fmt.Sprintf("%d", int(mid)), raw_msg) message := worker.CheckPermission() if message == "ok" { + message = worker.GetMsg() worker.SendMsg(message) + } else { + println("权限校验失败") } } diff --git a/workers/ai.go b/workers/ai.go index 1f2f32a..e5f42ed 100644 --- a/workers/ai.go +++ b/workers/ai.go @@ -86,7 +86,7 @@ func (a *AI) GetMsg() string { } if len(a.Parms) > 3 && strings.ToLower(a.Parms[2]) == "set" { // 判断允许设置权限,需要AllowUser和发消息用户账号相同 - if a.AllowUser != nil && contains(a.AllowUser, a.UID) { + if a.Master != nil && contains(a.Master, a.UID) { if contains(models, a.Parms[3]) { cfg["MODEL"] = a.Parms[3] msg = "已设置模型为 " + a.Parms[3] @@ -116,8 +116,8 @@ func (a *AI) GetMsg() string { PROMPT = "" } // PROMPT = "" - println("PROMPT:", PROMPT) - println("ask:", ask) + // println("PROMPT:", PROMPT) + // println("ask:", ask) requestBody := map[string]interface{}{ "model": MODEL, "stream": false, diff --git a/workers/core.go b/workers/core.go index 6d341ce..0f6a188 100644 --- a/workers/core.go +++ b/workers/core.go @@ -14,6 +14,7 @@ type StdAns struct { AllowRole []interface{} BlockGroup []interface{} BlockUser []interface{} + Master []interface{} GroupNotAllow string UserNotAllow string RoleNotAllow string @@ -47,6 +48,7 @@ func NewStdAns(parms []string, uid, gid, role, mid, rawMsg string) *StdAns { AllowRole: cfg["AllowRole"].([]interface{}), BlockGroup: cfg["BlockGroup"].([]interface{}), BlockUser: cfg["BlockUser"].([]interface{}), + Master: cfg["Master"].([]interface{}), GroupNotAllow: "汝所在的群组不被允许这样命令咱呢.", UserNotAllow: "汝不被允许呢.", RoleNotAllow: "汝的角色不被允许哦.",