mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-14 21:52:56 +08:00
更新依赖注入
This commit is contained in:
parent
1ce4537605
commit
499517e882
@ -293,6 +293,10 @@ PS: **ARM平台** 请使用全量版 同时 **如果你的机器 RAM < 1G 可能
|
||||
|
||||
## 更新
|
||||
|
||||
### 2022/10/22
|
||||
|
||||
* 更新依赖注入
|
||||
|
||||
### 2022/10/16 \[v0.1.6.4]
|
||||
|
||||
* 修改商店道具icon可以为空
|
||||
|
||||
@ -33,6 +33,8 @@ async def _(bot: Bot, api: str, data: Dict[str, Any]):
|
||||
)
|
||||
and r.group(1) in group_manager.get_task_data().keys()
|
||||
):
|
||||
# if bot.self_id in bot.config.superusers:
|
||||
# raise MockApiException(f"禁止社死...")
|
||||
task = r.group(1)
|
||||
group_id = data["group_id"]
|
||||
if group_manager.get_group_level(
|
||||
|
||||
@ -68,7 +68,7 @@ __plugin_configs__ = {
|
||||
}
|
||||
|
||||
add_sub = on_command("添加订阅", priority=5, block=True)
|
||||
del_sub = on_regex(r"^删除订阅(\d+)$", priority=5, block=True)
|
||||
del_sub = on_regex(r"^删除订阅[\s\S]?(\d+)$", priority=5, block=True)
|
||||
show_sub_info = on_regex("^查看订阅$", priority=5, block=True)
|
||||
|
||||
driver: Driver = nonebot.get_driver()
|
||||
|
||||
@ -9,7 +9,7 @@ import platform
|
||||
# asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
|
||||
|
||||
|
||||
url = "http://www.eclzz.cool"
|
||||
url = "http://www.eclzz.love"
|
||||
|
||||
|
||||
async def get_bt_info(keyword: str, page: int):
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import imagehash
|
||||
from PIL import Image
|
||||
from io import BytesIO
|
||||
from httpx import TimeoutException
|
||||
from services.log import logger
|
||||
|
||||
from nonebot.typing import T_State
|
||||
from nonebot.adapters.onebot.v11 import MessageEvent
|
||||
@ -20,8 +20,8 @@ async def check(event: MessageEvent, state: T_State) -> bool:
|
||||
try:
|
||||
r = await AsyncHttpx.get(img[0])
|
||||
problem = str(imagehash.average_hash(Image.open(BytesIO(r.content))))
|
||||
except TimeoutException:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.warning(f"word_bank rule 获取图片失败 {type(e)}:{e}")
|
||||
if at:
|
||||
temp = ''
|
||||
for seg in event.message:
|
||||
|
||||
2
poetry.lock
generated
2
poetry.lock
generated
@ -1859,7 +1859,7 @@ reference = "ali"
|
||||
[metadata]
|
||||
lock-version = "1.1"
|
||||
python-versions = "^3.8"
|
||||
content-hash = "4dadd609a841e1e4639254f4256dc4cf2dfa4eb36d813c24dc101bded155a7a1"
|
||||
content-hash = "911ba141941ab24fc67895f173219d5e92a9cbdf80bfa0e7758ea28805418e32"
|
||||
|
||||
[metadata.files]
|
||||
aiofiles = [
|
||||
|
||||
@ -13,7 +13,6 @@ url = "https://mirrors.aliyun.com/pypi/simple/"
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.8"
|
||||
nonebot2 = "^2.0.0rc1"
|
||||
nonebot-adapter-onebot = "^2.0.0-beta.1"
|
||||
aiofiles = "^0.8.0"
|
||||
aiohttp = "3.7.4.post0"
|
||||
beautifulsoup4 = "4.9.3"
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
from typing import List, Callable, Optional
|
||||
from typing import List, Callable, Optional, Union
|
||||
|
||||
from nonebot.adapters.onebot.v11 import GroupMessageEvent, MessageEvent
|
||||
from nonebot.internal.matcher import Matcher
|
||||
@ -7,9 +7,11 @@ from models.user_shop_gold_log import UserShopGoldLog
|
||||
from models.bag_user import BagUser
|
||||
from utils.message_builder import at
|
||||
from utils.utils import get_message_at, get_message_face, get_message_img, get_message_text
|
||||
from configs.config import Config
|
||||
from utils.manager import plugins_manager
|
||||
|
||||
|
||||
def cost_gold(gold: int):
|
||||
def CostGold(gold: int):
|
||||
"""
|
||||
说明:
|
||||
插件方法调用使用金币
|
||||
@ -25,60 +27,105 @@ def cost_gold(gold: int):
|
||||
return Depends(dependency)
|
||||
|
||||
|
||||
async def _match(matcher: Matcher, event: MessageEvent, msg: Optional[str], func: Callable):
|
||||
def GetConfig(module: Optional[str] = None, config: str = "", default_value: Optional[str] = None, prompt: Optional[str] = None):
|
||||
"""
|
||||
说明:
|
||||
获取配置项
|
||||
参数:
|
||||
:param module: 模块名,为空时默认使用当前插件模块名
|
||||
:param config: 配置项名称
|
||||
:param default_value: 默认值
|
||||
:param prompt: 为空时提示
|
||||
"""
|
||||
async def dependency(matcher: Matcher):
|
||||
module_ = module or matcher.plugin_name
|
||||
value = Config.get_config(module_, config, default_value)
|
||||
if value is None:
|
||||
await matcher.finish(prompt or f"配置项 {config} 未填写!")
|
||||
return value
|
||||
|
||||
return Depends(dependency)
|
||||
|
||||
|
||||
def CheckConfig(module: Optional[str] = None, config: Union[str, List[str]] = "", prompt: Optional[str] = None):
|
||||
"""
|
||||
说明:
|
||||
检测配置项在配置文件中是否填写
|
||||
参数:
|
||||
:param module: 模块名,为空时默认使用当前插件模块名
|
||||
:param config: 需要检查的配置项名称
|
||||
:param prompt: 为空时提示
|
||||
"""
|
||||
async def dependency(matcher: Matcher):
|
||||
module_ = module or matcher.plugin_name
|
||||
config_list = [config] if isinstance(config, str) else config
|
||||
for c in config_list:
|
||||
if Config.get_config(module_, c) is None:
|
||||
await matcher.finish(prompt or f"配置项 {c} 未填写!")
|
||||
|
||||
return Depends(dependency)
|
||||
|
||||
|
||||
async def _match(matcher: Matcher, event: MessageEvent, msg: Optional[str], func: Callable, contain_reply: bool):
|
||||
_list = func(event.message)
|
||||
if event.reply and contain_reply:
|
||||
_list = func(event.reply.message)
|
||||
if not _list and msg:
|
||||
await matcher.finish(msg)
|
||||
return _list
|
||||
|
||||
|
||||
def ImageList(msg: Optional[str] = None) -> List[str]:
|
||||
def ImageList(msg: Optional[str] = None, contain_reply: bool = True) -> List[str]:
|
||||
"""
|
||||
说明:
|
||||
获取图片列表,含有msg时不能为空,为空时提示并结束事件
|
||||
获取图片列表(包括回复时),含有msg时不能为空,为空时提示并结束事件
|
||||
参数:
|
||||
:param msg: 提示文本
|
||||
:param contain_reply: 包含回复内容
|
||||
"""
|
||||
async def dependency(matcher: Matcher, event: MessageEvent):
|
||||
return await _match(matcher, event, msg, get_message_img)
|
||||
return await _match(matcher, event, msg, get_message_img, contain_reply)
|
||||
|
||||
return Depends(dependency)
|
||||
|
||||
|
||||
def AtList(msg: Optional[str] = None) -> List[str]:
|
||||
def AtList(msg: Optional[str] = None, contain_reply: bool = True) -> List[str]:
|
||||
"""
|
||||
说明:
|
||||
获取at列表,含有msg时不能为空,为空时提示并结束事件
|
||||
获取at列表(包括回复时),含有msg时不能为空,为空时提示并结束事件
|
||||
参数:
|
||||
:param msg: 提示文本
|
||||
:param contain_reply: 包含回复内容
|
||||
"""
|
||||
async def dependency(matcher: Matcher, event: MessageEvent):
|
||||
return await _match(matcher, event, msg, get_message_at)
|
||||
return await _match(matcher, event, msg, get_message_at, contain_reply)
|
||||
|
||||
return Depends(dependency)
|
||||
|
||||
|
||||
def FaceList(msg: Optional[str] = None) -> List[str]:
|
||||
def FaceList(msg: Optional[str] = None, contain_reply: bool = True) -> List[str]:
|
||||
"""
|
||||
说明:
|
||||
获取face列表,含有msg时不能为空,为空时提示并结束事件
|
||||
获取face列表(包括回复时),含有msg时不能为空,为空时提示并结束事件
|
||||
参数:
|
||||
:param msg: 提示文本
|
||||
:param contain_reply: 包含回复内容
|
||||
"""
|
||||
async def dependency(matcher: Matcher, event: MessageEvent):
|
||||
return await _match(matcher, event, msg, get_message_face)
|
||||
return await _match(matcher, event, msg, get_message_face, contain_reply)
|
||||
|
||||
return Depends(dependency)
|
||||
|
||||
|
||||
def PlaintText(msg: Optional[str] = None) -> str:
|
||||
def PlaintText(msg: Optional[str] = None, contain_reply: bool = True) -> str:
|
||||
"""
|
||||
说明:
|
||||
获取纯文本且,含有msg时不能为空,为空时提示并结束事件
|
||||
获取纯文本且(包括回复时),含有msg时不能为空,为空时提示并结束事件
|
||||
参数:
|
||||
:param msg: 提示文本
|
||||
:param contain_reply: 包含回复内容
|
||||
"""
|
||||
async def dependency(matcher: Matcher, event: MessageEvent):
|
||||
return await _match(matcher, event, msg, get_message_text)
|
||||
return await _match(matcher, event, msg, get_message_text, contain_reply)
|
||||
|
||||
return Depends(dependency)
|
||||
|
||||
@ -44,6 +44,7 @@ class AsyncHttpx:
|
||||
:param params: params
|
||||
:param headers: 请求头
|
||||
:param cookies: cookies
|
||||
:param verify: verify
|
||||
:param use_proxy: 使用默认代理
|
||||
:param proxy: 指定代理
|
||||
:param timeout: 超时时间
|
||||
|
||||
Loading…
Reference in New Issue
Block a user