mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
修复一些问题
This commit is contained in:
parent
504f78dd49
commit
5f118471cb
2
.gitignore
vendored
2
.gitignore
vendored
@ -159,3 +159,5 @@ resources/
|
|||||||
!/configs/config.yaml
|
!/configs/config.yaml
|
||||||
!/.env
|
!/.env
|
||||||
!/.env.dev
|
!/.env.dev
|
||||||
|
!/plugins/csgo_server/
|
||||||
|
!/plugins/activity/
|
||||||
|
|||||||
@ -279,9 +279,16 @@ PS: **ARM平台** 请使用全量版 同时 **如果你的机器 RAM < 1G 可能
|
|||||||
|
|
||||||
## 更新
|
## 更新
|
||||||
|
|
||||||
|
### 2022/9/16
|
||||||
|
|
||||||
|
* fix: bilibili_sub, azur_draw_card [@pull/1090](https://github.com/HibiKier/zhenxun_bot/pull/1090)
|
||||||
|
* 修复原神资源查询查询完毕后图片存储错误
|
||||||
|
* b站订阅发送 与 b站订阅 使用相同开关,即:关闭b站订阅
|
||||||
|
|
||||||
### 2022/9/10
|
### 2022/9/10
|
||||||
|
|
||||||
* 自定义群欢迎消息参数不完全时提示报错
|
* 自定义群欢迎消息参数不完全时提示报错
|
||||||
|
* 修改bt插件的url地址 [@pull/1067](https://github.com/HibiKier/zhenxun_bot/pull/1067)
|
||||||
|
|
||||||
### 2022/9/8
|
### 2022/9/8
|
||||||
|
|
||||||
|
|||||||
@ -60,7 +60,7 @@ async def _():
|
|||||||
try:
|
try:
|
||||||
await bot.send_group_msg(group_id=g, message="[[_task|zwa]]早上好" + result)
|
await bot.send_group_msg(group_id=g, message="[[_task|zwa]]早上好" + result)
|
||||||
except ActionFailed:
|
except ActionFailed:
|
||||||
logger.warning(f"{g} 群被禁言中,无法发送早安")
|
logger.warning(f"{g} 发送早安失败")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"早晚安错误 e:{e}")
|
logger.error(f"早晚安错误 e:{e}")
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ async def _():
|
|||||||
group_id=g, message=f"[[_task|zwa]]{NICKNAME}要睡觉了,你们也要早点睡呀" + result
|
group_id=g, message=f"[[_task|zwa]]{NICKNAME}要睡觉了,你们也要早点睡呀" + result
|
||||||
)
|
)
|
||||||
except ActionFailed:
|
except ActionFailed:
|
||||||
logger.warning(f"{g} 群被禁言中,无法发送晚安")
|
logger.warning(f"{g} 发送晚安失败")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"早晚安错误 e:{e}")
|
logger.error(f"早晚安错误 e:{e}")
|
||||||
|
|
||||||
|
|||||||
@ -34,84 +34,87 @@ def init_plugins_settings(data_path: str):
|
|||||||
logger.warning(f"配置文件 模块:{x} 获取 plugin_name 失败...{e}")
|
logger.warning(f"配置文件 模块:{x} 获取 plugin_name 失败...{e}")
|
||||||
_tmp_module[x] = ""
|
_tmp_module[x] = ""
|
||||||
for matcher in _matchers:
|
for matcher in _matchers:
|
||||||
if matcher.plugin_name not in plugins2settings_manager.keys():
|
try:
|
||||||
_plugin = matcher.plugin
|
if matcher.plugin_name not in plugins2settings_manager.keys():
|
||||||
if not _plugin:
|
_plugin = matcher.plugin
|
||||||
continue
|
if not _plugin:
|
||||||
metadata = _plugin.metadata
|
continue
|
||||||
try:
|
metadata = _plugin.metadata
|
||||||
_module = _plugin.module
|
|
||||||
except AttributeError:
|
|
||||||
logger.warning(f"插件 {matcher.plugin_name} 加载失败...,插件控制未加载.")
|
|
||||||
else:
|
|
||||||
try:
|
try:
|
||||||
if metadata:
|
_module = _plugin.module
|
||||||
plugin_name = metadata.name
|
except AttributeError:
|
||||||
|
logger.warning(f"插件 {matcher.plugin_name} 加载失败...,插件控制未加载.")
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
if metadata:
|
||||||
|
plugin_name = metadata.name
|
||||||
|
else:
|
||||||
|
plugin_name = _module.__getattribute__("__zx_plugin_name__")
|
||||||
|
if "[admin]" in plugin_name.lower():
|
||||||
|
try:
|
||||||
|
admin_settings = _module.__getattribute__(
|
||||||
|
"__plugin_settings__"
|
||||||
|
)
|
||||||
|
level = admin_settings["admin_level"]
|
||||||
|
cmd = admin_settings.get("cmd")
|
||||||
|
except (AttributeError, KeyError):
|
||||||
|
level = 5
|
||||||
|
cmd = None
|
||||||
|
if level is None:
|
||||||
|
level = 5
|
||||||
|
admin_manager.add_admin_plugin_settings(
|
||||||
|
matcher.plugin_name, cmd, level
|
||||||
|
)
|
||||||
|
if (
|
||||||
|
"[hidden]" in plugin_name.lower()
|
||||||
|
or "[admin]" in plugin_name.lower()
|
||||||
|
or "[superuser]" in plugin_name.lower()
|
||||||
|
or matcher.plugin_name in plugins2settings_manager.keys()
|
||||||
|
):
|
||||||
|
continue
|
||||||
|
except AttributeError:
|
||||||
|
if matcher.plugin_name not in _tmp:
|
||||||
|
logger.warning(
|
||||||
|
f"获取插件 {matcher.plugin_name} __zx_plugin_name__ 失败...,插件控制未加载."
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
plugin_name = _module.__getattribute__("__zx_plugin_name__")
|
_tmp_module[matcher.plugin_name] = plugin_name
|
||||||
if "[admin]" in plugin_name.lower():
|
|
||||||
try:
|
try:
|
||||||
admin_settings = _module.__getattribute__(
|
plugin_settings = _module.__getattribute__(
|
||||||
"__plugin_settings__"
|
"__plugin_settings__"
|
||||||
)
|
)
|
||||||
level = admin_settings["admin_level"]
|
|
||||||
cmd = admin_settings.get("cmd")
|
|
||||||
except (AttributeError, KeyError):
|
|
||||||
level = 5
|
|
||||||
cmd = None
|
|
||||||
if level is None:
|
|
||||||
level = 5
|
|
||||||
admin_manager.add_admin_plugin_settings(
|
|
||||||
matcher.plugin_name, cmd, level
|
|
||||||
)
|
|
||||||
if (
|
|
||||||
"[hidden]" in plugin_name.lower()
|
|
||||||
or "[admin]" in plugin_name.lower()
|
|
||||||
or "[superuser]" in plugin_name.lower()
|
|
||||||
or matcher.plugin_name in plugins2settings_manager.keys()
|
|
||||||
):
|
|
||||||
continue
|
|
||||||
except AttributeError:
|
|
||||||
if matcher.plugin_name not in _tmp:
|
|
||||||
logger.warning(
|
|
||||||
f"获取插件 {matcher.plugin_name} __zx_plugin_name__ 失败...,插件控制未加载."
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
_tmp_module[matcher.plugin_name] = plugin_name
|
|
||||||
try:
|
|
||||||
plugin_settings = _module.__getattribute__(
|
|
||||||
"__plugin_settings__"
|
|
||||||
)
|
|
||||||
except AttributeError:
|
|
||||||
plugin_settings = {"cmd": [matcher.plugin_name, plugin_name]}
|
|
||||||
if not plugin_settings.get("cost_gold"):
|
|
||||||
plugin_settings["cost_gold"] = 0
|
|
||||||
if (
|
|
||||||
plugin_settings.get("cmd") is not None
|
|
||||||
and plugin_name not in plugin_settings["cmd"]
|
|
||||||
):
|
|
||||||
plugin_settings["cmd"].append(plugin_name)
|
|
||||||
if plugins2settings_manager.get(
|
|
||||||
matcher.plugin_name
|
|
||||||
) and plugins2settings_manager[matcher.plugin_name].get(
|
|
||||||
"plugin_type"
|
|
||||||
):
|
|
||||||
plugin_type = tuple(
|
|
||||||
plugins2settings_manager.get_plugin_data(
|
|
||||||
matcher.plugin_name
|
|
||||||
)["plugin_type"]
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
plugin_type = _module.__getattribute__("__plugin_type__")
|
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
plugin_type = ("normal",)
|
plugin_settings = {"cmd": [matcher.plugin_name, plugin_name]}
|
||||||
if plugin_settings and matcher.plugin_name:
|
if not plugin_settings.get("cost_gold"):
|
||||||
plugins2settings_manager.add_plugin_settings(
|
plugin_settings["cost_gold"] = 0
|
||||||
matcher.plugin_name,
|
if (
|
||||||
plugin_type=plugin_type,
|
plugin_settings.get("cmd") is not None
|
||||||
**plugin_settings,
|
and plugin_name not in plugin_settings["cmd"]
|
||||||
)
|
):
|
||||||
|
plugin_settings["cmd"].append(plugin_name)
|
||||||
|
if plugins2settings_manager.get(
|
||||||
|
matcher.plugin_name
|
||||||
|
) and plugins2settings_manager[matcher.plugin_name].get(
|
||||||
|
"plugin_type"
|
||||||
|
):
|
||||||
|
plugin_type = tuple(
|
||||||
|
plugins2settings_manager.get_plugin_data(
|
||||||
|
matcher.plugin_name
|
||||||
|
)["plugin_type"]
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
plugin_type = _module.__getattribute__("__plugin_type__")
|
||||||
|
except AttributeError:
|
||||||
|
plugin_type = ("normal",)
|
||||||
|
if plugin_settings and matcher.plugin_name:
|
||||||
|
plugins2settings_manager.add_plugin_settings(
|
||||||
|
matcher.plugin_name,
|
||||||
|
plugin_type=plugin_type,
|
||||||
|
**plugin_settings,
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f'{matcher.plugin_name} 初始化 plugin_settings 发生错误 {type(e)}:{e}')
|
||||||
_tmp.append(matcher.plugin_name)
|
_tmp.append(matcher.plugin_name)
|
||||||
_tmp_data = {"PluginSettings": plugins2settings_manager.get_data()}
|
_tmp_data = {"PluginSettings": plugins2settings_manager.get_data()}
|
||||||
with open(plugins2settings_file, "w", encoding="utf8") as wf:
|
with open(plugins2settings_file, "w", encoding="utf8") as wf:
|
||||||
|
|||||||
@ -15,6 +15,7 @@ from .data_source import (
|
|||||||
BilibiliSub,
|
BilibiliSub,
|
||||||
)
|
)
|
||||||
from models.level_user import LevelUser
|
from models.level_user import LevelUser
|
||||||
|
from utils.manager import group_manager
|
||||||
from configs.config import Config
|
from configs.config import Config
|
||||||
from utils.utils import is_number, scheduler, get_bot
|
from utils.utils import is_number, scheduler, get_bot
|
||||||
from typing import Optional, Tuple, Any
|
from typing import Optional, Tuple, Any
|
||||||
@ -267,7 +268,8 @@ async def send_sub_msg(rst: str, sub: BilibiliSub, bot: Bot):
|
|||||||
and Config.get_config("bilibili_sub", "UP_MSG_AT_ALL")
|
and Config.get_config("bilibili_sub", "UP_MSG_AT_ALL")
|
||||||
):
|
):
|
||||||
rst = "[CQ:at,qq=all]\n" + rst
|
rst = "[CQ:at,qq=all]\n" + rst
|
||||||
await bot.send_group_msg(group_id=group_id, message=Message(rst))
|
if group_manager.get_plugin_status("bilibili_sub", group_id):
|
||||||
|
await bot.send_group_msg(group_id=group_id, message=Message(rst))
|
||||||
else:
|
else:
|
||||||
await bot.send_private_msg(user_id=int(x), message=Message(rst))
|
await bot.send_private_msg(user_id=int(x), message=Message(rst))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
|
from io import BytesIO
|
||||||
|
import imagehash
|
||||||
|
from PIL import Image
|
||||||
from nonebot.adapters.onebot.v11.permission import GROUP
|
from nonebot.adapters.onebot.v11.permission import GROUP
|
||||||
from configs.path_config import TEMP_PATH
|
from configs.path_config import TEMP_PATH
|
||||||
from utils.image_utils import get_img_hash
|
|
||||||
import random
|
import random
|
||||||
from utils.message_builder import image
|
from utils.message_builder import image
|
||||||
from nonebot import on_message
|
from nonebot import on_message
|
||||||
@ -8,7 +10,6 @@ from utils.utils import get_message_img, get_message_text
|
|||||||
from nonebot.adapters.onebot.v11 import GroupMessageEvent
|
from nonebot.adapters.onebot.v11 import GroupMessageEvent
|
||||||
from configs.config import Config
|
from configs.config import Config
|
||||||
from utils.http_utils import AsyncHttpx
|
from utils.http_utils import AsyncHttpx
|
||||||
from services.log import logger
|
|
||||||
from configs.config import NICKNAME
|
from configs.config import NICKNAME
|
||||||
|
|
||||||
|
|
||||||
@ -90,7 +91,7 @@ async def _(event: GroupMessageEvent):
|
|||||||
if not img and not msg:
|
if not img and not msg:
|
||||||
return
|
return
|
||||||
if img:
|
if img:
|
||||||
img_hash = await get_fudu_img_hash(img[0], event.group_id)
|
img_hash = await get_fudu_img_hash(img[0])
|
||||||
else:
|
else:
|
||||||
img_hash = ""
|
img_hash = ""
|
||||||
add_msg = msg + "|-|" + img_hash
|
add_msg = msg + "|-|" + img_hash
|
||||||
@ -123,15 +124,5 @@ async def _(event: GroupMessageEvent):
|
|||||||
await fudu.finish("[[_task|fudu]]" + rst)
|
await fudu.finish("[[_task|fudu]]" + rst)
|
||||||
|
|
||||||
|
|
||||||
async def get_fudu_img_hash(url, group_id):
|
async def get_fudu_img_hash(url):
|
||||||
try:
|
return str(imagehash.average_hash(Image.open(BytesIO((await AsyncHttpx.get(url)).content))))
|
||||||
if await AsyncHttpx.download_file(
|
|
||||||
url, TEMP_PATH / f"compare_{group_id}_img.jpg"
|
|
||||||
):
|
|
||||||
img_hash = get_img_hash(TEMP_PATH / f"compare_{group_id}_img.jpg")
|
|
||||||
return str(img_hash)
|
|
||||||
else:
|
|
||||||
logger.warning(f"复读下载图片失败...")
|
|
||||||
except Exception as e:
|
|
||||||
logger.warning(f"复读读取图片Hash出错 {type(e)}:{e}")
|
|
||||||
return ""
|
|
||||||
|
|||||||
@ -118,7 +118,7 @@ class Map:
|
|||||||
self._generate_best_route()
|
self._generate_best_route()
|
||||||
self.map.crop((min_width, min_height, max_width, max_height))
|
self.map.crop((min_width, min_height, max_width, max_height))
|
||||||
rand = random.randint(1, 10000)
|
rand = random.randint(1, 10000)
|
||||||
self.map.save(f"{IMAGE_PATH}/temp/genshin_map_{rand}.png")
|
self.map.save(f"{TEXT_PATH}/genshin_map_{rand}.png")
|
||||||
return rand
|
return rand
|
||||||
|
|
||||||
# 资源数量
|
# 资源数量
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user