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)
|
||||
|
||||
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)
|
||||
|
|
|
@ -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("权限校验失败")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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: "汝的角色不被允许哦.",
|
||||
|
|
Loading…
Reference in a new issue