mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-01 01:30:04 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c8983e753 | ||
|
|
1fe41dd823 | ||
|
|
e8df59203c | ||
|
|
0f6690606b | ||
|
|
a0115309dd | ||
|
|
ca18d45786 | ||
|
|
76df21036a | ||
|
|
c674d581b7 | ||
|
|
fc53c3c487 | ||
|
|
7a4e31df80 | ||
|
|
f1d308d559 | ||
|
|
b7914bac05 | ||
|
|
8c40d88cc4 |
+1
-1
@@ -139,7 +139,7 @@ dmypy.json
|
|||||||
cython_debug/
|
cython_debug/
|
||||||
|
|
||||||
test.py
|
test.py
|
||||||
server.py
|
server_ip.py
|
||||||
member_activity_handle.py
|
member_activity_handle.py
|
||||||
Yu-Gi-Oh/
|
Yu-Gi-Oh/
|
||||||
search_image/
|
search_image/
|
||||||
|
|||||||
@@ -191,7 +191,7 @@
|
|||||||
# 配置gocq
|
# 配置gocq
|
||||||
|
|
||||||
在 https://github.com/Mrs4s/go-cqhttp 下载Releases最新版本,运行后选择反向代理,
|
在 https://github.com/Mrs4s/go-cqhttp 下载Releases最新版本,运行后选择反向代理,
|
||||||
后将gocq的配置文件config.yml中的universal改为universal: ws://127.0.0.1:8080/cqhttp/ws
|
后将gocq的配置文件config.yml中的universal改为universal: ws://127.0.0.1:8080/onebot/v11/ws
|
||||||
|
|
||||||
# 获取代码
|
# 获取代码
|
||||||
git clone https://github.com/HibiKier/zhenxun_bot.git
|
git clone https://github.com/HibiKier/zhenxun_bot.git
|
||||||
@@ -236,6 +236,21 @@ __Docker 最新版本由 [Sakuracio](https://github.com/Sakuracio) 提供__
|
|||||||
|
|
||||||
## 更新
|
## 更新
|
||||||
|
|
||||||
|
### 2022/2/25 \[v0.1.4]
|
||||||
|
|
||||||
|
* PIX提供配置MAX_ONCE_NUM2FORWARD:当单次发送图片超过指定张数且在群聊时,将转为合并消息
|
||||||
|
* 优化抽卡
|
||||||
|
* 修复点歌无法正确发送
|
||||||
|
* 修复我有一个朋友有时文本会包含CQ码
|
||||||
|
* 修复群欢消息被动控制文本未删除 [@pull/124](https://github.com/HibiKier/zhenxun_bot/pull/124)
|
||||||
|
* message_builder.image不再提供参数:abspath
|
||||||
|
|
||||||
|
### 2022/2/23
|
||||||
|
|
||||||
|
* 插件状态将从已加载插件模块中读取
|
||||||
|
* 修复b站订阅插件订阅失败问题
|
||||||
|
* 修复重启命令无法使用
|
||||||
|
|
||||||
### 2022/2/21 \[v0.1.3.2]
|
### 2022/2/21 \[v0.1.3.2]
|
||||||
|
|
||||||
* 群权限为-1时,超级用户发送的命令依旧生效
|
* 群权限为-1时,超级用户发送的命令依旧生效
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
__version__: v0.1.3.2
|
__version__: v0.1.4
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from nonebot.adapters.onebot.v11.message import MessageSegment
|
|||||||
from services.log import logger
|
from services.log import logger
|
||||||
from configs.path_config import DATA_PATH
|
from configs.path_config import DATA_PATH
|
||||||
from utils.message_builder import image
|
from utils.message_builder import image
|
||||||
from utils.utils import get_bot
|
from utils.utils import get_bot, get_matchers
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from models.group_member_info import GroupInfoUser
|
from models.group_member_info import GroupInfoUser
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@@ -75,7 +75,7 @@ async def custom_group_welcome(
|
|||||||
await AsyncHttpx.download_file(
|
await AsyncHttpx.download_file(
|
||||||
img, DATA_PATH / "custom_welcome_msg" / f"{group_id}.jpg"
|
img, DATA_PATH / "custom_welcome_msg" / f"{group_id}.jpg"
|
||||||
)
|
)
|
||||||
img_result = image(abspath=DATA_PATH / "custom_welcome_msg" / f"{group_id}.jpg")
|
img_result = image(DATA_PATH / "custom_welcome_msg" / f"{group_id}.jpg")
|
||||||
logger.info(f"USER {user_id} GROUP {group_id} 更换群欢迎消息图片")
|
logger.info(f"USER {user_id} GROUP {group_id} 更换群欢迎消息图片")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"GROUP {group_id} 替换群消息失败 e:{e}")
|
logger.error(f"GROUP {group_id} 替换群消息失败 e:{e}")
|
||||||
@@ -187,24 +187,28 @@ def _get_plugin_status() -> MessageSegment:
|
|||||||
"""
|
"""
|
||||||
rst = "\t功能\n"
|
rst = "\t功能\n"
|
||||||
flag_str = "状态".rjust(4) + "\n"
|
flag_str = "状态".rjust(4) + "\n"
|
||||||
for module in plugins_manager.get_data():
|
tmp_name = []
|
||||||
flag = plugins_manager.get_plugin_block_type(module)
|
for matcher in get_matchers():
|
||||||
flag = flag.upper() + " CLOSE" if flag else "OPEN"
|
if matcher.plugin_name not in tmp_name:
|
||||||
try:
|
tmp_name.append(matcher.plugin_name)
|
||||||
plugin_name = plugins_manager.get(module)["plugin_name"]
|
module = matcher.plugin_name
|
||||||
if (
|
flag = plugins_manager.get_plugin_block_type(module)
|
||||||
"[Hidden]" in plugin_name
|
flag = flag.upper() + " CLOSE" if flag else "OPEN"
|
||||||
or "[Admin]" in plugin_name
|
try:
|
||||||
or "[Superuser]" in plugin_name
|
plugin_name = plugins_manager.get(module)["plugin_name"]
|
||||||
):
|
if (
|
||||||
continue
|
"[Hidden]" in plugin_name
|
||||||
rst += f"{plugin_name}"
|
or "[Admin]" in plugin_name
|
||||||
except KeyError:
|
or "[Superuser]" in plugin_name
|
||||||
rst += f"{module}"
|
):
|
||||||
if plugins_manager.get(module)["error"]:
|
continue
|
||||||
rst += "[ERROR]"
|
rst += f"{plugin_name}"
|
||||||
rst += "\n"
|
except KeyError:
|
||||||
flag_str += f"{flag}\n"
|
rst += f"{module}"
|
||||||
|
if plugins_manager.get(module)["error"]:
|
||||||
|
rst += "[ERROR]"
|
||||||
|
rst += "\n"
|
||||||
|
flag_str += f"{flag}\n"
|
||||||
height = len(rst.split("\n")) * 24
|
height = len(rst.split("\n")) * 24
|
||||||
a = BuildImage(250, height, font_size=20)
|
a = BuildImage(250, height, font_size=20)
|
||||||
a.text((10, 10), rst)
|
a.text((10, 10), rst)
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ async def _(bot: Bot, event: GroupIncreaseNoticeEvent):
|
|||||||
at_flag = True
|
at_flag = True
|
||||||
if (DATA_PATH / "custom_welcome_msg" / f"{event.group_id}.jpg").exists():
|
if (DATA_PATH / "custom_welcome_msg" / f"{event.group_id}.jpg").exists():
|
||||||
img = image(
|
img = image(
|
||||||
abspath=DATA_PATH / "custom_welcome_msg" / f"{event.group_id}.jpg"
|
DATA_PATH / "custom_welcome_msg" / f"{event.group_id}.jpg"
|
||||||
)
|
)
|
||||||
if msg or img:
|
if msg or img:
|
||||||
msg = msg.strip() + img
|
msg = msg.strip() + img
|
||||||
|
|||||||
@@ -14,10 +14,20 @@ async def handle_api_call(bot: Bot, api: str, data: Dict[str, Any]):
|
|||||||
or api == "send_group_msg"
|
or api == "send_group_msg"
|
||||||
)
|
)
|
||||||
and (
|
and (
|
||||||
(r := re.search("^\[\[_task\|(.*)]]", str(data["message"]).strip()))
|
(
|
||||||
|
r := re.search(
|
||||||
|
"^\[\[_task\|(.*)]]",
|
||||||
|
data["message"].strip()
|
||||||
|
if isinstance(data["message"], str)
|
||||||
|
else str(data["message"]["text"]).strip(),
|
||||||
|
)
|
||||||
|
)
|
||||||
or (
|
or (
|
||||||
r := re.search(
|
r := re.search(
|
||||||
"^[[_task\|(.*)]]", str(data["message"]).strip()
|
"^[[_task\|(.*)]]",
|
||||||
|
data["message"].strip()
|
||||||
|
if isinstance(data["message"], str)
|
||||||
|
else str(data["message"]["text"]).strip(),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ from utils.utils import is_number, scheduler, get_bot
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
from services.log import logger
|
from services.log import logger
|
||||||
from nonebot import Driver
|
from nonebot import Driver
|
||||||
from nonebot.params import CommandArg, ArgPlainText
|
from nonebot.params import CommandArg, ArgStr
|
||||||
import nonebot
|
import nonebot
|
||||||
|
|
||||||
__zx_plugin_name__ = "B站订阅"
|
__zx_plugin_name__ = "B站订阅"
|
||||||
@@ -112,14 +112,22 @@ async def _(event: MessageEvent, state: T_State, arg: Message = CommandArg()):
|
|||||||
state["id"] = int(id_)
|
state["id"] = int(id_)
|
||||||
|
|
||||||
|
|
||||||
|
@add_sub.got("sub_type")
|
||||||
|
@add_sub.got("sub_user")
|
||||||
@add_sub.got("id")
|
@add_sub.got("id")
|
||||||
async def _(event: MessageEvent, state: T_State, id_: str = ArgPlainText("id")):
|
async def _(
|
||||||
season_data = state["season_data"]
|
event: MessageEvent,
|
||||||
if not is_number(id_) or int(id_) < 1 or int(id_) > len(season_data):
|
state: T_State,
|
||||||
await add_sub.reject_arg("id", "Id必须为数字且在范围内!请重新输入...")
|
id_: str = ArgStr("id"),
|
||||||
id_ = season_data[int(id_) - 1]["media_id"]
|
sub_type: str = ArgStr("sub_type"),
|
||||||
sub_type = state["sub_type"]
|
sub_user: str = ArgStr("sub_user"),
|
||||||
sub_user = state["sub_user"]
|
):
|
||||||
|
if sub_type in ["season", "动漫", "番剧"] and state.get("season_data"):
|
||||||
|
season_data = state["season_data"]
|
||||||
|
if not is_number(id_) or int(id_) < 1 or int(id_) > len(season_data):
|
||||||
|
await add_sub.reject_arg("id", "Id必须为数字且在范围内!请重新输入...")
|
||||||
|
id_ = season_data[int(id_) - 1]["media_id"]
|
||||||
|
id_ = int(id_)
|
||||||
if sub_type in ["主播", "直播"]:
|
if sub_type in ["主播", "直播"]:
|
||||||
await add_sub.send(await add_live_sub(id_, sub_user))
|
await add_sub.send(await add_live_sub(id_, sub_user))
|
||||||
elif sub_type.lower() in ["up", "用户"]:
|
elif sub_type.lower() in ["up", "用户"]:
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
from nonebot.adapters.onebot.v11 import Bot
|
from nonebot.adapters.onebot.v11 import Bot
|
||||||
from nonebot.typing import T_State
|
|
||||||
from nonebot.permission import SUPERUSER
|
from nonebot.permission import SUPERUSER
|
||||||
from nonebot import on_command
|
from nonebot import on_command
|
||||||
from .data_source import check_update, get_latest_version_data
|
from .data_source import check_update, get_latest_version_data
|
||||||
@@ -8,6 +7,7 @@ from utils.utils import scheduler, get_bot
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from configs.config import Config
|
from configs.config import Config
|
||||||
from nonebot.rule import to_me
|
from nonebot.rule import to_me
|
||||||
|
from nonebot.params import ArgStr
|
||||||
import platform
|
import platform
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@@ -73,8 +73,7 @@ async def _():
|
|||||||
|
|
||||||
|
|
||||||
@restart.got("flag", prompt="确定是否重启真寻?(重启失败咱们将失去联系,请谨慎!)")
|
@restart.got("flag", prompt="确定是否重启真寻?(重启失败咱们将失去联系,请谨慎!)")
|
||||||
async def _(state: T_State):
|
async def _(flag: str = ArgStr("flag")):
|
||||||
flag = state["flag"]
|
|
||||||
if flag.lower() in ["true", "是", "好", "确定", "确定是"]:
|
if flag.lower() in ["true", "是", "好", "确定", "确定是"]:
|
||||||
await restart.send("开始重启真寻..请稍等...")
|
await restart.send("开始重启真寻..请稍等...")
|
||||||
open("is_restart", "w")
|
open("is_restart", "w")
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import os
|
|||||||
def image(
|
def image(
|
||||||
file: Union[str, Path, bytes] = None,
|
file: Union[str, Path, bytes] = None,
|
||||||
path: str = None,
|
path: str = None,
|
||||||
abspath: Union[str, Path] = None,
|
|
||||||
b64: str = None,
|
b64: str = None,
|
||||||
) -> Union[MessageSegment, str]:
|
) -> Union[MessageSegment, str]:
|
||||||
"""
|
"""
|
||||||
@@ -20,18 +19,9 @@ def image(
|
|||||||
参数:
|
参数:
|
||||||
:param file: 图片文件名称,默认在 resource/img 目录下
|
:param file: 图片文件名称,默认在 resource/img 目录下
|
||||||
:param path: 图片所在路径,默认在 resource/img 目录下
|
:param path: 图片所在路径,默认在 resource/img 目录下
|
||||||
:param abspath: 图片绝对路径
|
|
||||||
:param b64: 图片base64
|
:param b64: 图片base64
|
||||||
"""
|
"""
|
||||||
if abspath:
|
if isinstance(file, Path):
|
||||||
if isinstance(abspath, Path):
|
|
||||||
return MessageSegment.image(file)
|
|
||||||
return (
|
|
||||||
MessageSegment.image("file:///" + abspath)
|
|
||||||
if os.path.exists(abspath)
|
|
||||||
else ""
|
|
||||||
)
|
|
||||||
elif isinstance(file, Path):
|
|
||||||
if file.exists():
|
if file.exists():
|
||||||
return MessageSegment.image(file)
|
return MessageSegment.image(file)
|
||||||
logger.warning(f"图片 {file.absolute()}缺失...")
|
logger.warning(f"图片 {file.absolute()}缺失...")
|
||||||
@@ -41,14 +31,11 @@ def image(
|
|||||||
elif b64:
|
elif b64:
|
||||||
return MessageSegment.image(b64 if "base64://" in b64 else "base64://" + b64)
|
return MessageSegment.image(b64 if "base64://" in b64 else "base64://" + b64)
|
||||||
else:
|
else:
|
||||||
if "http" in file:
|
if file.startswith("http"):
|
||||||
return MessageSegment.image(file)
|
return MessageSegment.image(file)
|
||||||
if len(file.split(".")) == 1:
|
if len(file.split(".")) == 1:
|
||||||
file += ".jpg"
|
file += ".jpg"
|
||||||
file = (
|
if (file := IMAGE_PATH / path / file if path else IMAGE_PATH / file).exists():
|
||||||
IMAGE_PATH / path / file if path else IMAGE_PATH / file
|
|
||||||
)
|
|
||||||
if file.exists():
|
|
||||||
return MessageSegment.image(file)
|
return MessageSegment.image(file)
|
||||||
else:
|
else:
|
||||||
logger.warning(f"图片 {file} 缺失...")
|
logger.warning(f"图片 {file} 缺失...")
|
||||||
|
|||||||
Reference in New Issue
Block a user