|
@@ -4,7 +4,6 @@ import json |
|
|
import os |
|
|
import os |
|
|
import random |
|
|
import random |
|
|
import string |
|
|
import string |
|
|
import traceback |
|
|
|
|
|
from typing import Tuple |
|
|
from typing import Tuple |
|
|
|
|
|
|
|
|
import plugins |
|
|
import plugins |
|
@@ -12,7 +11,6 @@ from bridge.bridge import Bridge |
|
|
from bridge.context import ContextType |
|
|
from bridge.context import ContextType |
|
|
from bridge.reply import Reply, ReplyType |
|
|
from bridge.reply import Reply, ReplyType |
|
|
from common import const |
|
|
from common import const |
|
|
from common.log import logger |
|
|
|
|
|
from config import conf, load_config, global_config |
|
|
from config import conf, load_config, global_config |
|
|
from plugins import * |
|
|
from plugins import * |
|
|
|
|
|
|
|
@@ -32,6 +30,10 @@ COMMANDS = { |
|
|
"args": ["口令"], |
|
|
"args": ["口令"], |
|
|
"desc": "管理员认证", |
|
|
"desc": "管理员认证", |
|
|
}, |
|
|
}, |
|
|
|
|
|
"model": { |
|
|
|
|
|
"alias": ["model", "模型"], |
|
|
|
|
|
"desc": "查看和设置全局模型", |
|
|
|
|
|
}, |
|
|
"set_openai_api_key": { |
|
|
"set_openai_api_key": { |
|
|
"alias": ["set_openai_api_key"], |
|
|
"alias": ["set_openai_api_key"], |
|
|
"args": ["api_key"], |
|
|
"args": ["api_key"], |
|
@@ -257,6 +259,18 @@ class Godcmd(Plugin): |
|
|
break |
|
|
break |
|
|
if not ok: |
|
|
if not ok: |
|
|
result = "插件不存在或未启用" |
|
|
result = "插件不存在或未启用" |
|
|
|
|
|
elif cmd == "model": |
|
|
|
|
|
if not isadmin and not self.is_admin_in_group(e_context["context"]): |
|
|
|
|
|
ok, result = False, "需要管理员权限执行" |
|
|
|
|
|
elif len(args) == 0: |
|
|
|
|
|
ok, result = True, "当前模型为: " + str(conf().get("model")) |
|
|
|
|
|
elif len(args) == 1: |
|
|
|
|
|
if args[0] not in const.MODEL_LIST: |
|
|
|
|
|
ok, result = False, "模型名称不存在" |
|
|
|
|
|
else: |
|
|
|
|
|
conf()["model"] = args[0] |
|
|
|
|
|
Bridge().reset_bot() |
|
|
|
|
|
ok, result = True, "模型设置为: " + str(conf().get("model")) |
|
|
elif cmd == "id": |
|
|
elif cmd == "id": |
|
|
ok, result = True, user |
|
|
ok, result = True, user |
|
|
elif cmd == "set_openai_api_key": |
|
|
elif cmd == "set_openai_api_key": |
|
@@ -438,3 +452,9 @@ class Godcmd(Plugin): |
|
|
|
|
|
|
|
|
def get_help_text(self, isadmin=False, isgroup=False, **kwargs): |
|
|
def get_help_text(self, isadmin=False, isgroup=False, **kwargs): |
|
|
return get_help_text(isadmin, isgroup) |
|
|
return get_help_text(isadmin, isgroup) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def is_admin_in_group(self, context): |
|
|
|
|
|
if context["isgroup"]: |
|
|
|
|
|
return context.kwargs.get("msg").actual_user_id in global_config["admin_users"] |
|
|
|
|
|
return False |