2021-05-20 19:27:31 +08:00
|
|
|
|
from nonebot import on_command
|
2022-02-19 18:20:19 +08:00
|
|
|
|
from nonebot.adapters.onebot.v11 import GroupMessageEvent
|
|
|
|
|
|
from nonebot.adapters.onebot.v11.permission import GROUP
|
2021-05-20 19:27:31 +08:00
|
|
|
|
from configs.path_config import DATA_PATH
|
2021-07-30 21:21:51 +08:00
|
|
|
|
from utils.message_builder import image
|
|
|
|
|
|
|
2021-05-20 19:27:31 +08:00
|
|
|
|
try:
|
|
|
|
|
|
import ujson as json
|
|
|
|
|
|
except ModuleNotFoundError:
|
|
|
|
|
|
import json
|
|
|
|
|
|
|
2021-10-03 14:24:07 +08:00
|
|
|
|
__zx_plugin_name__ = "查看群欢迎消息"
|
|
|
|
|
|
__plugin_usage__ = """
|
|
|
|
|
|
usage:
|
|
|
|
|
|
查看当前的群欢迎消息
|
|
|
|
|
|
指令:
|
|
|
|
|
|
查看群欢迎消息
|
|
|
|
|
|
""".strip()
|
|
|
|
|
|
__plugin_des__ = "查看群欢迎消息"
|
|
|
|
|
|
__plugin_cmd__ = ["查看群欢迎消息"]
|
|
|
|
|
|
__plugin_version__ = 0.1
|
|
|
|
|
|
__plugin_author__ = "HibiKier"
|
|
|
|
|
|
__plugin_settings__ = {
|
|
|
|
|
|
"level": 5,
|
|
|
|
|
|
"default_status": True,
|
|
|
|
|
|
"limit_superuser": False,
|
|
|
|
|
|
"cmd": ["查看群欢迎消息"],
|
|
|
|
|
|
}
|
2021-06-15 10:57:08 +08:00
|
|
|
|
|
2021-07-30 21:21:51 +08:00
|
|
|
|
view_custom_welcome = on_command(
|
|
|
|
|
|
"群欢迎消息", aliases={"查看群欢迎消息", "查看当前群欢迎消息"}, permission=GROUP, priority=5, block=True
|
|
|
|
|
|
)
|
2021-05-20 19:27:31 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@view_custom_welcome.handle()
|
2022-02-19 18:20:19 +08:00
|
|
|
|
async def _(event: GroupMessageEvent):
|
2021-07-30 21:21:51 +08:00
|
|
|
|
img = ""
|
|
|
|
|
|
msg = ""
|
2022-02-19 18:20:19 +08:00
|
|
|
|
if (DATA_PATH / "custom_welcome_msg" / f"{event.group_id}.jpg").exists():
|
|
|
|
|
|
img = image(abspath=DATA_PATH / "custom_welcome_msg" / f"{event.group_id}.jpg")
|
2021-07-30 21:21:51 +08:00
|
|
|
|
custom_welcome_msg_json = (
|
2022-02-19 18:20:19 +08:00
|
|
|
|
DATA_PATH / "custom_welcome_msg" / "custom_welcome_msg.json"
|
2021-07-30 21:21:51 +08:00
|
|
|
|
)
|
2021-05-20 19:27:31 +08:00
|
|
|
|
if custom_welcome_msg_json.exists():
|
2021-07-30 21:21:51 +08:00
|
|
|
|
data = json.load(open(custom_welcome_msg_json, "r"))
|
2021-05-20 19:27:31 +08:00
|
|
|
|
if data.get(str(event.group_id)):
|
|
|
|
|
|
msg = data[str(event.group_id)]
|
2021-07-30 21:21:51 +08:00
|
|
|
|
if msg.find("[at]") != -1:
|
|
|
|
|
|
msg = msg.replace("[at]", "")
|
2021-05-20 19:27:31 +08:00
|
|
|
|
if img or msg:
|
|
|
|
|
|
await view_custom_welcome.finish(msg + img, at_sender=True)
|
2021-05-20 20:47:34 +08:00
|
|
|
|
else:
|
2021-07-30 21:21:51 +08:00
|
|
|
|
await view_custom_welcome.finish("当前还没有自定义群欢迎消息哦", at_sender=True)
|