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: "汝的角色不被允许哦.",