diff --git a/README.md b/README.md index 9da8580..6b06dfd 100644 --- a/README.md +++ b/README.md @@ -7,14 +7,14 @@ [KimigaiiWuyi/GenshinUID](https://github.com/KimigaiiWuyi/GenshinUID) 的核心部分,平台无关,支持 HTTP/WS 形式调用,便于移植到其他平台以及框架。 -目前仍在开发中。 +**🎉[详细文档](https://docs.gsuid.gbots.work/#/)** ## 安装Core 1. git clone gsuid-core本体 ```shell -git clone https://ghproxy.com/https://github.com/Genshin-bots/gsuid-core.git --depth=1 --single-branch +git clone https://ghproxy.com/https://github.com/Genshin-bots/gsuid_core.git --depth=1 --single-branch ``` 2. 安装poetry @@ -26,28 +26,34 @@ pip install poetry 3. 安装所需依赖 ```shell +# cd进入clone好的文件夹内 +cd gsuid_core +# 安装依赖 poetry install ``` -4. 安装所需插件 +4. 安装所需插件(可选) ```shell -# 安装v4 GenshinUID +# cd进入插件文件夹内 cd plugins +# 安装v4 GenshinUID git clone -b v4 https://ghproxy.com/https://github.com/KimigaiiWuyi/GenshinUID.git --depth=1 --single-branch ``` -5. 启动gsuid-core +5. 启动gsuid_core(早柚核心) ```shell # 在gsuid_core/genshin_core文件夹内 poetry run python core.py +# 或者(二选一即可) +poetry run core ``` 6. 链接其他适配端 + 默认core将运行在`localhost:8765`端口上,如有需要可至`config.json`修改。 -+ 在支持的Bot上(例如NoneBot2、HoshinoBot),安装相应适配插件,启动Bot(如果有修改端口,则需要在启动Bot前修改适配插件相应端口),即可自动连接Core端。 ++ 在支持的Bot上(例如NoneBot2、HoshinoBot、ZeroBot、YunZaiBot等),安装相应适配插件,启动Bot(如果有修改端口,则需要在启动Bot前修改适配插件相应端口),即可自动连接Core端。 ## Docker部署Core(可选) @@ -56,7 +62,7 @@ poetry run python core.py 1. git clone gsuid-core本体 ```shell -git clone https://ghproxy.com/https://github.com/Genshin-bots/gsuid-core.git --depth=1 --single-branch +git clone https://ghproxy.com/https://github.com/Genshin-bots/gsuid_core.git --depth=1 --single-branch ``` 2. 安装所需插件 @@ -77,6 +83,40 @@ docker-compose up -d - 默认core将运行在`localhost:8765`端口上,Docker部署必须修改`config.json`,如`0.0.0.0:8765` - 如果Bot(例如NoneBot2、HoshinoBot)也是Docker部署的,Core或其插件更新后,可能需要将Core和Bot的容器都重启才生效 +## 配置文件 + +修改`gsuid_core/gsuid_core/config.json`,参考如下 + +**(注意json不支持`#`,所以不要复制下面的配置到自己的文件中)** + +> { +> "HOST": "localhost", # 如需挂载公网修改为`0.0.0.0` +> "PORT": "8765", # core端口 +> "masters": ["444835641", "111"], # Bot主人,pm为0 +> "superusers": ["123456789"], # 超管,pm为1 +> "sv": { +> "Core管理": { +> "priority": 5, # 某个服务的优先级 +> "enabled": true, # 某个服务是否启动 +> "pm": 1, # 某个服务要求的权限等级 +> "black_list": [], # 某个服务的黑名单 +> "area": "ALL", # 某个服务的触发范围 +> "white_list": [] # 某个服务的白名单 +> }, +> }, +> "log": { +> "level": "DEBUG" # log等级 +> }, +> "command_start": ["/", "*"], # core内所有插件的要求前缀 +> "misfire_grace_time": 90 +> } + +> 黑名单一旦设置,黑名单中的用户ID将无法访问该服务 +> +> 白名单一旦设置,只有白名单的用户ID能访问该服务 +> +> 服务配置可以通过[网页控制台](https://docs.gsuid.gbots.work/#/WebConsole)实时修改, 如果手动修改`config.json`需要**重启** + ## 编写插件 @@ -101,7 +141,9 @@ sv=SV( pm=2, # 权限 0为master,1为superuser,2为群的群主&管理员,3为普通 priority=5, # 整组服务的优先级 enabled=True, # 是否启用 - black_list=[] # 黑名单 + area= 'ALL', # 群聊和私聊均可触发 + black_list=[], # 黑名单 + white_list=[], # 白名单 ) @sv.on_prefix('测试') diff --git a/gsuid_core/utils/database/dal.py b/gsuid_core/utils/database/dal.py index 2d52169..b513cbd 100644 --- a/gsuid_core/utils/database/dal.py +++ b/gsuid_core/utils/database/dal.py @@ -625,9 +625,7 @@ class SQLA: async with self.async_session() as session: async with session.begin(): await self.push_exists(uid) - sql = select(GsPush).where( - GsPush.uid == uid, GsPush.bot_id == self.bot_id - ) + sql = select(GsPush).where(GsPush.uid == uid) result = await session.execute(sql) data = result.scalars().all() return data[0] if len(data) >= 1 else None