fix 修复权限校验问题,添加Master参数
This commit is contained in:
parent
82f93e455b
commit
fef6cc7c9d
4 changed files with 9 additions and 4 deletions
|
@ -22,7 +22,7 @@ func main() {
|
||||||
}
|
}
|
||||||
parms := strings.Fields(raw_msg)
|
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())
|
fmt.Println("TestPermission:", worker.CheckPermission())
|
||||||
message := worker.GetMsg()
|
message := worker.GetMsg()
|
||||||
fmt.Println("message:", message)
|
fmt.Println("message:", message)
|
||||||
|
|
|
@ -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)
|
// 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()
|
message := worker.CheckPermission()
|
||||||
if message == "ok" {
|
if message == "ok" {
|
||||||
|
|
||||||
message = worker.GetMsg()
|
message = worker.GetMsg()
|
||||||
worker.SendMsg(message)
|
worker.SendMsg(message)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
println("权限校验失败")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ func (a *AI) GetMsg() string {
|
||||||
}
|
}
|
||||||
if len(a.Parms) > 3 && strings.ToLower(a.Parms[2]) == "set" {
|
if len(a.Parms) > 3 && strings.ToLower(a.Parms[2]) == "set" {
|
||||||
// 判断允许设置权限,需要AllowUser和发消息用户账号相同
|
// 判断允许设置权限,需要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]) {
|
if contains(models, a.Parms[3]) {
|
||||||
cfg["MODEL"] = a.Parms[3]
|
cfg["MODEL"] = a.Parms[3]
|
||||||
msg = "已设置模型为 " + a.Parms[3]
|
msg = "已设置模型为 " + a.Parms[3]
|
||||||
|
@ -116,8 +116,8 @@ func (a *AI) GetMsg() string {
|
||||||
PROMPT = ""
|
PROMPT = ""
|
||||||
}
|
}
|
||||||
// PROMPT = ""
|
// PROMPT = ""
|
||||||
println("PROMPT:", PROMPT)
|
// println("PROMPT:", PROMPT)
|
||||||
println("ask:", ask)
|
// println("ask:", ask)
|
||||||
requestBody := map[string]interface{}{
|
requestBody := map[string]interface{}{
|
||||||
"model": MODEL,
|
"model": MODEL,
|
||||||
"stream": false,
|
"stream": false,
|
||||||
|
|
|
@ -14,6 +14,7 @@ type StdAns struct {
|
||||||
AllowRole []interface{}
|
AllowRole []interface{}
|
||||||
BlockGroup []interface{}
|
BlockGroup []interface{}
|
||||||
BlockUser []interface{}
|
BlockUser []interface{}
|
||||||
|
Master []interface{}
|
||||||
GroupNotAllow string
|
GroupNotAllow string
|
||||||
UserNotAllow string
|
UserNotAllow string
|
||||||
RoleNotAllow string
|
RoleNotAllow string
|
||||||
|
@ -47,6 +48,7 @@ func NewStdAns(parms []string, uid, gid, role, mid, rawMsg string) *StdAns {
|
||||||
AllowRole: cfg["AllowRole"].([]interface{}),
|
AllowRole: cfg["AllowRole"].([]interface{}),
|
||||||
BlockGroup: cfg["BlockGroup"].([]interface{}),
|
BlockGroup: cfg["BlockGroup"].([]interface{}),
|
||||||
BlockUser: cfg["BlockUser"].([]interface{}),
|
BlockUser: cfg["BlockUser"].([]interface{}),
|
||||||
|
Master: cfg["Master"].([]interface{}),
|
||||||
GroupNotAllow: "汝所在的群组不被允许这样命令咱呢.",
|
GroupNotAllow: "汝所在的群组不被允许这样命令咱呢.",
|
||||||
UserNotAllow: "汝不被允许呢.",
|
UserNotAllow: "汝不被允许呢.",
|
||||||
RoleNotAllow: "汝的角色不被允许哦.",
|
RoleNotAllow: "汝的角色不被允许哦.",
|
||||||
|
|
Loading…
Reference in a new issue