diff --git a/plugins/__init__.py b/plugins/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/plugins/__pycache__/__init__.cpython-38.pyc b/plugins/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 61e31c0d..00000000 Binary files a/plugins/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/__pycache__/__init__.cpython-39.pyc b/plugins/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 020e7d6d..00000000 Binary files a/plugins/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/__pycache__/add_dy.cpython-38.pyc b/plugins/__pycache__/add_dy.cpython-38.pyc deleted file mode 100644 index 7ce2a3b5..00000000 Binary files a/plugins/__pycache__/add_dy.cpython-38.pyc and /dev/null differ diff --git a/plugins/__pycache__/admin_config.cpython-38.pyc b/plugins/__pycache__/admin_config.cpython-38.pyc deleted file mode 100644 index 8a9208c5..00000000 Binary files a/plugins/__pycache__/admin_config.cpython-38.pyc and /dev/null differ diff --git a/plugins/__pycache__/admin_config.cpython-39.pyc b/plugins/__pycache__/admin_config.cpython-39.pyc deleted file mode 100644 index 916fc828..00000000 Binary files a/plugins/__pycache__/admin_config.cpython-39.pyc and /dev/null differ diff --git a/plugins/__pycache__/change_dy.cpython-38.pyc b/plugins/__pycache__/change_dy.cpython-38.pyc deleted file mode 100644 index e5774a10..00000000 Binary files a/plugins/__pycache__/change_dy.cpython-38.pyc and /dev/null differ diff --git a/plugins/__pycache__/del_dy.cpython-38.pyc b/plugins/__pycache__/del_dy.cpython-38.pyc deleted file mode 100644 index 13f9d385..00000000 Binary files a/plugins/__pycache__/del_dy.cpython-38.pyc and /dev/null differ diff --git a/plugins/__pycache__/fake_msg.cpython-38.pyc b/plugins/__pycache__/fake_msg.cpython-38.pyc deleted file mode 100644 index ea2ce00c..00000000 Binary files a/plugins/__pycache__/fake_msg.cpython-38.pyc and /dev/null differ diff --git a/plugins/__pycache__/fake_msg.cpython-39.pyc b/plugins/__pycache__/fake_msg.cpython-39.pyc deleted file mode 100644 index 08a1dbf6..00000000 Binary files a/plugins/__pycache__/fake_msg.cpython-39.pyc and /dev/null differ diff --git a/plugins/__pycache__/fudu.cpython-38.pyc b/plugins/__pycache__/fudu.cpython-38.pyc deleted file mode 100644 index 55536dca..00000000 Binary files a/plugins/__pycache__/fudu.cpython-38.pyc and /dev/null differ diff --git a/plugins/__pycache__/fudu.cpython-39.pyc b/plugins/__pycache__/fudu.cpython-39.pyc deleted file mode 100644 index d21c499f..00000000 Binary files a/plugins/__pycache__/fudu.cpython-39.pyc and /dev/null differ diff --git a/plugins/__pycache__/group_welcome_msg.cpython-38.pyc b/plugins/__pycache__/group_welcome_msg.cpython-38.pyc deleted file mode 100644 index a6bfdf99..00000000 Binary files a/plugins/__pycache__/group_welcome_msg.cpython-38.pyc and /dev/null differ diff --git a/plugins/__pycache__/group_welcome_msg.cpython-39.pyc b/plugins/__pycache__/group_welcome_msg.cpython-39.pyc deleted file mode 100644 index e73285b9..00000000 Binary files a/plugins/__pycache__/group_welcome_msg.cpython-39.pyc and /dev/null differ diff --git a/plugins/__pycache__/hook.cpython-38.pyc b/plugins/__pycache__/hook.cpython-38.pyc deleted file mode 100644 index 504dc298..00000000 Binary files a/plugins/__pycache__/hook.cpython-38.pyc and /dev/null differ diff --git a/plugins/__pycache__/hook.cpython-39.pyc b/plugins/__pycache__/hook.cpython-39.pyc deleted file mode 100644 index 4429fd30..00000000 Binary files a/plugins/__pycache__/hook.cpython-39.pyc and /dev/null differ diff --git a/plugins/__pycache__/jitang.cpython-38.pyc b/plugins/__pycache__/jitang.cpython-38.pyc deleted file mode 100644 index d6dbb4bc..00000000 Binary files a/plugins/__pycache__/jitang.cpython-38.pyc and /dev/null differ diff --git a/plugins/__pycache__/jitang.cpython-39.pyc b/plugins/__pycache__/jitang.cpython-39.pyc deleted file mode 100644 index 9e6c1051..00000000 Binary files a/plugins/__pycache__/jitang.cpython-39.pyc and /dev/null differ diff --git a/plugins/__pycache__/mute.cpython-38.pyc b/plugins/__pycache__/mute.cpython-38.pyc deleted file mode 100644 index 3931683d..00000000 Binary files a/plugins/__pycache__/mute.cpython-38.pyc and /dev/null differ diff --git a/plugins/__pycache__/mute.cpython-39.pyc b/plugins/__pycache__/mute.cpython-39.pyc deleted file mode 100644 index d33d11db..00000000 Binary files a/plugins/__pycache__/mute.cpython-39.pyc and /dev/null differ diff --git a/plugins/__pycache__/my_info.cpython-38.pyc b/plugins/__pycache__/my_info.cpython-38.pyc deleted file mode 100644 index 6ee37bb7..00000000 Binary files a/plugins/__pycache__/my_info.cpython-38.pyc and /dev/null differ diff --git a/plugins/__pycache__/my_info.cpython-39.pyc b/plugins/__pycache__/my_info.cpython-39.pyc deleted file mode 100644 index 14304782..00000000 Binary files a/plugins/__pycache__/my_info.cpython-39.pyc and /dev/null differ diff --git a/plugins/__pycache__/nickname.cpython-38.pyc b/plugins/__pycache__/nickname.cpython-38.pyc deleted file mode 100644 index 9c59ba11..00000000 Binary files a/plugins/__pycache__/nickname.cpython-38.pyc and /dev/null differ diff --git a/plugins/__pycache__/nickname.cpython-39.pyc b/plugins/__pycache__/nickname.cpython-39.pyc deleted file mode 100644 index 29823fee..00000000 Binary files a/plugins/__pycache__/nickname.cpython-39.pyc and /dev/null differ diff --git a/plugins/__pycache__/parse_bilibili_json.cpython-38.pyc b/plugins/__pycache__/parse_bilibili_json.cpython-38.pyc deleted file mode 100644 index 9c27968d..00000000 Binary files a/plugins/__pycache__/parse_bilibili_json.cpython-38.pyc and /dev/null differ diff --git a/plugins/__pycache__/parse_bilibili_json.cpython-39.pyc b/plugins/__pycache__/parse_bilibili_json.cpython-39.pyc deleted file mode 100644 index f648969e..00000000 Binary files a/plugins/__pycache__/parse_bilibili_json.cpython-39.pyc and /dev/null differ diff --git a/plugins/__pycache__/quotations.cpython-38.pyc b/plugins/__pycache__/quotations.cpython-38.pyc deleted file mode 100644 index 1da2b002..00000000 Binary files a/plugins/__pycache__/quotations.cpython-38.pyc and /dev/null differ diff --git a/plugins/__pycache__/quotations.cpython-39.pyc b/plugins/__pycache__/quotations.cpython-39.pyc deleted file mode 100644 index cece1c3d..00000000 Binary files a/plugins/__pycache__/quotations.cpython-39.pyc and /dev/null differ diff --git a/plugins/__pycache__/server_ip.cpython-38.pyc b/plugins/__pycache__/server_ip.cpython-38.pyc deleted file mode 100644 index 4bc3755a..00000000 Binary files a/plugins/__pycache__/server_ip.cpython-38.pyc and /dev/null differ diff --git a/plugins/__pycache__/server_ip.cpython-39.pyc b/plugins/__pycache__/server_ip.cpython-39.pyc deleted file mode 100644 index ad404eb2..00000000 Binary files a/plugins/__pycache__/server_ip.cpython-39.pyc and /dev/null differ diff --git a/plugins/__pycache__/show_all.cpython-38.pyc b/plugins/__pycache__/show_all.cpython-38.pyc deleted file mode 100644 index aff9e8ef..00000000 Binary files a/plugins/__pycache__/show_all.cpython-38.pyc and /dev/null differ diff --git a/plugins/__pycache__/show_dy.cpython-38.pyc b/plugins/__pycache__/show_dy.cpython-38.pyc deleted file mode 100644 index d0ad36b5..00000000 Binary files a/plugins/__pycache__/show_dy.cpython-38.pyc and /dev/null differ diff --git a/plugins/__pycache__/start.cpython-38.pyc b/plugins/__pycache__/start.cpython-38.pyc deleted file mode 100644 index 74da3032..00000000 Binary files a/plugins/__pycache__/start.cpython-38.pyc and /dev/null differ diff --git a/plugins/__pycache__/statistics_hook.cpython-39.pyc b/plugins/__pycache__/statistics_hook.cpython-39.pyc deleted file mode 100644 index 197e3151..00000000 Binary files a/plugins/__pycache__/statistics_hook.cpython-39.pyc and /dev/null differ diff --git a/plugins/__pycache__/test.cpython-38.pyc b/plugins/__pycache__/test.cpython-38.pyc deleted file mode 100644 index 8d400c85..00000000 Binary files a/plugins/__pycache__/test.cpython-38.pyc and /dev/null differ diff --git a/plugins/__pycache__/test.cpython-39.pyc b/plugins/__pycache__/test.cpython-39.pyc deleted file mode 100644 index 49b11867..00000000 Binary files a/plugins/__pycache__/test.cpython-39.pyc and /dev/null differ diff --git a/plugins/__pycache__/update_info.cpython-38.pyc b/plugins/__pycache__/update_info.cpython-38.pyc deleted file mode 100644 index ece25f1f..00000000 Binary files a/plugins/__pycache__/update_info.cpython-38.pyc and /dev/null differ diff --git a/plugins/__pycache__/update_info.cpython-39.pyc b/plugins/__pycache__/update_info.cpython-39.pyc deleted file mode 100644 index 4105d524..00000000 Binary files a/plugins/__pycache__/update_info.cpython-39.pyc and /dev/null differ diff --git a/plugins/__pycache__/update_pic.cpython-38.pyc b/plugins/__pycache__/update_pic.cpython-38.pyc deleted file mode 100644 index d32b3c56..00000000 Binary files a/plugins/__pycache__/update_pic.cpython-38.pyc and /dev/null differ diff --git a/plugins/__pycache__/update_pic.cpython-39.pyc b/plugins/__pycache__/update_pic.cpython-39.pyc deleted file mode 100644 index 558c39e4..00000000 Binary files a/plugins/__pycache__/update_pic.cpython-39.pyc and /dev/null differ diff --git a/plugins/__pycache__/white2black_img.cpython-38.pyc b/plugins/__pycache__/white2black_img.cpython-38.pyc deleted file mode 100644 index 1d7a8d3e..00000000 Binary files a/plugins/__pycache__/white2black_img.cpython-38.pyc and /dev/null differ diff --git a/plugins/__pycache__/white2black_img.cpython-39.pyc b/plugins/__pycache__/white2black_img.cpython-39.pyc deleted file mode 100644 index 1b5d8c59..00000000 Binary files a/plugins/__pycache__/white2black_img.cpython-39.pyc and /dev/null differ diff --git a/plugins/aconfig/__init__.py b/plugins/aconfig/__init__.py deleted file mode 100644 index 90221aec..00000000 --- a/plugins/aconfig/__init__.py +++ /dev/null @@ -1,71 +0,0 @@ -import random -from nonebot import on_keyword -import os -from util.init_result import image -from configs.path_config import IMAGE_PATH -from nonebot import on_command -from nonebot.rule import to_me -from nonebot.typing import T_State -from nonebot.adapters.cqhttp import Bot, GroupMessageEvent, MessageEvent -from nonebot.adapters.cqhttp.permission import GROUP -from util.utils import FreqLimiter - - -__plugin_name__ = '基本设置 [Hidden]' -__plugin_usage__ = '用法: 基本' - - -_flmt = FreqLimiter(300) - - -config_playgame = on_keyword({'打游戏'}, permission=GROUP, priority=1, block=True) - - -@config_playgame.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - if not _flmt.check(event.group_id): - return - _flmt.start_cd(event.group_id) - await config_playgame.finish(image( - random.choice(os.listdir(IMAGE_PATH + "dayouxi/") - ), "dayouxi")) - - -self_introduction = on_command("自我介绍", aliases={'介绍', '你是谁', '你叫什么'}, - rule=to_me(), priority=5, block=True) - - -@self_introduction.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - result = "我叫绪山真寻\n" \ - "你们可以叫我真寻,小真寻,哪怕你们叫我小寻子我也能接受!\n" \ - "年龄的话我还是个**岁初中生(至少现在是)\n" \ - "身高保密!!!(也就比美波里(姐姐..(妹妹))矮一点)\n" \ - "我生日是在3月6号, 能记住的话我会很高兴的\n现在是自宅警备系的现役JC\n" \ - "最好的朋友是椛!\n"\ - + image("zhenxun") - await self_introduction.finish(result) - -laopo = on_keyword({'老婆'}, rule=to_me(), priority=5, block=True) - - -@laopo.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - await laopo.finish(image('laopo.jpg', 'other')) - - -# config_robot = on_keyword({"机器人"}, permission=GROUP, priority=5, block=True) -# @config_robot.handle() -# async def _(bot: Bot, event: Event, state: T_State): -# if not _flmt.check(event.group_id) or event.group_id == 774261838: -# return -# _flmt.start_cd(event.group_id) -# await config_robot.send("小真寻才不是机器人!") -# result = "我叫绪山真寻\n" \ -# "你们可以叫我真寻,小真寻,哪怕你们叫我小寻子我也能接受!\n" \ -# "年龄的话我还是个**岁初中生(至少现在是)\n" \ -# "身高保密!!!(也就比美波里(姐姐..(妹妹))矮一点)\n" \ -# "我生日是在3月6号, 能记住的话我会很高兴的\n现在是自宅警备系的现役JC\n" \ -# "最好的朋友是椛!\n"\ -# + image("zhenxun", "") -# await config_jieshao.finish(result) diff --git a/plugins/aconfig/__pycache__/__init__.cpython-38.pyc b/plugins/aconfig/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 42dacef3..00000000 Binary files a/plugins/aconfig/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/aconfig/__pycache__/__init__.cpython-39.pyc b/plugins/aconfig/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 11dcfb37..00000000 Binary files a/plugins/aconfig/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/admin_bot_manage/__init__.py b/plugins/admin_bot_manage/__init__.py deleted file mode 100644 index 891b1f82..00000000 --- a/plugins/admin_bot_manage/__init__.py +++ /dev/null @@ -1,88 +0,0 @@ -from nonebot import on_command -from util.utils import get_message_text, get_message_imgs, scheduler, get_bot -from nonebot.typing import T_State -from nonebot.adapters.cqhttp import Bot, GroupMessageEvent -from .data_source import set_group_status, custom_group_welcome, change_group_switch, \ - update_member_info, group_current_status -from nonebot.adapters.cqhttp.permission import GROUP -from services.log import logger -from configs.config import plugins2name_dict -from nonebot.plugin import export - -__plugin_usage__ = '''自定义进群欢迎消息: - 自定义进群欢迎消息 xxxx(图片) - 示例:自定义进群欢迎消息 欢迎新人!(后面可以跟一张图片噢)''' - -export = export() -export.update_member_info = update_member_info - -cmds = [] -for cmd_list in plugins2name_dict.values(): - for cmd in cmd_list: - cmds.append(f'开启{cmd}') - cmds.append(f'关闭{cmd}') -cmds = set(cmds) - -group_status = on_command('oc_reminds', aliases={'开启早晚安', '关闭早晚安', - '开启进群欢迎', '关闭进群欢迎', - '开启每日开箱重置提醒', '关闭每日开箱重置提醒', - '开启b站转发解析', '关闭b站转发解析', - '开启epic通知', '关闭epic通知', - '开启丢人爬', '关闭丢人爬', - '开启原神黄历提醒', '关闭原神黄历提醒', - '开启全部通知', '开启所有通知', '关闭全部通知', '关闭所有通知', - '群通知状态'}, permission=GROUP, priority=4, block=True) - -switch_rule = on_command('switch_rule', aliases=cmds, permission=GROUP, priority=4, block=True) -custom_welcome = on_command('自定义进群欢迎消息', aliases={'自定义欢迎消息', '自定义群欢迎消息'}, permission=GROUP, priority=5, block=True) -refresh_member_group = on_command("更新群组成员列表", aliases={"更新群组成员信息"}, permission=GROUP, priority=5, block=True) - - -@switch_rule.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - await switch_rule.send(await change_group_switch(state["_prefix"]["raw_command"].strip(), event.group_id)) - logger.info(f'USER {event.user_id} GROUP {event.group_id} 使用群功能管理命令 {state["_prefix"]["raw_command"]}') - - -@group_status.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - if state["_prefix"]["raw_command"] in ['群通知状态']: - await group_status.finish(await group_current_status(event.group_id)) - await group_status.send(await set_group_status(state["_prefix"]["raw_command"], event.group_id), - at_sender=True) - logger.info(f'USER {event.user_id} GROUP {event.group_id} 使用群通知管理命令 {state["_prefix"]["raw_command"]}') - - -@custom_welcome.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - if str(event.get_message()) in ['帮助'] or str(event.get_message()) == '': - await custom_welcome.finish(__plugin_usage__) - msg = get_message_text(event.json()) - imgs = get_message_imgs(event.json()) - await custom_welcome.finish(await custom_group_welcome(msg, imgs, event.user_id, event.group_id), at_sender=True) - - -@refresh_member_group.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - if await update_member_info(event.group_id): - await refresh_member_group.finish("更新群员信息成功!", at_sender=True) - else: - await refresh_member_group.finish("更新群员信息失败!", at_sender=True) - - -# 自动更新群员信息 -@scheduler.scheduled_job( - 'cron', - hour=2, - minute=1, -) -async def _(): - bot = get_bot() - gl = await bot.get_group_list(self_id=bot.self_id) - gl = [g['group_id'] for g in gl] - for g in gl: - try: - await update_member_info(g) - logger.info(f'更新群组 g:{g} 成功') - except Exception as e: - logger.error(f'更新群组错误 g:{g} e:{e}') diff --git a/plugins/admin_bot_manage/__pycache__/__init__.cpython-38.pyc b/plugins/admin_bot_manage/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 5a1526bb..00000000 Binary files a/plugins/admin_bot_manage/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/admin_bot_manage/__pycache__/__init__.cpython-39.pyc b/plugins/admin_bot_manage/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 098a4cde..00000000 Binary files a/plugins/admin_bot_manage/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/admin_bot_manage/__pycache__/data_source.cpython-38.pyc b/plugins/admin_bot_manage/__pycache__/data_source.cpython-38.pyc deleted file mode 100644 index 6f9fd211..00000000 Binary files a/plugins/admin_bot_manage/__pycache__/data_source.cpython-38.pyc and /dev/null differ diff --git a/plugins/admin_bot_manage/__pycache__/data_source.cpython-39.pyc b/plugins/admin_bot_manage/__pycache__/data_source.cpython-39.pyc deleted file mode 100644 index 5437c578..00000000 Binary files a/plugins/admin_bot_manage/__pycache__/data_source.cpython-39.pyc and /dev/null differ diff --git a/plugins/admin_bot_manage/data_source.py b/plugins/admin_bot_manage/data_source.py deleted file mode 100644 index 48f312fd..00000000 --- a/plugins/admin_bot_manage/data_source.py +++ /dev/null @@ -1,210 +0,0 @@ -from models.group_remind import GroupRemind -from services.log import logger -from configs.path_config import DATA_PATH -import os -import aiofiles -import aiohttp -from util.init_result import image -from util.utils import get_local_proxy, get_bot -from pathlib import Path -from nonebot import require -from configs.config import plugins2name_dict -from models.group_member_info import GroupInfoUser -import time -from datetime import datetime -from services.db_context import db -from models.level_user import LevelUser -from configs.config import ADMIN_DEFAULT_AUTH -try: - import ujson as json -except ModuleNotFoundError: - import json - - -export = require("nonebot_plugin_manager") - - -command_dict = { - '早晚安': 'zwa', - '进群欢迎': 'hy', - '每日开箱重置提醒': 'kxcz', - 'b站转发解析': 'blpar', - 'epic': 'epic', - '丢人爬': 'pa', - '原神黄历提醒': 'almanac', -} -command_list = list(command_dict.values()) -command_info_dt = { - '早晚安': '将会在每晚11:59晚安,在6:01早安哦', - '每日开箱重置提醒': '将会在每日00:01提示开箱重置!', - 'epic': '将会在每日中午12:01发送可白嫖的epic游戏', - '原神黄历提醒': '将会在每日8:00发送当日的原神黄历', -} - - -async def remind_status(group: int, name: str, flag: bool) -> str: - _name = '' - if name in command_dict.values(): - _name = list(command_dict.keys())[list(command_dict.values()).index(name)] - if flag: - rst = '开启' - if await GroupRemind.get_status(group, name): - return f'该群已经{rst}过 {_name},请勿重复开启!' - else: - rst = '关闭' - if not await GroupRemind.get_status(group, name): - return f'该群已经{rst}过 {_name},请勿重复开启!' - if await GroupRemind.set_status(group, name, flag): - info = command_info_dt[_name] if command_info_dt.get(_name) else '' - if info: - info = '\n' + info - return f'成功{rst} {_name}!0v0 {info}' - else: - return f'{rst} {_name} 失败了...' - - -async def set_group_status(name: str, group_id: int): - flag = None - if name[:2] == '开启': - flag = True - elif name[:2] == '关闭': - flag = False - cmd = name[2:] - if cmd in ['全部通知', '所有通知']: - for command in command_list: - await remind_status(group_id, command, flag) - return f'已{name[:2]}所有通知!' - return await remind_status(group_id, command_dict[cmd], flag) - - -async def group_current_status(group_id: int): - result = f'(被动技能)\n早晚安通知:{"√" if await GroupRemind.get_status(group_id, "zwa") else "×"}\n' \ - f'进群欢迎:{"√" if await GroupRemind.get_status(group_id, "hy") else "×"}\n' \ - f'每日开箱重置通知:{"√" if await GroupRemind.get_status(group_id, "kxcz") else "×"}\n' \ - f'b站转发解析:{"√" if await GroupRemind.get_status(group_id, "blpar") else "×"}\n' \ - f'丢人爬:{"√" if await GroupRemind.get_status(group_id, "pa") else "×"}\n' \ - f'epic免费游戏:{"√" if await GroupRemind.get_status(group_id, "epic") else "×"}\n' \ - f'原神黄历提醒:{"√" if await GroupRemind.get_status(group_id, "almanac") else "×"}' - return result - - -custom_welcome_msg_json = Path() / "data" / "custom_welcome_msg" / "custom_welcome_msg.json" - - -async def custom_group_welcome(msg, imgs, user_id, group_id): - img_result = '' - img = imgs[0] if imgs else '' - result = '' - if os.path.exists(DATA_PATH + f'custom_welcome_msg/{group_id}.jpg'): - os.remove(DATA_PATH + f'custom_welcome_msg/{group_id}.jpg') - # print(custom_welcome_msg_json) - if not custom_welcome_msg_json.exists(): - custom_welcome_msg_json.parent.mkdir(parents=True, exist_ok=True) - data = {} - else: - try: - data = json.load(open(custom_welcome_msg_json, 'r')) - except FileNotFoundError: - data = {} - try: - if msg: - data[str(group_id)] = str(msg) - json.dump(data, open(custom_welcome_msg_json, 'w'), indent=4, ensure_ascii=False) - logger.info(f'USER {user_id} GROUP {group_id} 更换群欢迎消息 {msg}') - result += msg - if img: - async with aiohttp.ClientSession() as session: - async with session.get(img, proxy=get_local_proxy()) as response: - async with aiofiles.open(DATA_PATH + f'custom_welcome_msg/{group_id}.jpg', 'wb') as f: - await f.write(await response.read()) - img_result = image(abspath=DATA_PATH + f'custom_welcome_msg/{group_id}.jpg') - logger.info(f'USER {user_id} GROUP {group_id} 更换群欢迎消息图片') - except Exception as e: - logger.error(f'GROUP {group_id} 替换群消息失败 e:{e}') - return '替换群消息失败..' - return f'替换群欢迎消息成功:\n{result}' + img_result - - -async def change_group_switch(cmd: str, group_id: int): - group_id = str(group_id) - status = cmd[:2] - cmd = cmd[2:] - try: - with open(DATA_PATH + 'manager/plugin_list.json', 'r', encoding='utf8') as f: - plugin_list = json.load(f) - except ValueError: - pass - except FileNotFoundError: - pass - for plugin_cmd in plugins2name_dict.keys(): - if cmd in plugins2name_dict[plugin_cmd]: - # print(plugin_list[plugin_cmd]) - if status == '开启': - # if group_id in plugin_list[plugin_cmd]: - if group_id not in plugin_list[plugin_cmd] or plugin_list[plugin_cmd][group_id]: - return f'功能 {cmd} 正处于开启状态!不要重复开启.' - export.unblock_plugin(group_id, plugin_cmd) - else: - if group_id in plugin_list[plugin_cmd]: - if not plugin_list[plugin_cmd][group_id]: - return f'功能 {cmd} 正处于关闭状态!不要重复关闭.' - export.block_plugin(group_id, plugin_cmd) - if os.path.exists(DATA_PATH + f'group_help/{group_id}.png'): - os.remove(DATA_PATH + f'group_help/{group_id}.png') - - return f'{status} {cmd} 功能!' - return f'没有找到 {cmd} 功能喔' - - -async def update_member_info(group_id: int) -> bool: - bot = get_bot() - _group_user_list = await bot.get_group_member_list(group_id=group_id) - _error_member_list = [] - _exist_member_list = [] - # try: - for user_info in _group_user_list: - if user_info['card'] == "": - nickname = user_info['nickname'] - else: - nickname = user_info['card'] - async with db.transaction(): - # 更新权限 - if user_info['role'] in ['owner', 'admin'] and not await LevelUser.is_group_flag(user_info['user_id'], group_id): - await LevelUser.set_level(user_info['user_id'], user_info['group_id'], ADMIN_DEFAULT_AUTH) - if str(user_info['user_id']) in bot.config.superusers: - await LevelUser.set_level(user_info['user_id'], user_info['group_id'], 9) - user = await GroupInfoUser.select_member_info(user_info['user_id'], user_info['group_id']) - if user: - if user.user_name != nickname: - await user.update(user_name=nickname).apply() - logger.info(f"用户{user_info['user_id']} 所属{user_info['group_id']} 更新群昵称成功") - _exist_member_list.append(int(user_info['user_id'])) - continue - join_time = datetime.strptime( - time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(user_info['join_time'])), "%Y-%m-%d %H:%M:%S") - if await GroupInfoUser.insert( - user_info['user_id'], - user_info['group_id'], - nickname, - join_time,): - _exist_member_list.append(int(user_info['user_id'])) - logger.info(f"用户{user_info['user_id']} 所属{user_info['group_id']} 更新成功") - else: - _error_member_list.append(f"用户{user_info['user_id']} 所属{user_info['group_id']} 更新失败\n") - _del_member_list = list(set(_exist_member_list).difference(set(await GroupInfoUser.query_group_member_list(group_id)))) - if _del_member_list: - for del_user in _del_member_list: - if await GroupInfoUser.delete_member_info(del_user, group_id): - logger.info(f"退群用户{del_user} 所属{group_id} 已删除") - else: - logger.info(f"退群用户{del_user} 所属{group_id} 删除失败") - if _error_member_list: - result = "" - for error_user in _error_member_list: - result += error_user - await bot.send_private_msg(user_id=int(list(bot.config.superusers)[0]), message=result[:-1]) - return True - - - - diff --git a/plugins/admin_config.py b/plugins/admin_config.py deleted file mode 100644 index a2b7b4a6..00000000 --- a/plugins/admin_config.py +++ /dev/null @@ -1,27 +0,0 @@ -from nonebot import on_notice -from services.log import logger -from nonebot.adapters.cqhttp import Bot, GroupAdminNoticeEvent -from nonebot.typing import T_State -from models.level_user import LevelUser -from models.group_member_info import GroupInfoUser -from configs.config import ADMIN_DEFAULT_AUTH - - -admin_notice = on_notice(priority=5) - - -@admin_notice.handle() -async def _(bot: Bot, event: GroupAdminNoticeEvent, state: T_State): - try: - nickname = (await GroupInfoUser.select_member_info(event.user_id, event.group_id)).user_name - except AttributeError: - nickname = event.user_id - if event.sub_type == 'set': - await LevelUser.set_level(event.user_id, event.group_id, ADMIN_DEFAULT_AUTH) - logger.info(f'为新晋管理员 {nickname}({event.user_id}) 添加权限等级:{ADMIN_DEFAULT_AUTH}') - if event.sub_type == 'unset': - await LevelUser.delete_level(event.user_id, event.group_id) - logger.info(f'将非管理员 {nickname}({event.user_id}) 取消权限等级') - - - diff --git a/plugins/admin_help/__init__.py b/plugins/admin_help/__init__.py deleted file mode 100644 index 2b1e8afc..00000000 --- a/plugins/admin_help/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from nonebot import on_command -from nonebot.typing import T_State -from nonebot.adapters import Bot -from nonebot.adapters.cqhttp import GroupMessageEvent -from util.img_utils import CreateImg -from configs.path_config import IMAGE_PATH -from util.init_result import image - - -__plugin_name__ = '管理帮助 [Hidden]' -__plugin_usage__ = '''管理帮助(权限等级): - 1.更新群组成员列表(1) - 2.功能开关 --> 指令:开启/关闭xx功能(2) - 3.查看群被动技能 --> 指令:群通知状态(2) - 4.自定义群欢迎 --> 指令:自定义进群欢迎消息(2) - 5.将用户拉入真寻黑名单 --> .ban/.unban(5) - 6.刷屏禁言相关 --> 指令:刷屏检测设置/设置检测时间 - \t\t/设置检测次数/设置禁言时长(5) - 7.上传图片(6) - 8.移动图片(7) - 9.删除图片(7) -对我说 “指令名 帮助” 获取对应详细帮助 -群主与管理员默认 5 级权限 -''' - -passive_help = '''【被动技能开关(2): - 开启/关闭进群欢迎 - 开启/关闭每日开箱重置提醒 - 开启/关闭b站转发解析 - 开启/关闭丢人爬 - 开启/关闭epic通知 - 开启/关闭全部通知 - 开启/关闭原神黄历提醒】 -''' - -admin_help = on_command("管理员帮助", aliases={"管理帮助"}, priority=5, block=True) - -admin_help_img = CreateImg(1000, 600, font_size=24) -admin_help_img.text((10, 10), __plugin_usage__) -admin_help_img.paste(CreateImg(400, 600, font_size=24).text((0, 0), passive_help), (600, 50)) -admin_help_img.save(IMAGE_PATH + 'admin_help_img.png') - - -@admin_help.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - await admin_help.send(image('admin_help_img.png')) diff --git a/plugins/admin_help/__pycache__/__init__.cpython-38.pyc b/plugins/admin_help/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 2a943938..00000000 Binary files a/plugins/admin_help/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/admin_help/__pycache__/__init__.cpython-39.pyc b/plugins/admin_help/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 569123fd..00000000 Binary files a/plugins/admin_help/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/ai/__init__.py b/plugins/ai/__init__.py deleted file mode 100644 index 64a84913..00000000 --- a/plugins/ai/__init__.py +++ /dev/null @@ -1,61 +0,0 @@ -from .data_source import get_qqbot_chat_result, hello, no_result -from services.log import logger -from nonebot import on_message -from nonebot.rule import to_me -from nonebot.typing import T_State -from nonebot.adapters.cqhttp import Bot, GroupMessageEvent, PrivateMessageEvent -from util.utils import get_message_text, get_message_imgs -from models.friend_user import FriendUser -from models.group_member_info import GroupInfoUser - -__plugin_name__ = 'AI' - - -ai = on_message(rule=to_me(), priority=8) - - -@ai.handle() -async def _(bot: Bot, event: PrivateMessageEvent, state: T_State): - msg = get_message_text(event.json()) - imgs = get_message_imgs(event.json()) - if str(event.get_message()).find('CQ:xml') != -1: - return - # 打招呼 - if not msg and not imgs: - await ai.finish(hello()) - img = imgs[0] if imgs else '' - nickname = await FriendUser.get_friend_nickname(event.user_id) - if not nickname: - nickname = await FriendUser.get_user_name(event.user_id) - if not nickname: - nickname = "你" - result = await get_qqbot_chat_result(msg, img, event.user_id, nickname) - logger.info(f"USER {event.user_id} 问题:{msg}\n回答:{result}") - if result: - await ai.finish(result) - else: - await ai.finish(no_result()) - - -@ai.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - # if await GroupRemind.get_status(event.group_id, 'ai'): - msg = get_message_text(event.json()) - imgs = get_message_imgs(event.json()) - # 打招呼 - if not msg and not imgs: - await ai.finish(hello()) - img = imgs[0] if imgs else '' - nickname = await GroupInfoUser.get_group_member_nickname(event.user_id, event.group_id) - if not nickname: - try: - nickname = (await GroupInfoUser.select_member_info(event.user_id, event.group_id)).user_name - except AttributeError: - nickname = "你" - result = await get_qqbot_chat_result(msg, img, event.user_id, nickname) - logger.info(f"问题:{msg}\n回答:{result}") - if result: - await ai.finish(result) - else: - await ai.finish(no_result()) - diff --git a/plugins/ai/__pycache__/__init__.cpython-38.pyc b/plugins/ai/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index c8ad1e1f..00000000 Binary files a/plugins/ai/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/ai/__pycache__/__init__.cpython-39.pyc b/plugins/ai/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index f3e1b82b..00000000 Binary files a/plugins/ai/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/ai/__pycache__/data_source.cpython-38.pyc b/plugins/ai/__pycache__/data_source.cpython-38.pyc deleted file mode 100644 index 43b03ebe..00000000 Binary files a/plugins/ai/__pycache__/data_source.cpython-38.pyc and /dev/null differ diff --git a/plugins/ai/__pycache__/data_source.cpython-39.pyc b/plugins/ai/__pycache__/data_source.cpython-39.pyc deleted file mode 100644 index 4eaa7fd0..00000000 Binary files a/plugins/ai/__pycache__/data_source.cpython-39.pyc and /dev/null differ diff --git a/plugins/ai/data_source.py b/plugins/ai/data_source.py deleted file mode 100644 index bfc333bc..00000000 --- a/plugins/ai/data_source.py +++ /dev/null @@ -1,142 +0,0 @@ -from configs.config import TL_KEY -import aiohttp -import random -import os -from configs.path_config import IMAGE_PATH, DATA_PATH -from util.init_result import image -from util.utils import get_bot - -try: - import ujson as json -except ModuleNotFoundError: - import json - -url = "http://openapi.tuling123.com/openapi/api/v2" - -index = 0 - -anime_data = json.load(open(DATA_PATH + 'anime.json', 'r', encoding='utf8')) - - -# 图灵AI -async def get_qqbot_chat_result(text: str, img_url: str, user_id: int, user_name: str) -> str: - global index - if index == 5: - index = 0 - if len(text) < 6 and random.random() < 0.6: - keys = anime_data.keys() - for key in keys: - if text.find(key) != -1: - return random.choice(anime_data[key]).replace('你', user_name) - if text: - req = { - "perception": - { - "inputText": - { - "text": text - }, - "selfInfo": - { - "location": - { - "city": "陨石坑", - "province": "火星", - "street": "第5坑位" - } - } - }, - "userInfo": - { - "apiKey": TL_KEY[index], - "userId": str(user_id) - } - } - elif img_url: - req = { - "reqType": 1, - "perception": - { - "inputImage": { - "url": img_url - }, - "selfInfo": - { - "location": - { - "city": "陨石坑", - "province": "火星", - "street": "第5坑位" - } - } - }, - "userInfo": - { - "apiKey": TL_KEY[index], - "userId": str(user_id) - } - } - async with aiohttp.ClientSession() as sess: - async with sess.post(url, json=req) as response: - if response.status != 200: - return '' - resp_payload = json.loads(await response.text()) - if resp_payload['intent']: - if resp_payload['intent']['code'] == 4003: - index += 1 - # 该AI很屑!!!!!!!!!!!! - async with sess.get(f'http://api.qingyunke.com/api.php?key=free&appid=0&msg={text}') as res: - data = json.loads(await res.text()) - if data['result'] == 0: - content = data['content'] - if content.find('菲菲') != -1: - content = content.replace('菲菲', list(get_bot().config.nickname)[0]) - if content.find('公众号') != -1: - content = '' - if content.find('{br}') != -1: - content = content.replace('{br}', '\n') - if content.find('提示') != -1: - content = content[:content.find('提示')] - return content - if resp_payload['results']: - for result in resp_payload['results']: - if result['resultType'] == 'text': - text = result['values']['text'] - if user_name: - text = text.replace('小朋友', user_name) - if len(user_name) < 5: - if random.random() < 0.5: - user_name = "~".join(user_name) + '~' - if random.random() < 0.5: - if user_name.find('大人') == -1: - user_name += '大~人~' - text = text.replace('小主人', user_name) - return text - - -def hello() -> str: - result = random.choice(( - "哦豁?!", - "你好!Ov<", - f"库库库,呼唤{list(get_bot().config.nickname)[0]}做什么呢", - "我在呢!", - "呼呼,叫俺干嘛" - )) - img = random.choice(os.listdir(IMAGE_PATH + "zai/")) - if img[-4:] == ".gif": - result += image(img, "zai") - else: - result += image(img, "zai") - return result - - -def no_result() -> str: - return random.choice([ - '你在说啥子?', - f'纯洁的{list(get_bot().config.nickname)[0]}没听懂', - '下次再告诉你(下次一定)', - '你觉得我听懂了吗?嗯?', - '我!不!知!道!' - ]) + image( - random.choice(os.listdir(IMAGE_PATH + "noresult/") - ), "noresult") diff --git a/plugins/auto_invite/__init__.py b/plugins/auto_invite/__init__.py deleted file mode 100644 index 6e971406..00000000 --- a/plugins/auto_invite/__init__.py +++ /dev/null @@ -1,44 +0,0 @@ -from nonebot import on_request -from nonebot.adapters.cqhttp import Bot, FriendRequestEvent, GroupRequestEvent -from models.friend_user import FriendUser -from datetime import datetime -from configs.config import AUTO_ADD_FRIEND -from nonebot.adapters.cqhttp.exception import ActionFailed - -__plugin_name__ = '处理请求' - -friend_req = on_request(priority=5) - - -@friend_req.handle() -async def _(bot: Bot, event: FriendRequestEvent, state: dict): - if AUTO_ADD_FRIEND: - nickname = '' - for user in await bot.get_friend_list(): - if user['user_id'] == event.user_id: - nickname = user['nickname'] - await FriendUser.add_friend_info(user['user_id'], user['nickname']) - break - await bot.send_private_msg(user_id=int(list(bot.config.superusers)[0]), message=f"{nickname}({event.user_id})" - f" 添加小真寻好友(已自动同意)") - await bot.set_friend_add_request(flag=event.flag, approve=True) - - -group_req = on_request(priority=5, block=True) - - -@group_req.handle() -async def _(bot: Bot, event: GroupRequestEvent, state: dict): - if event.sub_type == 'invite': - nickname = await FriendUser.get_user_name(event.user_id) - if str(event.user_id) in bot.config.superusers: - try: - await bot.set_group_add_request(flag=event.flag, sub_type='invite', approve=True) - except ActionFailed: - pass - else: - await bot.send_private_msg(user_id=int(list(bot.config.superusers)[0]), - message=f"报告..\n{nickname}({event.user_id})" - f" 希望邀请我加入 {event.group_id}\n邀请日期:{str(datetime.now()).split('.')[0]}") - await bot.send_private_msg(user_id=event.user_id, - message="想要邀请我偷偷入群嘛~~已经提醒管理员了\n等待管理员处理吧~") diff --git a/plugins/auto_invite/__pycache__/__init__.cpython-38.pyc b/plugins/auto_invite/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index bc01b25a..00000000 Binary files a/plugins/auto_invite/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/auto_invite/__pycache__/__init__.cpython-39.pyc b/plugins/auto_invite/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 9a9a1a90..00000000 Binary files a/plugins/auto_invite/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/ban/__init__.py b/plugins/ban/__init__.py deleted file mode 100644 index 543ede34..00000000 --- a/plugins/ban/__init__.py +++ /dev/null @@ -1,82 +0,0 @@ -from nonebot import on_command -from models.ban_user import BanUser -from models.level_user import LevelUser -from nonebot.typing import T_State -from nonebot.adapters import Bot -from nonebot.adapters.cqhttp import GroupMessageEvent -from nonebot.adapters.cqhttp.permission import GROUP -from util.utils import get_message_at, get_message_text, is_number -from services.log import logger -from models.group_member_info import GroupInfoUser - - -__plugin_name__ = 'Ban/unBan' -__plugin_usage__ = f'用法: 封禁/解封用户(不是禁言!是针对bot是否处理封禁用户消息)\n' \ - '示例:.ban @djdsk\n' \ - '示例:.ban @djdsk 0(小时) 30(分钟)\n' \ - '示例:.ban @sdasf 4(小时)\n' \ - '示例:.unban @sdasf' - - -ban = on_command(".ban", aliases={'.unban', '/ban', '/unban'}, priority=5, permission=GROUP, block=True) - - -@ban.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - if get_message_text(event.json()) in ['帮助'] or str(event.get_message()) == '': - await ban.finish(__plugin_usage__) - # try: - result = '' - qq = int(get_message_at(event.json())[0]) - if qq: - nickname = await GroupInfoUser.get_group_member_nickname(qq, event.group_id) - if not nickname: - nickname = '用户' - msg = get_message_text(event.json()) - if msg: - msg = msg.split(" ") - if len(msg) == 2: - if not is_number(msg[0].strip()) or not is_number(msg[1].strip()): - await ban.finish('参数必须是数字!', at_sender=True) - time = int(msg[0]) * 60 * 60 + int(msg[1]) * 60 - else: - if not is_number(msg[0].strip()): - await ban.finish('参数必须是数字!', at_sender=True) - time = int(msg[0]) * 60 * 60 - else: - time = -1 - if state["_prefix"]["raw_command"] in [".ban", '/ban']: - if await LevelUser.get_user_level(event.user_id, event.group_id) <= await \ - LevelUser.get_user_level(qq, event.group_id) and str(event.user_id) not in bot.config.superusers: - await ban.finish(f"您的权限等级比对方低或相等, {list(bot.config.nickname)[0]}不能为您使用此功能!", at_sender=True) - if await BanUser.ban(qq, await LevelUser.get_user_level(event.user_id, event.group_id), time): - logger.info(f"USER {event.user_id} GROUP {event.group_id} 将 USER {qq} 封禁 时长 {time/60} 分钟") - result = f"已经将 {nickname} 加入{list(bot.config.nickname)[0]}的黑名单了!" - if time != -1: - result += f"将在 {time/60} 分钟后解封" - else: - time = await BanUser.check_ban_time(qq) - if is_number(time): - time = abs(time) - if time < 60: - time = str(int(time)) + ' 秒' - else: - time = str(int(time / 60)) + ' 分钟' - else: - time += ' 分钟' - result = f"{nickname} 已在黑名单!预计 {time}后解封" - else: - if await BanUser.check_ban_level(qq, await LevelUser.get_user_level(event.user_id, event.group_id)) and\ - str(event.user_id) not in bot.config.superusers: - await ban.finish(f"ban掉 {nickname} 的管理员权限比您高,无法进行unban", at_sender=True) - if await BanUser.unban(qq): - logger.info(f"USER {event.user_id} GROUP {event.group_id} 将 USER {qq} 解禁") - result = f"已经把 {nickname} 从黑名单中删除了!" - else: - result = f"{nickname} 不在黑名单!" - else: - await ban.finish('艾特人了吗??', at_sender=True) - # except Exception as e: - # result = 'ban/unban执行出错,确定艾特人了吗?' - # logger.error(f'ban/unban执行出错 e:{e}') - await ban.finish(result, at_sender=True) diff --git a/plugins/ban/__pycache__/__init__.cpython-38.pyc b/plugins/ban/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index e38a327f..00000000 Binary files a/plugins/ban/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/ban/__pycache__/__init__.cpython-39.pyc b/plugins/ban/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 3bb7d493..00000000 Binary files a/plugins/ban/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/broadcast/__init__.py b/plugins/broadcast/__init__.py deleted file mode 100644 index cf40fcd3..00000000 --- a/plugins/broadcast/__init__.py +++ /dev/null @@ -1,44 +0,0 @@ -from nonebot import on_command -from nonebot.typing import T_State -from nonebot.adapters import Bot, Event -from nonebot.permission import SUPERUSER -import asyncio -from util.utils import get_message_text, get_message_imgs -from services.log import logger -from models.group_remind import GroupRemind -from util.init_result import image - -broadcast = on_command("广播-", priority=1, permission=SUPERUSER, block=True) - - -@broadcast.handle() -async def _(bot: Bot, event: Event, state: T_State): - msg = get_message_text(event.json()) - imgs = get_message_imgs(event.json()) - rst = '' - for img in imgs: - rst += image(img) - sid = bot.self_id - gl = await bot.get_group_list(self_id=sid) - gl = [g['group_id'] for g in gl] - for g in gl: - if await GroupRemind.get_status(g, 'gb'): - await asyncio.sleep(0.5) - try: - await bot.send_group_msg(self_id=sid, group_id=g, message=msg+rst) - logger.info(f'群{g} 投递广播成功') - except Exception as e: - logger.error(f'群{g} 投递广播失败:{type(e)}') - try: - await broadcast.send(f'群{g} 投递广播失败:{type(e)}') - except Exception as e: - logger.critical(f'向广播发起者进行错误回报时发生错误:{type(e)}') - await broadcast.send(f'广播完成!') - - - - - - - - diff --git a/plugins/broadcast/__pycache__/__init__.cpython-38.pyc b/plugins/broadcast/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 4afd8a50..00000000 Binary files a/plugins/broadcast/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/broadcast/__pycache__/__init__.cpython-39.pyc b/plugins/broadcast/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index b196d44e..00000000 Binary files a/plugins/broadcast/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/bt/__init__.py b/plugins/bt/__init__.py deleted file mode 100644 index 7e2e79a8..00000000 --- a/plugins/bt/__init__.py +++ /dev/null @@ -1,95 +0,0 @@ -from nonebot import on_command -from .data_source import get_bt_info -from services.log import logger -from nonebot.typing import T_State -from nonebot.adapters import Bot -from nonebot.adapters.cqhttp import PrivateMessageEvent -from util.utils import get_message_text -from nonebot.adapters.cqhttp.permission import PRIVATE -from util.utils import UserExistLimiter - -__plugin_name__ = '磁力搜索' -__plugin_usage__ = r""" -* 请各位使用后不要转发 * -* 有时可能搜不到,再试一次就行了 * -参数: -U(时间) -H(热度) -S(大小) - -V(仅视频) -P(仅图片) -A(仅压缩包) - -R (R18懂的都懂) - num(页数, 如果不知道页数请不要填,并且是倒叙,比如页数总数是29,你想查看第一页的内容, 就使用 bt 29 xxx) --按相关度检索(默认) -bt [关键词] --按更新时间检索(参数不区分大小写,但要注意空格) -bt -U [关键词] --搜索第10页数 -bt 10(倒着) [关键词] -""".strip() - -_ulmt = UserExistLimiter() - -bt = on_command('bt', permission=PRIVATE, priority=5, block=True) - - -@bt.args_parser -async def _(bot: Bot, event: PrivateMessageEvent, state: T_State): - if str(event.get_message()) in ['取消', '算了']: - await bt.finish("已取消操作..", at_sender=True) - msg = get_message_text(event.json()) - if not msg: - await bt.reject('你想搜索什么呢?', at_sender=True) - mp = msg.split(" ") - if len(mp) > 1: - args = '' - for i in range(len(mp) - 1): - args += mp[i] + ' ' - state['args'] = args - state['bt'] = mp[1] - else: - state['bt'] = get_message_text(event.json()) - state['args'] = '' - - -@bt.handle() -async def _(bot: Bot, event: PrivateMessageEvent, state: T_State): - if get_message_text(event.json()) in ['帮助'] or str(event.get_message()) == '': - await bt.finish(__plugin_usage__) - if _ulmt.check(event.user_id): - await bt.finish('您有bt任务正在进行,请等待结束.', at_sender=True) - mp = get_message_text(event.json()).split(" ") - if len(mp) > 1: - args = '' - for i in range(len(mp) - 1): - args += mp[i] + ' ' - state['args'] = args.strip() - state['bt'] = mp[-1] - else: - state['bt'] = get_message_text(event.json()) - state['args'] = '' - - -@bt.got('bt', prompt='虚空磁力?查什么GKD') -async def _(bot: Bot, event: PrivateMessageEvent, state: T_State): - _ulmt.set_True(event.user_id) - keyword = state['bt'] - args = state['args'] - await bt.send('开始搜索....', at_sender=True) - try: - if args.find('-R') == -1 and args.find('-r') == -1: - bt_report = await get_bt_info(keyword, args) - else: - bt_report = await get_bt_info(keyword, args, '0') - if bt_report: - if len(bt_report.split("\n")) < 2: - await bt.finish(bt_report + '搜索失败了,再试一次也许能成', at_sender=True) - else: - await bt.send("如果有页数没资源请再试一次\n" + bt_report) - logger.info( - f"(USER {event.user_id}, GROUP {event.group_id if event.message_type != 'private' else 'private'})" - f" 搜索bt {args} {keyword}") - else: - logger.error("没查询到资源") - await bt.send("没有查询到资源(也有可能是超时,再试一次?)", at_sender=True) - _ulmt.set_False(event.user_id) - except Exception as e: - _ulmt.set_False(event.user_id) - await bt.send("bt出错啦,再试一次?", at_sender=True) - logger.info(f'bt {keyword} 出错 e:{e}') diff --git a/plugins/bt/__pycache__/__init__.cpython-38.pyc b/plugins/bt/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 01bdabee..00000000 Binary files a/plugins/bt/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/bt/__pycache__/__init__.cpython-39.pyc b/plugins/bt/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 58d50e12..00000000 Binary files a/plugins/bt/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/bt/__pycache__/data_source.cpython-38.pyc b/plugins/bt/__pycache__/data_source.cpython-38.pyc deleted file mode 100644 index 0d4af9b7..00000000 Binary files a/plugins/bt/__pycache__/data_source.cpython-38.pyc and /dev/null differ diff --git a/plugins/bt/__pycache__/data_source.cpython-39.pyc b/plugins/bt/__pycache__/data_source.cpython-39.pyc deleted file mode 100644 index f7c47d95..00000000 Binary files a/plugins/bt/__pycache__/data_source.cpython-39.pyc and /dev/null differ diff --git a/plugins/bt/data_source.py b/plugins/bt/data_source.py deleted file mode 100644 index b00ee71c..00000000 --- a/plugins/bt/data_source.py +++ /dev/null @@ -1,96 +0,0 @@ -from util.user_agent import get_user_agent -import aiohttp -from lxml import etree -from lxml.etree import Element -from configs.config import MAXINFO_BT -from urllib import parse -from html import unescape -from util.utils import get_local_proxy, is_number -import time -import platform -if platform.system() == 'Windows': - import asyncio - asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) - - -url = 'https://www.btmet.com/search.php' - - -async def get_bt_info(keyword: str, args: str, r18: str = '1') -> str: - cookiesDit = { - 'r18': r18 - } - s_time = time.time() - params = get_params(keyword, args) - async with aiohttp.ClientSession(headers=get_user_agent(), cookies=cookiesDit) as session: - async with session.get(url, proxy=get_local_proxy(), params=params, timeout=30) as response: - html = etree.HTML(await response.text()) - print(response.url) - num = html.xpath('//div[@id="wall"]//span/b/text()')[0] - print(num) - if num.find(",") != -1: - num = num.split(',')[0] - if num == '0': - return "没有找到记录" - - div_all = html.xpath('//div[@class="search-item"]')[1:] - div_all = div_all[:MAXINFO_BT] if len(div_all) > MAXINFO_BT else div_all - line_list = [await get_item_line(div) for div in div_all] - clist = [] - for line in line_list: - if line.strip() != '': - clist.append(line) - - return f"搜索 {keyword} 结果(共 {int(int(num.text) / 10) if int(num) % 10 == 0 else int(int(num) / 10) + 1} " \ - f"页)(耗时 {int(time.time() - s_time)} 秒):\n" + "\n\n".join(clist) - - -async def get_item_line(div: Element) -> str: - try: - magent = div.xpath('./div[2]/a/@href')[0] - size = div.xpath('./div[@class="f_left"]/div[@class="item-bar"]/span/b/font/text()')[0] - type = div.xpath('./div[@class="f_left"]/div[@class="item-bar"]/span[@class="cpill blue-pill"]/text()')[0].strip() - - title_doc = div.xpath('.//a[@class="smashTitle"]//text()')[0] - title_code = title_doc[title_doc.find('("') + 2: title_doc.find('")')] - title_xml_code = parse.unquote(title_code) - title_xml = etree.HTML(unescape(title_xml_code)) - title = title_xml.xpath('string(.)') - except Exception: - return '' - return "【{}】| {}\n【{}】| {}".format(type, title, size, magent) - - -# https://www.btmet.com/search.php?q=%E9%92%A2%E9%93%81%E4%BE%A0&c=5&o=0&l=&p=2 -def get_params(keyword: str, args: str) -> dict: - params = { - 'q': keyword, - 'c': '', - 'l': '', - 'o': 0, - 'p': '' - } - if not args: - return params - args = args.split(" ") - for arg in args: - if '-U' == arg.upper(): - params['o'] = 1 - if '-S' == arg.upper(): - params['o'] = 2 - if '-H' == arg.upper(): - params['o'] = 3 - if '-V' == arg.upper(): - params['c'] = 1 - if '-P' == arg.upper(): - params['c'] = 2 - if '-A' == arg.upper(): - params['c'] = 5 - if is_number(arg): - params['p'] = arg - return params - - -# print(asyncio.get_event_loop().run_until_complete(get_bt_info('钢铁侠', ''))) - - diff --git a/plugins/check/__init__.py b/plugins/check/__init__.py deleted file mode 100644 index 78c96318..00000000 --- a/plugins/check/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ - -from nonebot import on_command -from .data_source import Check -from nonebot.adapters.cqhttp import Bot, Event -from nonebot.typing import T_State -from nonebot.rule import to_me -from nonebot.permission import SUPERUSER - - -__plugin_name__ = '自我检查' - -check = Check() - - -check_ = on_command('自检', aliases={'check'}, rule=to_me(), permission=SUPERUSER, block=True, priority=1) - - -@check_.handle() -async def _(bot: Bot, event: Event, state: T_State): - await check_.send(await check.show()) diff --git a/plugins/check/__pycache__/__init__.cpython-38.pyc b/plugins/check/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 0735d60d..00000000 Binary files a/plugins/check/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/check/__pycache__/__init__.cpython-39.pyc b/plugins/check/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 5bfd5f68..00000000 Binary files a/plugins/check/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/check/__pycache__/data_source.cpython-38.pyc b/plugins/check/__pycache__/data_source.cpython-38.pyc deleted file mode 100644 index 279d1374..00000000 Binary files a/plugins/check/__pycache__/data_source.cpython-38.pyc and /dev/null differ diff --git a/plugins/check/__pycache__/data_source.cpython-39.pyc b/plugins/check/__pycache__/data_source.cpython-39.pyc deleted file mode 100644 index dcfa2938..00000000 Binary files a/plugins/check/__pycache__/data_source.cpython-39.pyc and /dev/null differ diff --git a/plugins/check/data_source.py b/plugins/check/data_source.py deleted file mode 100644 index 865769fe..00000000 --- a/plugins/check/data_source.py +++ /dev/null @@ -1,67 +0,0 @@ -import psutil -import aiohttp -import time -from datetime import datetime -from util.user_agent import get_user_agent -from asyncio.exceptions import TimeoutError -from aiohttp.client_exceptions import ClientConnectorError -from util.utils import get_local_proxy -import asyncio -from services.log import logger - - -class Check: - def __init__(self): - self.cpu = None - self.memory = None - self.disk = None - self.user = None - self.baidu = 200 - self.google = 200 - - async def check_all(self): - await self.check_network() - await asyncio.sleep(0.1) - self.check_system() - self.check_user() - - def check_system(self): - self.cpu = psutil.cpu_percent() - self.memory = psutil.virtual_memory().percent - self.disk = psutil.disk_usage("/").percent - - async def check_network(self): - async with aiohttp.ClientSession(headers=get_user_agent()) as session: - try: - async with session.get('https://www.baidu.com/', proxy=get_local_proxy(), timeout=3) as response: - pass - except (TimeoutError, ClientConnectorError) as e: - logger.warning(f'访问BaiDu失败... e: {e}') - self.baidu = 404 - try: - async with session.get('https://www.google.com/', proxy=get_local_proxy(), timeout=3) as response: - pass - except (TimeoutError, ClientConnectorError) as e: - logger.warning(f'访问Google失败... e: {e}') - self.google = 404 - - def check_user(self): - rst = '' - for user in psutil.users(): - rst += f'[{user.name}] {time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(user.started))}\n' - self.user = rst[:-1] - - async def show(self): - await self.check_all() - rst = f'[Time] {str(datetime.now()).split(".")[0]}\n' \ - f'-----System-----\n' \ - f'[CPU] {self.cpu}%\n' \ - f'[Memory] {self.memory}%\n' \ - f'[Disk] {self.disk}%\n' \ - f'-----Network-----\n' \ - f'[BaiDu] {self.baidu}\n' \ - f'[Google] {self.google}\n' - if self.user: - rst += '-----User-----\n' + self.user - return rst - diff --git a/plugins/coser/__init__.py b/plugins/coser/__init__.py deleted file mode 100644 index 2e8ec9bf..00000000 --- a/plugins/coser/__init__.py +++ /dev/null @@ -1,39 +0,0 @@ -from nonebot import on_command -from util.utils import get_message_text -from nonebot.typing import T_State -from nonebot.adapters import Bot, Event -from services.log import logger -from util.init_result import image -import requests - -__plugin_usage_coser__ = '不得看看可爱的coser?发送‘coser’' - - -coser = on_command('cos', aliases={'coser', '括丝'}, priority=5, block=True) - - -url_2 = 'http://api.rosysun.cn/cos' - - -@coser.handle() -async def _(bot: Bot, event: Event, state: T_State): - if get_message_text(event.json()) in ['帮助']: - await coser.finish(__plugin_usage_coser__) - img_url = requests.get(url_2).text - await coser.send(image(img_url)) - logger.info( - f"(USER {event.user_id}, GROUP {event.group_id if event.message_type != 'private' else 'private'}) 发送COSER") - - - - - - - - - - - - - - diff --git a/plugins/coser/__pycache__/__init__.cpython-38.pyc b/plugins/coser/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 45df0634..00000000 Binary files a/plugins/coser/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/coser/__pycache__/__init__.cpython-39.pyc b/plugins/coser/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index fd08ed41..00000000 Binary files a/plugins/coser/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/delete_img/__init__.py b/plugins/delete_img/__init__.py deleted file mode 100644 index 9c20ee64..00000000 --- a/plugins/delete_img/__init__.py +++ /dev/null @@ -1,79 +0,0 @@ -from configs.path_config import IMAGE_PATH, TEMP_PATH -import os -from util.init_result import image -from services.log import logger -from nonebot import on_command -from nonebot.rule import to_me -from nonebot.typing import T_State -from nonebot.adapters import Bot, Event -from configs.config import IMAGE_DIR_LIST -from util.utils import is_number, cn2py - -__plugin_name__ = '删除图片' -__plugin_usage__ = '删除图片帮助:\n\t' \ - '1.查看列表 --> 指令: 删除图片 列表/目录\n\t' \ - '2.删除图片 图库 id, 即在相应目录下删除图片\n\t\t示例: 删除图片 色图 1 ' - - -delete_img = on_command("删除图片", priority=5, rule=to_me(), block=True) - - -@delete_img.args_parser -async def parse(bot: Bot, event: Event, state: T_State): - if str(event.get_message()) in ['取消', '算了']: - await delete_img.finish("已取消操作..", at_sender=True) - if state["_current_key"] in ['path']: - if str(event.get_message()) not in IMAGE_DIR_LIST: - await delete_img.reject("此目录不正确,请重新输入目录!") - state[state["_current_key"]] = str(event.get_message()) - if state["_current_key"] == 'id': - if not is_number(str(event.get_message())): - await delete_img.reject("id不正确!请重新输入数字...") - state[state["_current_key"]] = str(event.get_message()) - - -@delete_img.handle() -async def _(bot: Bot, event: Event, state: T_State): - raw_arg = str(event.get_message()).strip() - if raw_arg: - args = raw_arg.split(" ") - if args[0] in ['帮助']: - await delete_img.finish(__plugin_usage__) - if len(args) >= 2 and args[0] in IMAGE_DIR_LIST and is_number(args[1]): - state['path'] = args[0] - state['id'] = args[1] - - -@delete_img.got("path", prompt="请输入要删除的目标图库?") -@delete_img.got("id", prompt="请输入要删除的图片id?") -async def arg_handle(bot: Bot, event: Event, state: T_State): - path = cn2py(state['path']) - img_id = state['id'] - path = IMAGE_PATH + path - max_id = len(os.listdir(path)) - 1 - if int(img_id) > max_id or int(img_id) < 0: - await delete_img.finish(f"Id超过上下限,上限:{max_id}", at_sender=True) - try: - if os.path.exists(IMAGE_PATH + TEMP_PATH + "delete.jpg"): - os.remove(IMAGE_PATH + TEMP_PATH + "delete.jpg") - logger.info("删除图片 delete.jpg 成功") - except Exception as e: - logger.warning(f"删除图片 delete.jpg 失败 e{e}") - try: - os.rename(path + img_id + ".jpg", IMAGE_PATH + TEMP_PATH + "delete.jpg") - logger.info(f"移动 {path}{img_id}.jpg 移动成功") - except Exception as e: - logger.warning(f"{path}{img_id}.jpg --> 移动失败 e:{e}") - if not os.path.exists(path + img_id + ".jpg"): - try: - if int(img_id) != max_id: - os.rename(path + str(max_id) + ".jpg", path + img_id + ".jpg") - except FileExistsError: - logger.error(f"{path}{max_id}.jpg 替换 {path}{img_id}.jpg 失败 e:{e}") - logger.info(f"{path}{max_id}.jpg 替换 {path}{img_id}.jpg 成功") - logger.info(f"USER {event.user_id} GROUP {event.group_id if event.message_type != 'private' else 'private'}" - f" -> id: {img_id} 删除成功") - await delete_img.finish(f"id: {img_id} 删除成功" + image("delete.jpg", TEMP_PATH), at_sender=True) - await delete_img.finish(f"id: {img_id} 删除失败!") - - diff --git a/plugins/delete_img/__pycache__/__init__.cpython-38.pyc b/plugins/delete_img/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index bf87c76e..00000000 Binary files a/plugins/delete_img/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/delete_img/__pycache__/__init__.cpython-39.pyc b/plugins/delete_img/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index e6418283..00000000 Binary files a/plugins/delete_img/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/dialogue/__init__.py b/plugins/dialogue/__init__.py deleted file mode 100644 index 40d0ccd7..00000000 --- a/plugins/dialogue/__init__.py +++ /dev/null @@ -1,54 +0,0 @@ -from nonebot import on_command -from nonebot.typing import T_State -from nonebot.adapters import Bot, Event -from nonebot.permission import SUPERUSER -from util.utils import get_message_text, is_number -from services.log import logger -from util.init_result import at - - -__plugin_name__ = '联系管理员' -__plugin_usage__ = '滴滴滴- 后接内容 联系管理员' - - -dialogue = on_command("[滴滴滴]", aliases={"滴滴滴-"}, priority=1, block=True) -reply = on_command("/t", priority=1, permission=SUPERUSER, block=True) - - -@dialogue.handle() -async def _(bot: Bot, event: Event, state: T_State): - uid = event.user_id - coffee = int(list(bot.config.superusers)[0]) - text = get_message_text(event.json()) - if not text or text in ['帮助']: - await dialogue.send("请发送[滴滴滴]+您要说的内容~", at_sender=True) - else: - if event.get_event_name() == "message.private.friend": - group_id = "" - else: - group_id = event.group_id - await bot.send_private_msg(user_id=coffee, message=f'Q{uid}@群{group_id}\n{text}') - await dialogue.send(f'您的话已发送至管理员!\n======\n{text}', at_sender=True) - logger.info(f"Q{uid}@群{group_id} 联系管理员:{coffee} text:{text}") - - -@reply.handle() -async def _(bot: Bot, event: Event, state: T_State): - if get_message_text(event.json()) in ['帮助']: - await reply.finish(f'/t qq group text') - msg = get_message_text(event.json()).split(" ") - user_id = int(msg[0]) - if is_number(msg[1]) and len(msg[1]) > 5: - group_id = int(msg[1]) - text = msg[2] - else: - group_id = "" - text = msg[1] - if group_id: - await bot.send_group_msg(group_id=group_id, message=at(user_id) + "\n管理员回复\n=======\n" + text) - else: - if user_id in [qq['user_id'] for qq in await bot.get_friend_list()]: - await bot.send_private_msg(user_id=user_id, message="管理员回复\n=======\n" + text) - await reply.finish("发送成功", at_sender=True) - else: - await reply.send(f"对象不是{list(bot.config.nickname)[0]}的好友...", at_sender=True) diff --git a/plugins/dialogue/__pycache__/__init__.cpython-38.pyc b/plugins/dialogue/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 07fc0cb6..00000000 Binary files a/plugins/dialogue/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/dialogue/__pycache__/__init__.cpython-39.pyc b/plugins/dialogue/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 8ee41a1a..00000000 Binary files a/plugins/dialogue/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/draw_card/__init__.py b/plugins/draw_card/__init__.py deleted file mode 100644 index a5383798..00000000 --- a/plugins/draw_card/__init__.py +++ /dev/null @@ -1,174 +0,0 @@ -from nonebot import on_regex, on_keyword -from nonebot.adapters.cqhttp import Bot, MessageEvent -from nonebot.permission import SUPERUSER -from nonebot.typing import T_State -from .genshin_handle import genshin_draw, update_genshin_info, reset_count -from .prts_handle import update_prts_info, prts_draw, reload_pool -from .pretty_handle import update_pretty_info, pretty_draw -from .update_game_info import update_info -from util.utils import is_number, scheduler -from services.log import logger -import re - - -prts = on_regex(r'.*?方舟[1-9|一][0-9]{0,2}[抽|井]', priority=5, block=True) -prts_update = on_keyword({'更新方舟信息', '更新明日方舟信息'}, permission=SUPERUSER, priority=1, block=True) -prts_reload = on_keyword({'重载方舟卡池'}, priority=1, block=True) - -genshin = on_regex('.*?原神[1-9|一][0-9]{0,2}[抽|井]', priority=5, block=True) -genshin_reset = on_keyword({'重置原神抽卡'}, priority=1, block=True) -genshin_update = on_keyword({'更新原神信息'}, permission=SUPERUSER, priority=1, block=True) - -pretty = on_regex('.*?马娘卡?[1-9|一][0-9]{0,2}[抽|井]', priority=5, block=True) -pretty_update = on_keyword({'更新马娘信息', '更新赛马娘信息'}, permission=SUPERUSER, priority=1, block=True) - - -@prts.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - msg = str(event.get_message()).strip() - if msg in ['方舟一井', '方舟1井']: - num = 300 - else: - rmsg = re.search(r'.*?方舟(.*)抽', msg) - if rmsg and is_number(rmsg.group(1)): - try: - num = int(rmsg.group(1)) - except ValueError: - await prts.finish('必!须!是!数!字!', at_sender=True) - if num > 300: - await prts.finish('一井都满不足不了你嘛!快爬开!', at_sender=True) - if num < 1: - await prts.finish('虚空抽卡???', at_sender=True) - else: - return - # print(num) - await prts.send(await prts_draw(num), at_sender=True) - logger.info( - f"(USER {event.user_id}, GROUP {event.group_id if event.message_type != 'private' else 'private'})" - f" 方舟{num}抽") - - -@prts_reload.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - await reload_pool() - await prts_reload.finish('重载完成!') - - -@genshin.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - msg = str(event.get_message()).strip() - if msg in ['原神一井', '原神1井']: - num = 180 - else: - rmsg = re.search(r'.*?原神(.*)抽', msg) - if rmsg and is_number(rmsg.group(1)): - try: - num = int(rmsg.group(1)) - except ValueError: - await genshin.finish('必!须!是!数!字!', at_sender=True) - if num > 300: - await genshin.finish('一井都满不足不了你嘛!快爬开!', at_sender=True) - if num < 1: - await genshin.finish('虚空抽卡???', at_sender=True) - else: - return - await genshin.send(await genshin_draw(event.user_id, num), at_sender=True) - logger.info( - f"(USER {event.user_id}, GROUP {event.group_id if event.message_type != 'private' else 'private'})" - f" 原神{num}抽") - - -@genshin_reset.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - reset_count(event.user_id) - await genshin_reset.send('重置了原神抽卡次数', at_sender=True) - - -@pretty.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - msg = str(event.get_message()).strip() - if msg in ['赛马娘一井', '赛马娘1井', '马娘一井', '马娘1井', '赛马娘卡一井', '赛马娘卡1井', '马娘卡一井', '马娘卡1井']: - num = 200 - if msg.find("卡") == -1: - pool_name = 'horse' - else: - pool_name = 'card' - else: - rmsg = re.search(r'.*?马娘(.*)抽', msg) - if rmsg: - num = rmsg.group(1) - if num[0] == '卡': - num = num[1:] - pool_name = 'card' - else: - pool_name = 'horse' - if is_number(num): - try: - num = int(num) - except ValueError: - await genshin.finish('必!须!是!数!字!', at_sender=True) - if num > 200: - await genshin.finish('一井都满不足不了你嘛!快爬开!', at_sender=True) - if num < 1: - await genshin.finish('虚空抽卡???', at_sender=True) - else: - return - await pretty.send(await pretty_draw(num, pool_name), at_sender=True) - logger.info( - f"(USER {event.user_id}, GROUP {event.group_id if event.message_type != 'private' else 'private'})" - f" 赛马娘{num}抽") - - -@prts_update.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - await update_prts_info() - await reload_pool() - await prts_update.finish('更新完成!') - - -@genshin_update.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - await update_genshin_info() - await genshin_update.finish('更新完成!') - - -@pretty_update.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - await update_pretty_info() - await genshin_update.finish('更新完成!') - - -# 更新资源 -@scheduler.scheduled_job( - 'cron', - hour=4, - minute=1, -) -async def _(): - try: - await update_prts_info() - logger.info('自动更新明日方舟信息') - except Exception as e: - logger.error(f'自动更新明日方舟信息出错 e:{e}') - try: - await update_genshin_info() - logger.info('自动更新原神信息') - except Exception as e: - logger.error(f'自动更新原神信息出错 e:{e}') - try: - await update_pretty_info() - logger.info('自动更新赛马娘信息') - except Exception as e: - logger.error(f'自动更新赛马娘信息出错 e:{e}') - - -# 每天四点重载up卡池 -@scheduler.scheduled_job( - 'cron', - hour=4, - minute=1, -) -async def _(): - await reload_pool() - - diff --git a/plugins/draw_card/__pycache__/__init__.cpython-38.pyc b/plugins/draw_card/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 228a0662..00000000 Binary files a/plugins/draw_card/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/draw_card/__pycache__/__init__.cpython-39.pyc b/plugins/draw_card/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index c8e3c911..00000000 Binary files a/plugins/draw_card/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/draw_card/__pycache__/announcement.cpython-39.pyc b/plugins/draw_card/__pycache__/announcement.cpython-39.pyc deleted file mode 100644 index f8f5af29..00000000 Binary files a/plugins/draw_card/__pycache__/announcement.cpython-39.pyc and /dev/null differ diff --git a/plugins/draw_card/__pycache__/config.cpython-38.pyc b/plugins/draw_card/__pycache__/config.cpython-38.pyc deleted file mode 100644 index a1980fc3..00000000 Binary files a/plugins/draw_card/__pycache__/config.cpython-38.pyc and /dev/null differ diff --git a/plugins/draw_card/__pycache__/config.cpython-39.pyc b/plugins/draw_card/__pycache__/config.cpython-39.pyc deleted file mode 100644 index 4dd03ded..00000000 Binary files a/plugins/draw_card/__pycache__/config.cpython-39.pyc and /dev/null differ diff --git a/plugins/draw_card/__pycache__/genshin_handle.cpython-38.pyc b/plugins/draw_card/__pycache__/genshin_handle.cpython-38.pyc deleted file mode 100644 index fbc3ba8d..00000000 Binary files a/plugins/draw_card/__pycache__/genshin_handle.cpython-38.pyc and /dev/null differ diff --git a/plugins/draw_card/__pycache__/genshin_handle.cpython-39.pyc b/plugins/draw_card/__pycache__/genshin_handle.cpython-39.pyc deleted file mode 100644 index eec4add5..00000000 Binary files a/plugins/draw_card/__pycache__/genshin_handle.cpython-39.pyc and /dev/null differ diff --git a/plugins/draw_card/__pycache__/init_card_pool.cpython-39.pyc b/plugins/draw_card/__pycache__/init_card_pool.cpython-39.pyc deleted file mode 100644 index 02d57fa4..00000000 Binary files a/plugins/draw_card/__pycache__/init_card_pool.cpython-39.pyc and /dev/null differ diff --git a/plugins/draw_card/__pycache__/pretty_handle.cpython-39.pyc b/plugins/draw_card/__pycache__/pretty_handle.cpython-39.pyc deleted file mode 100644 index 8774e41b..00000000 Binary files a/plugins/draw_card/__pycache__/pretty_handle.cpython-39.pyc and /dev/null differ diff --git a/plugins/draw_card/__pycache__/prts_handle.cpython-38.pyc b/plugins/draw_card/__pycache__/prts_handle.cpython-38.pyc deleted file mode 100644 index 8e4f77e7..00000000 Binary files a/plugins/draw_card/__pycache__/prts_handle.cpython-38.pyc and /dev/null differ diff --git a/plugins/draw_card/__pycache__/prts_handle.cpython-39.pyc b/plugins/draw_card/__pycache__/prts_handle.cpython-39.pyc deleted file mode 100644 index db3503ce..00000000 Binary files a/plugins/draw_card/__pycache__/prts_handle.cpython-39.pyc and /dev/null differ diff --git a/plugins/draw_card/__pycache__/update_game_info.cpython-38.pyc b/plugins/draw_card/__pycache__/update_game_info.cpython-38.pyc deleted file mode 100644 index 429d5438..00000000 Binary files a/plugins/draw_card/__pycache__/update_game_info.cpython-38.pyc and /dev/null differ diff --git a/plugins/draw_card/__pycache__/update_game_info.cpython-39.pyc b/plugins/draw_card/__pycache__/update_game_info.cpython-39.pyc deleted file mode 100644 index 95e4b678..00000000 Binary files a/plugins/draw_card/__pycache__/update_game_info.cpython-39.pyc and /dev/null differ diff --git a/plugins/draw_card/__pycache__/util.cpython-38.pyc b/plugins/draw_card/__pycache__/util.cpython-38.pyc deleted file mode 100644 index 9345c928..00000000 Binary files a/plugins/draw_card/__pycache__/util.cpython-38.pyc and /dev/null differ diff --git a/plugins/draw_card/__pycache__/util.cpython-39.pyc b/plugins/draw_card/__pycache__/util.cpython-39.pyc deleted file mode 100644 index 4f102f4c..00000000 Binary files a/plugins/draw_card/__pycache__/util.cpython-39.pyc and /dev/null differ diff --git a/plugins/draw_card/announcement.py b/plugins/draw_card/announcement.py deleted file mode 100644 index 2c3e78c8..00000000 --- a/plugins/draw_card/announcement.py +++ /dev/null @@ -1,119 +0,0 @@ -import aiohttp -from bs4 import BeautifulSoup -import re -from datetime import datetime -from pathlib import Path -from configs.path_config import DRAW_PATH -from util.user_agent import get_user_agent - -try: - import ujson as json -except ModuleNotFoundError: - import json - -up_char_file = Path(DRAW_PATH) / "draw_card_up" / "prts_up_char.json" - -prts_url = "https://wiki.biligame.com/arknights/%E6%96%B0%E9%97%BB%E5%85%AC%E5%91%8A" - - -def _get_up_char(r: str, text: str): - pr = re.search(r, text) - chars = pr.group(1) - probability = pr.group(2) - chars = chars.replace('[限定]', '').replace('[', '').replace(']', '') - probability = probability.replace('【', '') - return chars, probability - - -class PrtsAnnouncement: - - @staticmethod - async def get_announcement_text(): - async with aiohttp.ClientSession(headers=get_user_agent()) as session: - async with session.get(prts_url, timeout=7) as res: - soup = BeautifulSoup(await res.text(), 'lxml') - trs = soup.find('table').find('tbody').find_all('tr') - for tr in trs: - a = tr.find_all('td')[-1].find('a') - if a.text.find('寻访') != -1: - url = a.get('href') - break - async with session.get(f'https://wiki.biligame.com/{url}', timeout=7) as res: - return await res.text(), a.text[:-4] - - @staticmethod - async def update_up_char(): - up_char_file.parent.mkdir(parents=True, exist_ok=True) - data = {'up_char': {'6': {}, '5': {}, '4': {}}, 'title': '', 'time': ''} - text, title = await PrtsAnnouncement.get_announcement_text() - soup = BeautifulSoup(text, 'lxml') - data['title'] = title - context = soup.find('div', {'id': 'mw-content-text'}).find('div') - data['pool_img'] = str(context.find('div', {'class': 'center'}).find('div').find('a'). - find('img').get('srcset')).split(' ')[-2] - # print(context.find_all('p')) - for p in context.find_all('p')[1:]: - if p.text.find('活动时间') != -1: - pr = re.search(r'.*?活动时间:(.*)', p.text) - data['time'] = pr.group(1) - elif p.text.find('★★★★★★') != -1: - chars, probability = _get_up_char(r'.*?★★★★★★:(.*?)(.*?出率的?(.*?)%.*?).*?', p.text) - slt = '/' - if chars.find('\\') != -1: - slt = '\\' - for char in chars.split(slt): - data['up_char']['6'][char.strip()] = probability.strip() - elif p.text.find('★★★★★') != -1: - chars, probability = _get_up_char(r'.*?★★★★★:(.*?)(.*?出率的?(.*?)%.*?).*?', p.text) - slt = '/' - if chars.find('\\') != -1: - slt = '\\' - for char in chars.split(slt): - data['up_char']['5'][char.strip()] = probability.strip() - elif p.text.find('★★★★') != -1: - chars, probability = _get_up_char(r'.*?★★★★:(.*?)(.*?出率的?(.*?)%.*?).*?', p.text) - slt = '/' - if chars.find('\\') != -1: - slt = '\\' - for char in chars.split(slt): - data['up_char']['4'][char.strip()] = probability.strip() - break - pr = re.search(r'.*?★:(.*?)(在(.*?)★.*?以(.*?)倍权值.*?).*?', p.text) - if pr: - char = pr.group(1) - star = pr.group(2) - weight = pr.group(3) - char = char.replace('[限定]', '').replace('[', '').replace(']', '') - data['up_char'][star][char.strip()] = f'权{weight}' - # data['time'] = '03月09日16:00 - 05月23日03:59' - if not is_expired(data): - data['title'] = '' - else: - with open(up_char_file, 'w', encoding='utf8') as f: - json.dump(data, f, indent=4, ensure_ascii=False) - if not up_char_file.exists(): - with open(up_char_file, 'w', encoding='utf8') as f: - json.dump(data, f, indent=4, ensure_ascii=False) - else: - with open(up_char_file, 'r', encoding='utf8') as f: - old_data = json.load(f) - if is_expired(old_data): - return old_data - else: - with open(up_char_file, 'w', encoding='utf8') as f: - json.dump(data, f, indent=4, ensure_ascii=False) - return data - - -# 是否过时 -def is_expired(data: dict): - times = data['time'].split('-') - for i in range(len(times)): - times[i] = str(datetime.now().year) + '-' + times[i].split('日')[0].strip().replace('月', '-') - start_date = datetime.strptime(times[0], '%Y-%m-%d').date() - end_date = datetime.strptime(times[1], '%Y-%m-%d').date() - now = datetime.now().date() - return start_date < now < end_date - -# ad = Announcement('https://wiki.biligame.com/arknights/%E6%96%B0%E9%97%BB%E5%85%AC%E5%91%8A') -# asyncio.get_event_loop().run_until_complete(check_up_char('prts')) diff --git a/plugins/draw_card/config.py b/plugins/draw_card/config.py deleted file mode 100644 index eba09697..00000000 --- a/plugins/draw_card/config.py +++ /dev/null @@ -1,104 +0,0 @@ -import nonebot -from pathlib import Path -try: - import ujson as json -except ModuleNotFoundError: - import json - -# 方舟概率 -PRTS_SIX_P = 0.02 -PRTS_FIVE_P = 0.08 -PRTS_FOUR_P = 0.48 -PRTS_THREE_P = 0.42 - -# 原神概率 -GENSHIN_FIVE_P = 0.006 -GENSHIN_FOUR_P = 0.051 -GENSHIN_THREE_P = 0.43 -GENSHIN_G_FOUR_P = 0.13 -GENSHIN_G_FIVE_P = 0.016 -I72_ADD = 0.0585 - -# 赛马娘概率 -PRETTY_THREE = 0.03 -PRETTY_TWO = 0.18 -PRETTY_ONE = 0.79 - -path_dict = { - 'genshin': '原神', - 'prts': '明日方舟', - 'pretty': '赛马娘', -} - - -_draw_config = Path() / "data" / "draw_card" / "draw_card_config" / "draw_card_config.json" - - -driver: nonebot.Driver = nonebot.get_driver() - - -@driver.on_startup -def check_config(): - global PRTS_SIX_P, PRTS_FOUR_P, PRTS_FIVE_P, PRTS_THREE_P, GENSHIN_G_FIVE_P, \ - GENSHIN_G_FOUR_P, GENSHIN_FOUR_P, GENSHIN_FIVE_P, I72_ADD, path_dict, PRETTY_THREE, \ - PRETTY_ONE, PRETTY_TWO, GENSHIN_THREE_P - if _draw_config.exists(): - data = json.load(open(_draw_config, 'r', encoding='utf8')) - PRTS_SIX_P = float(data['prts']['six']) - PRTS_FIVE_P = float(data['prts']['five']) - PRTS_FOUR_P = float(data['prts']['four']) - PRTS_THREE_P = float(data['prts']['three']) - - GENSHIN_FIVE_P = float(data['genshin']['five_char']) - GENSHIN_FOUR_P = float(data['genshin']['four_char']) - GENSHIN_THREE_P = float(data['genshin']['three_char']) - GENSHIN_G_FIVE_P = float(data['genshin']['five_weapon']) - GENSHIN_G_FOUR_P = float(data['genshin']['four_weapon']) - I72_ADD = float(data['genshin']['72_add']) - - PRETTY_THREE = float(data['pretty']['three']) - PRETTY_TWO = float(data['pretty']['two']) - PRETTY_ONE = float(data['pretty']['one']) - - path_dict = data['path_dict'] - else: - _draw_config.parent.mkdir(parents=True, exist_ok=True) - config_dict = { - 'path_dict': { - 'genshin': '原神', - 'prts': '明日方舟', - 'pretty': '赛马娘', - }, - - 'prts': { - 'six': 0.02, - 'five': 0.08, - 'four': 0.48, - 'three': 0.42, - }, - - 'genshin': { - 'five_char': 0.006, - 'four_char': 0.051, - 'three_char': 0.43, - 'five_weapon': 0.13, - 'four_weapon': 0.016, - '72_add': 0.0585, - }, - - 'pretty': { - 'three': 0.03, - 'two': 0.18, - 'one': 0.79, - } - } - json.dump(config_dict, open(_draw_config, 'w', encoding='utf8'), indent=4, ensure_ascii=False) - - - - - - - - - diff --git a/plugins/draw_card/genshin_handle.py b/plugins/draw_card/genshin_handle.py deleted file mode 100644 index 923ae50f..00000000 --- a/plugins/draw_card/genshin_handle.py +++ /dev/null @@ -1,149 +0,0 @@ - -import os -import nonebot -import random -from .update_game_info import update_info -from .util import generate_img, init_star_rst, BaseData, set_list -from .config import GENSHIN_FIVE_P, GENSHIN_FOUR_P, GENSHIN_G_FIVE_P, GENSHIN_THREE_P, I72_ADD -from dataclasses import dataclass -from .init_card_pool import init_game_pool -from configs.path_config import DRAW_PATH -from util.init_result import image -try: - import ujson as json -except ModuleNotFoundError: - import json - -driver: nonebot.Driver = nonebot.get_driver() - -genshin_five = {} -genshin_count = {} -genshin_pl_count = {} - -ALL_CHAR = [] -ALL_ARM = [] - - -@dataclass -class GenshinChar(BaseData): - pass - - -async def genshin_draw(user_id: int, count: int): - # 0 1 2 - cnlist = ['★★★★★', '★★★★', '★★★'] - genshin_list, five_list, five_olist, five_dict, star_list = _format_card_information(count, user_id) - rst = init_star_rst(star_list, cnlist, five_list, five_olist) - print(five_list) - temp = '' - if count > 90: - genshin_list = set_list(genshin_list) - return image(b64=await generate_img(genshin_list, 'genshin', star_list)) + '\n' + rst[:-1] + \ - temp[:-1] + f'\n距离保底发还剩 {90 - genshin_count[user_id] if genshin_count.get(user_id) else "^"} 抽' \ - + "\n【五星:0.6%,四星:5.1%\n第72抽开始五星概率每抽加0.585%】" - - -async def update_genshin_info(): - global ALL_CHAR, ALL_ARM - url = 'https://wiki.biligame.com/ys/角色筛选' - data, code = await update_info(url, 'genshin') - if code == 200: - ALL_CHAR = init_game_pool('genshin', data, GenshinChar) - url = 'https://wiki.biligame.com/ys/武器图鉴' - data, code = await update_info(url, 'genshin_arm', ['头像', '名称', '类型', '稀有度.alt', '初始基础属性1', - '初始基础属性2', '攻击力(MAX)', '副属性(MAX)', '技能']) - if code == 200: - ALL_ARM = init_game_pool('genshin', data, GenshinChar) - - -# asyncio.get_event_loop().run_until_complete(update_genshin_info()) - - -@driver.on_startup -async def init_data(): - global ALL_CHAR, ALL_ARM - if not os.path.exists(DRAW_PATH + '/draw_card_config/genshin.json') or \ - not os.path.exists(DRAW_PATH + '/draw_card_config/genshin_arm.json'): - await update_genshin_info() - else: - with open(DRAW_PATH + '/draw_card_config/genshin.json', 'r', encoding='utf8') as f: - genshin_dict = json.load(f) - with open(DRAW_PATH + '/draw_card_config/genshin_arm.json', 'r', encoding='utf8') as f: - genshin_arm_dict = json.load(f) - ALL_CHAR = init_game_pool('genshin', genshin_dict, GenshinChar) - ALL_ARM = init_game_pool('genshin', genshin_arm_dict, GenshinChar) - - -# 抽取卡池 -def _get_genshin_card(mode: int = 1, add: float = 0.0): - global ALL_ARM, ALL_CHAR - if mode == 1: - star = random.sample([5, 4, 3], - counts=[int(GENSHIN_FIVE_P * 1000) + int(add * 1000), int(GENSHIN_FOUR_P * 1000), - int(GENSHIN_THREE_P * 1000)], - k=1)[0] - elif mode == 2: - star = random.sample([5, 4], - counts=[int(GENSHIN_G_FIVE_P * 1000) + int(add * 1000), int(GENSHIN_FOUR_P * 1000)], - k=1)[0] - else: - star = 5 - chars = [x for x in (ALL_ARM if random.random() < 0.5 or star == 3 else ALL_CHAR) if x.star == star] - return random.choice(chars), abs(star - 5) - - -def _format_card_information(_count: int, user_id): - genshin_list = [] - star_list = [0, 0, 0] - five_index_list = [] - five_list = [] - five_dict = {} - add = 0.0 - if genshin_count.get(user_id) and _count <= 90: - f_count = genshin_count[user_id] - else: - f_count = 0 - if genshin_pl_count.get(user_id) and _count <= 90: - count = genshin_pl_count[user_id] - else: - count = 0 - for i in range(_count): - count += 1 - f_count += 1 - # 十连保底 - if count == 10 and f_count != 90: - if f_count >= 72: - add += I72_ADD - char, code = _get_genshin_card(2, add) - count = 0 - # 大保底 - elif f_count == 90: - char, code = _get_genshin_card(3) - else: - if f_count >= 72: - add += I72_ADD - char, code = _get_genshin_card(add=add) - if code == 1: - count = 0 - star_list[code] += 1 - if code == 0: - if _count <= 90: - genshin_five[user_id] = f_count - add = 0.0 - f_count = 0 - five_list.append(char.name) - five_index_list.append(i) - try: - five_dict[char.name] += 1 - except KeyError: - five_dict[char.name] = 1 - genshin_list.append(char) - if _count <= 90: - genshin_count[user_id] = f_count - genshin_pl_count[user_id] = count - return genshin_list, five_list, five_index_list, five_dict, star_list - - -def reset_count(user_id: int): - genshin_count[user_id] = 0 - genshin_pl_count[user_id] = 0 diff --git a/plugins/draw_card/init_card_pool.py b/plugins/draw_card/init_card_pool.py deleted file mode 100644 index 46ec58be..00000000 --- a/plugins/draw_card/init_card_pool.py +++ /dev/null @@ -1,33 +0,0 @@ -from typing import Any - - -def init_game_pool(game: str, data: dict, Operator: Any): - tmp_lst = [] - if game == 'prts': - for key in data.keys(): - limited = False - recruit_only = False - event_only = False - if '限定寻访' in data[key]['获取途径']: - limited = True - if len(data[key]['获取途径']) == 1 and data[key]['获取途径'][0] == '公开招募': - recruit_only = True - if '活动获取' in data[key]['获取途径']: - event_only = True - if key.find('阿米娅') != -1: - continue - tmp_lst.append(Operator(name=key, star=int(data[key]['星级']), - limited=limited, recruit_only=recruit_only, event_only=event_only)) - if game == 'genshin': - for key in data.keys(): - if key.find('旅行者') != -1: - continue - tmp_lst.append(Operator(name=key, star=int(data[key]['稀有度'][:1]), limited=False)) - if game == 'pretty': - for key in data.keys(): - tmp_lst.append(Operator(name=key, star=data[key]['初始星级'], limited=False)) - if game == 'pretty_card': - for key in data.keys(): - tmp_lst.append(Operator(name=data[key]['中文名'], star=len(data[key]['稀有度']), limited=False)) - return tmp_lst - diff --git a/plugins/draw_card/pretty_handle.py b/plugins/draw_card/pretty_handle.py deleted file mode 100644 index dfee34fe..00000000 --- a/plugins/draw_card/pretty_handle.py +++ /dev/null @@ -1,105 +0,0 @@ - -import os -import nonebot -from util.init_result import image -from configs.path_config import DRAW_PATH -from .update_game_info import update_info -from .util import download_img, init_star_rst, generate_img, max_card, BaseData, set_list -import random -from .config import PRETTY_THREE, PRETTY_TWO, PRETTY_ONE -from dataclasses import dataclass -from .init_card_pool import init_game_pool -try: - import ujson as json -except ModuleNotFoundError: - import json - -driver: nonebot.Driver = nonebot.get_driver() - -ALL_CHAR = [] -ALL_CARD = [] - - -@dataclass -class PrettyChar(BaseData): - pass - - -async def pretty_draw(count: int, pool_name): - if pool_name == 'card': - cnlist = ['SSR', 'SR', 'R'] - else: - cnlist = ['★★★', '★★', '★'] - obj_list, obj_dict, three_list, star_list, three_olist = _format_card_information(count, pool_name) - rst = init_star_rst(star_list, cnlist, three_list, three_olist) - if count > 90: - obj_list = set_list(obj_list) - return image(b64=await generate_img(obj_list, 'pretty', star_list)) \ - + '\n' + rst[:-1] + '\n' + max_card(obj_dict) - - -async def update_pretty_info(): - global ALL_CHAR, ALL_CARD - url = 'https://wiki.biligame.com/umamusume/赛马娘图鉴' - data, code = await update_info(url, 'pretty') - if code == 200: - ALL_CHAR = init_game_pool('pretty', data, PrettyChar) - url = 'https://wiki.biligame.com/umamusume/支援卡图鉴' - data, code = await update_info(url, 'pretty_card') - if code == 200: - ALL_CARD = init_game_pool('pretty_card', data, PrettyChar) - - -@driver.on_startup -async def init_data(): - global ALL_CHAR, ALL_CARD - if not os.path.exists(DRAW_PATH + '/draw_card_config/pretty.json') or\ - not os.path.exists(DRAW_PATH + '/draw_card_config/pretty_card.json'): - await update_pretty_info() - for icon_url in [ - 'https://patchwiki.biligame.com/images/umamusume/thumb/0/06/q23szwkbtd7pfkqrk3wcjlxxt9z595o.png' - '/40px-SSR.png', - 'https://patchwiki.biligame.com/images/umamusume/thumb/3/3b/d1jmpwrsk4irkes1gdvoos4ic6rmuht.png' - '/40px-SR.png', - 'https://patchwiki.biligame.com/images/umamusume/thumb/f/f7/afqs7h4snmvovsrlifq5ib8vlpu2wvk.png' - '/40px-R.png']: - await download_img(icon_url, 'pretty', icon_url.split('-')[-1][:-4]) - else: - with open(DRAW_PATH + '/draw_card_config/pretty.json', 'r', encoding='utf8') as f: - pretty_char_dict = json.load(f) - with open(DRAW_PATH + '/draw_card_config/pretty_card.json', 'r', encoding='utf8') as f: - pretty_card_dict = json.load(f) - ALL_CHAR = init_game_pool('pretty', pretty_char_dict, PrettyChar) - ALL_CARD = init_game_pool('pretty_card', pretty_card_dict, PrettyChar) - - -# 抽取卡池 -def _get_pretty_card(itype): - global ALL_CHAR, ALL_CARD - star = random.sample([3, 2, 1], - counts=[int(PRETTY_THREE * 100), int(PRETTY_TWO * 100), - int(PRETTY_ONE * 100)], - k=1)[0] - chars = [x for x in (ALL_CARD if itype == 'card' else ALL_CHAR) if x.star == star] - return random.choice(chars), abs(star - 3) - - -# 整理数据 -def _format_card_information(count: int, pool_name: str): - three_list = [] - three_olist = [] - obj_list = [] - obj_dict = {} - star_list = [0, 0, 0] - for i in range(count): - obj, code = _get_pretty_card(pool_name) - star_list[code] += 1 - if code == 0: - three_list.append(obj.name) - three_olist.append(i) - try: - obj_dict[obj.name] += 1 - except KeyError: - obj_dict[obj.name] = 1 - obj_list.append(obj) - return obj_list, obj_dict, three_list, star_list, three_olist diff --git a/plugins/draw_card/prts_handle.py b/plugins/draw_card/prts_handle.py deleted file mode 100644 index 2631cf96..00000000 --- a/plugins/draw_card/prts_handle.py +++ /dev/null @@ -1,162 +0,0 @@ - -import os -import nonebot -import random -from .config import PRTS_FIVE_P, PRTS_FOUR_P, PRTS_SIX_P, PRTS_THREE_P -from .update_game_info import update_info -from .util import generate_img, init_star_rst, max_card, BaseData, UpEvent, set_list -from .init_card_pool import init_game_pool -from pathlib import Path -from .announcement import PrtsAnnouncement -from dataclasses import dataclass -from util.init_result import image -from configs.path_config import DRAW_PATH -from services.log import logger -try: - import ujson as json -except ModuleNotFoundError: - import json - -driver: nonebot.Driver = nonebot.get_driver() - -up_char_file = Path() / "data" / "draw_card" / "draw_card_up" / "prts_up_char.json" - -prts_dict = {} -UP_OPERATOR = [] -ALL_OPERATOR = [] -_CURRENT_POOL_TITLE = '' - - -@dataclass -class Operator(BaseData): - recruit_only: bool # 公招限定 - event_only: bool # 活动获得干员 - # special_only: bool # 升变/异格干员 - - -async def prts_draw(count: int = 300): - cnlist = ['★★★★★★', '★★★★★', '★★★★', '★★★'] - operator_list, operator_dict, six_list, star_list, six_olist = _format_card_information(count) - up_list = [] - if _CURRENT_POOL_TITLE: - for x in UP_OPERATOR: - for operator in x.operators: - up_list.append(operator) - rst = init_star_rst(star_list, cnlist, six_list, six_olist, up_list) - if count > 90: - operator_list = set_list(operator_list) - pool_info = "当前up池: " if _CURRENT_POOL_TITLE else "" - return pool_info + _CURRENT_POOL_TITLE + image(b64=await generate_img(operator_list, 'prts', star_list)) \ - + '\n' + rst[:-1] + '\n' + max_card(operator_dict) - - -async def update_prts_info(): - global prts_dict, ALL_OPERATOR - url = 'https://wiki.biligame.com/arknights/干员数据表' - data, code = await update_info(url, 'prts', ['头像', '名称', '阵营', '星级', '性别', '是否感染', '初始生命', '初始防御', - '初始法抗', '再部署', '部署费用', '阻挡数', '攻击速度', '标签']) - if code == 200: - prts_dict = data - ALL_OPERATOR = init_game_pool('prts', prts_dict, Operator) - - -@driver.on_startup -async def init_data(): - global prts_dict, ALL_OPERATOR - if not os.path.exists(DRAW_PATH + '/draw_card_config/prts.json'): - await update_prts_info() - else: - with open(DRAW_PATH + '/draw_card_config/prts.json', 'r', encoding='utf8') as f: - prts_dict = json.load(f) - ALL_OPERATOR = init_game_pool('prts', prts_dict, Operator) - await _init_up_char() - # print([x.operators for x in UP_OPERATOR if x.star == 5 and x.zoom > 1]) - - -# 抽取干员 -def _get_operator_card(): - star = random.sample([6, 5, 4, 3], - counts=[int(PRTS_SIX_P * 100), int(PRTS_FIVE_P * 100), - int(PRTS_FOUR_P * 100), int(PRTS_THREE_P * 100)], - k=1)[0] - if _CURRENT_POOL_TITLE: - zooms = [x.zoom for x in UP_OPERATOR if x.star == star] - zoom = 0 - weight = 0 - # 分配概率和权重 - for z in zooms: - if z < 1: - zoom = z - else: - weight = z - # UP - if random.random() < zoom: - up_operators = [x.operators for x in UP_OPERATOR if x.star == star and x.zoom < 1][0] - up_operator_name = random.choice(up_operators) - # print(up_operator_name) - acquire_operator = [x for x in ALL_OPERATOR if x.name == up_operator_name][0] - else: - all_star_operators = [x for x in ALL_OPERATOR if x.star == star - and not any([x.limited, x.event_only, x.recruit_only])] - weight_up_operators = [x.operators for x in UP_OPERATOR if x.star == star and x.zoom > 1] - # 权重 - if weight_up_operators and random.random() < 1.0 / float(len(all_star_operators)) * weight: - up_operator_name = random.choice(weight_up_operators[0]) - acquire_operator = [x for x in ALL_OPERATOR if x.name == up_operator_name][0] - else: - acquire_operator = random.choice(all_star_operators) - else: - acquire_operator = random.choice([x for x in ALL_OPERATOR if x.star == star - and not any([x.limited, x.event_only, x.recruit_only])]) - # print(f'{acquire_operator}: {star}') - return acquire_operator, abs(star - 6) - - -# 整理抽卡数据 -def _format_card_information(count: int): - operator_list = [] # 抽取的干员列表 - operator_dict = {} # 抽取各干员次数 - star_list = [0, 0, 0, 0] # 各个星级次数 - six_list = [] # 六星干员列表 - six_index_list = [] # 六星干员获取位置 - for i in range(count): - operator, code = _get_operator_card() - star_list[code] += 1 - if code == 0: - six_list.append(operator.name) - six_index_list.append(i) - try: - operator_dict[operator.name] += 1 - except KeyError: - operator_dict[operator.name] = 1 - operator_list.append(operator) - return operator_list, operator_dict, six_list, star_list, six_index_list - - -# 获取up干员和概率 -async def _init_up_char(): - global up_char_dict, _CURRENT_POOL_TITLE - up_char_dict = await PrtsAnnouncement.update_up_char() - # print(up_char_dict) - _CURRENT_POOL_TITLE = up_char_dict['title'] - up_char_dict = up_char_dict['up_char'] - logger.info(f'成功获取明日方舟当前up信息...当前up池: {_CURRENT_POOL_TITLE}') - average_dict = {'6': {}, '5': {}, '4': {}} - for star in up_char_dict.keys(): - for key in up_char_dict[star].keys(): - if average_dict[star].get(up_char_dict[star][key]): - average_dict[star][up_char_dict[star][key]].append(key) - else: - average_dict[star][up_char_dict[star][key]] = [key] - up_char_dict = {'6': {}, '5': {}, '4': {}} - for star in average_dict.keys(): - for str_zoom in average_dict[star].keys(): - if str_zoom[0] == '权': - zoom = float(str_zoom[1:]) - else: - zoom = float(str_zoom) / 100 - UP_OPERATOR.append(UpEvent(star=int(star), operators=average_dict[star][str_zoom], zoom=zoom)) - - -async def reload_pool(): - await _init_up_char() diff --git a/plugins/draw_card/update_game_info.py b/plugins/draw_card/update_game_info.py deleted file mode 100644 index c9b208b9..00000000 --- a/plugins/draw_card/update_game_info.py +++ /dev/null @@ -1,162 +0,0 @@ -#coding:utf-8 -import aiohttp -from configs.path_config import DRAW_PATH -from asyncio.exceptions import TimeoutError -from services.log import logger -from bs4 import BeautifulSoup -from .util import download_img -from urllib.parse import unquote -import bs4 -from util.user_agent import get_user_agent -import re -try: - import ujson as json -except ModuleNotFoundError: - import json - - -async def update_info(url: str, game_name: str, info_list: list = None) -> 'dict, int': - try: - with open(DRAW_PATH + f'/draw_card_config/{game_name}.json', 'r', encoding='utf8') as f: - data = json.load(f) - except (ValueError, FileNotFoundError): - data = {} - try: - async with aiohttp.ClientSession(headers=get_user_agent()) as session: - async with session.get(url, timeout=7) as response: - soup = BeautifulSoup(await response.text(), 'lxml') - max_count = 0 - _tbody = None - for tbody in soup.find_all('tbody'): - if len(tbody.find_all('tr')) > max_count: - _tbody = tbody - max_count = len(tbody.find_all('tr')) - trs = _tbody.find_all('tr') - att_dict = {'头像': 0, '名称': 1} - index = 2 - for th in trs[0].find_all('th')[2:]: - text = th.text - if text[-1] == '\n': - text = text[:-1] - att_dict[text] = index - index += 1 - for tr in trs[1:]: - member_dict = {} - k_name = '' - tds = tr.find_all('td') - if not info_list: - info_list = att_dict.keys() - for key in info_list: - attr = '' - if key.find('.') != -1: - key = key.split('.') - attr = key[-1] - key = key[0] - td = tds[att_dict[key]] - last_tag = unquote(_find_last_tag(td, attr), 'utf-8') - if game_name.find('pretty') == -1 and last_tag.find('http') == -1: - last_tag = last_tag.split('.')[0] - if key == '名称': - k_name = last_tag - member_dict[key] = last_tag - if game_name == 'pretty' and key == '初始星级': - member_dict['初始星级'] = len(td.find_all('img')) - avatar_img = await _modify_avatar_url(session, game_name, member_dict["名称"]) - if avatar_img: - member_dict['头像'] = avatar_img - name = member_dict['名称'] - if game_name == 'pretty_card': - name = member_dict['中文名'] - await download_img(member_dict['头像'], game_name, name) - if k_name: - data[k_name] = member_dict - logger.info(f'{k_name} is update...') - data = await _last_check(data, game_name, session) - except TimeoutError: - return {}, 999 - with open(DRAW_PATH + f'/draw_card_config/{game_name}.json', 'w', encoding='utf8') as wf: - wf.write(json.dumps(data, ensure_ascii=False, indent=4)) - return data, 200 - - -def _find_last_tag(element: bs4.element.Tag, attr: str) -> str: - last_tag = [] - for des in element.descendants: - last_tag.append(des) - if len(last_tag) == 1 and last_tag[0] == '\n': - last_tag = '' - elif last_tag[-1] == '\n': - last_tag = last_tag[-2] - else: - last_tag = last_tag[-1] - if attr and str(last_tag): - last_tag = last_tag[attr] - elif str(last_tag).find('([\s\S]*)'): - obtain = obtain.split('
') - elif obtain.find('
'): - obtain = obtain.split('
') - data[key]['获取途径'] = obtain - # if game_name == 'genshin': - # for key in data.keys(): - # async with session.get(f'https://wiki.biligame.com/ys/{key}', timeout=7) as res: - # soup = BeautifulSoup(await res.text(), 'lxml') - # trs = soup.find('div', {'class': 'poke-bg'}).find('table').find('tbody').find_all('tr') - # for tr in trs: - # if tr.find('th').text.find('常驻/限定') != -1: - # data[key]['常驻/限定'] = tr.find('td').text - # break - if game_name == 'pretty': - for keys in data.keys(): - for key in data[keys].keys(): - # print(f'key --> {data[keys][key]}') - r = re.search(r'.*?40px-(.*)图标.png', str(data[keys][key])) - if r: - data[keys][key] = r.group(1) - return data - - - - -# ul = soup.find('div', {'class': 'savelist_bot'}).find('ul') - - diff --git a/plugins/draw_card/util.py b/plugins/draw_card/util.py deleted file mode 100644 index edd57e94..00000000 --- a/plugins/draw_card/util.py +++ /dev/null @@ -1,161 +0,0 @@ -import os -import aiohttp -import aiofiles -from asyncio.exceptions import TimeoutError -from aiohttp.client_exceptions import InvalidURL -from typing import List, Union, Set -import asyncio -from pathlib import Path -from .config import path_dict -import nonebot -from util.utils import cn2py -from util.img_utils import CreateImg -from util.user_agent import get_user_agent -from configs.path_config import IMAGE_PATH -from dataclasses import dataclass -from services.log import logger -try: - import ujson as json -except ModuleNotFoundError: - import json - - -driver: nonebot.Driver = nonebot.get_driver() - - -@dataclass -class BaseData: - name: str - star: int - limited: bool # 限定 - - -@dataclass -class UpEvent: - star: int # 对应up星级 - operators: List[BaseData] # 干员列表 - zoom: float # up提升倍率 - - -async def download_img(url: str, path: str, name: str) -> bool: - path = path.split('_')[0] - codename = cn2py(name) - # if not _p.exists(): - # _p.mkdir(parents=True, exist_ok=True) - if not os.path.exists(IMAGE_PATH + f'/draw_card/{path}/{codename}.png'): - try: - async with aiohttp.ClientSession(headers=get_user_agent()) as session: - async with session.get(url, timeout=7) as response: - async with aiofiles.open(IMAGE_PATH + f'/draw_card/{path}/{codename}.png', 'wb') as f: - await f.write(await response.read()) - logger.info(f'下载 {path_dict[path]} 图片成功,名称:{name},url:{url}') - return True - except TimeoutError: - logger.info(f'下载 {path_dict[path]} 图片超时,名称:{name},url:{url}') - return False - except InvalidURL: - logger.info(f'下载 {path_dict[path]} 链接错误,名称:{name},url:{url}') - return False - else: - # logger.info(f'{path_dict[path]} 图片 {name} 已存在') - return False - - -@driver.on_startup -def _check_dir(): - for dir_name in path_dict.keys(): - _p = Path(IMAGE_PATH + f'/draw_card/' + dir_name) - if not _p.exists(): - _p.mkdir(parents=True, exist_ok=True) - - -async def generate_img(card_set: Union[Set[BaseData], List[BaseData]], game_name: str, star_list: list) -> str: - # try: - img_list = [] - color_list = [] - for x in card_set: - if game_name == 'prts': - if x.star == 6: - color_list.append('#FFD700') - elif x.star == 5: - color_list.append('#DAA520') - elif x.star == 4: - color_list.append('#9370D8') - else: - color_list.append('white') - pyname = cn2py(x.name) - img_list.append(IMAGE_PATH + f'/draw_card/{game_name}/{pyname}.png') - img_len = len(img_list) - w = 100 * 10 - if img_len <= 10: - w = 100 * img_len - h = 100 - elif img_len % 10 == 0: - h = 100 * int(img_len / 10) - else: - h = 100 * int(img_len / 10) + 100 - card_img = await asyncio.get_event_loop().run_in_executor(None, _pst, h, img_list, game_name, color_list) - num = 0 - for n in star_list: - num += n - A = CreateImg(w, h) - A.paste(card_img) - return A.pic2bs4() - - -def _pst(h: int, img_list: list, game_name: str, color_list: list): - card_img = CreateImg(100 * 10, h, 100, 100) - idx = 0 - for img in img_list: - try: - if game_name == 'prts': - bk = CreateImg(100, 100, color=color_list[idx]) - b = CreateImg(94, 94, background=img) - bk.paste(b, (3, 3)) - b = bk - idx += 1 - else: - b = CreateImg(100, 100, background=img) - except FileNotFoundError: - print(f'{img} not exists') - b = CreateImg(100, 100, color='black') - card_img.paste(b) - return card_img - - -def init_star_rst(star_list: list, cnlist: list, max_star_list: list, max_star_olist: list, up_list: list = None) -> str: - if not up_list: - up_list = [] - rst = '' - for i in range(len(star_list)): - if star_list[i]: - rst += f'[{cnlist[i]}×{star_list[i]}] ' - rst += '\n' - for i in range(len(max_star_list)): - if max_star_list[i] in up_list: - rst += f'第 {max_star_olist[i]+1} 抽获取UP {max_star_list[i]}\n' - else: - rst += f'第 {max_star_olist[i]+1} 抽获取 {max_star_list[i]}\n' - return rst - - -def max_card(_dict: dict): - _max_value = max(_dict.values()) - _max_user = list(_dict.keys())[list(_dict.values()).index(_max_value)] - return f'抽取到最多的是{_max_user},共抽取了{_max_value}次' - # ThreeHighest = nlargest(3, operator_dict, key=operator_dict.get) - # rst = '最喜欢你的前三位是干员是:\n' - # for name in ThreeHighest: - # rst += f'{name} 共投了 {operator_dict[name]} 份简历\n' - # return rst[:-1] - - -def set_list(lst: List[BaseData]) -> list: - tmp = [] - name_lst = [] - for x in lst: - if x.name not in name_lst: - tmp.append(x) - name_lst.append(x.name) - return tmp - diff --git a/plugins/epic/__init__.py b/plugins/epic/__init__.py deleted file mode 100644 index b96e3013..00000000 --- a/plugins/epic/__init__.py +++ /dev/null @@ -1,60 +0,0 @@ -from nonebot import on_command -from services.log import logger -from nonebot.adapters.cqhttp import Bot, MessageEvent -from nonebot.typing import T_State -from util.utils import scheduler, get_bot -from .data_source import get_epic_game -from models.group_remind import GroupRemind -from nonebot.adapters.cqhttp.exception import ActionFailed - -__plugin_usage__ = 'epic免费游戏提醒' - - -epic = on_command("epic", priority=5, block=True) - - -@epic.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - # try: - if str(event.get_message()) in ['帮助']: - await epic.finish(__plugin_usage__) - try: - result = await get_epic_game() - except: - result = '网络出错了!' - await epic.send(result) - logger.info( - f"(USER {event.user_id}, GROUP {event.group_id if event.message_type != 'private' else 'private'})" - f" 获取epic免费游戏") - # except Exception as e: - # logger.error(f'epic 出错 e:{e}') - # await epic.finish('网络好像炸了,再试一次?', at_sender=True) - - -# epic免费游戏 -@scheduler.scheduled_job( - 'cron', - hour=12, - minute=1, -) -async def _(): - # try: - bot = get_bot() - gl = await bot.get_group_list(self_id=bot.self_id) - gl = [g['group_id'] for g in gl] - for g in gl: - if await GroupRemind.get_status(g, 'epic'): - result = await get_epic_game() - if result == '今天没有游戏可以白嫖了!': - return - try: - await bot.send_group_msg(group_id=g, - message=result) - except ActionFailed: - logger.error(f'{g}群 epic免费游戏推送错误') - # except Exception as e: - # logger.error(f'epic免费游戏推送错误 e:{e}') - - - - diff --git a/plugins/epic/__pycache__/__init__.cpython-38.pyc b/plugins/epic/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index d34d9136..00000000 Binary files a/plugins/epic/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/epic/__pycache__/__init__.cpython-39.pyc b/plugins/epic/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 08ef01d7..00000000 Binary files a/plugins/epic/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/epic/__pycache__/data_source.cpython-38.pyc b/plugins/epic/__pycache__/data_source.cpython-38.pyc deleted file mode 100644 index 825f6e02..00000000 Binary files a/plugins/epic/__pycache__/data_source.cpython-38.pyc and /dev/null differ diff --git a/plugins/epic/__pycache__/data_source.cpython-39.pyc b/plugins/epic/__pycache__/data_source.cpython-39.pyc deleted file mode 100644 index 4c17f0c8..00000000 Binary files a/plugins/epic/__pycache__/data_source.cpython-39.pyc and /dev/null differ diff --git a/plugins/epic/data_source.py b/plugins/epic/data_source.py deleted file mode 100644 index 8f40f32f..00000000 --- a/plugins/epic/data_source.py +++ /dev/null @@ -1,46 +0,0 @@ -import aiohttp -import aiofiles -from util.utils import get_local_proxy -import feedparser -import platform -from util.init_result import image -from configs.path_config import IMAGE_PATH -from util.user_agent import get_user_agent -if platform.system() == 'Windows': - import asyncio - asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) - - -url = 'https://rsshub.app/epicgames/freegames' - - -async def get_epic_game() -> str: - result = '' - async with aiohttp.ClientSession(headers=get_user_agent()) as session: - async with session.get(url, proxy=get_local_proxy(), timeout=7) as response: - data = feedparser.parse(await response.text())['entries'] - if len(data) == 0: - return result - index = 0 - for item in data: - title = item['title'] - img_url = item['summary'][item['summary'].find('src="')+5: item['summary'].rfind('"')] - async with session.get(img_url, proxy=get_local_proxy(), timeout=7) as res: - async with aiofiles.open(IMAGE_PATH + f'temp/epic_{index}.jpg', 'wb') as f: - await f.write(await res.read()) - link = item['link'] - result += image(f'epic_{index}.jpg', 'temp') + f'\n【游戏】| {title}\n【链接】 | {link}\n' - index += 1 - if result != '': - result = 'epic限免游戏(速速白嫖):\n' + result - else: - result = '今天没有游戏可以白嫖了!' - print(result) - return result - - - - -# print(asyncio.get_event_loop().run_until_complete(get_epic_game())) - - diff --git a/plugins/fake_msg.py b/plugins/fake_msg.py deleted file mode 100644 index ab4e794a..00000000 --- a/plugins/fake_msg.py +++ /dev/null @@ -1,55 +0,0 @@ -from nonebot.typing import T_State -from nonebot.adapters.cqhttp import Bot, MessageEvent -from nonebot import on_command -from util.utils import get_message_imgs, get_message_text -from util.init_result import share -from services.log import logger - - -__plugin_usage__ = '用法:\n格式:网址 标题 内容(可省略) 图片(可省略)\n示例:假消息 www.4399.com 我喜欢萝莉 为什么我喜欢... (图片)' - - -fake_msg = on_command('假消息', priority=5, block=True) - - -@fake_msg.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - msg = get_message_text(event.json()).split(' ') - img = get_message_imgs(event.json()) - if not msg or msg in ['帮助']: - await fake_msg.finish(__plugin_usage__) - if len(msg) > 1: - if len(msg) == 2: - url = msg[0] - title = msg[1] - content = '' - else: - url = msg[0] - title = msg[1] - content = msg[2] - if img: - img = img[0] - else: - img = '' - if url.find('http://') == -1: - url = 'http://' + url - await fake_msg.send(share(url, title, content, img)) - logger.info( - f"(USER {event.user_id}, GROUP {event.group_id if event.message_type != 'private' else 'private'})" - f" 构造假消息 url {url}, title {title}, content {content}") - else: - await fake_msg.finish('消息格式错误:\n网址 标题 内容(可省略) 图片(可省略)') - - - - - - - - - - - - - - diff --git a/plugins/fudu.py b/plugins/fudu.py deleted file mode 100644 index 22ee19e8..00000000 --- a/plugins/fudu.py +++ /dev/null @@ -1,88 +0,0 @@ -from nonebot.adapters.cqhttp.permission import GROUP -from configs.path_config import IMAGE_PATH -from util.img_utils import get_img_hash -import random -from util.init_result import image -from nonebot import on_message -from util.utils import get_message_text, get_message_imgs, get_local_proxy -from nonebot.typing import T_State -from nonebot.adapters.cqhttp import Bot, GroupMessageEvent -import aiohttp -import aiofiles -from collections import defaultdict -from configs.config import FUDU_PROBABILITY - - -class Fudu: - def __init__(self): - self.mlist = defaultdict(list) - - def append(self, key, content): - self.mlist[key].append(content) - - def clear(self, key): - self.mlist[key] = [] - - def size(self, key) -> int: - return len(self.mlist[key]) - - def check(self, key, content) -> bool: - return self.mlist[key][0] == content - - def get(self, key): - return self.mlist[key][0] - - -_fudulist = Fudu() - - -fudu = on_message(permission=GROUP, priority=9) - - -@fudu.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - if event.is_tome() or state["_prefix"]["raw_command"]: - return - if get_message_text(event.json()): - if get_message_text(event.json()).find('@可爱的小真寻') != -1: - await fudu.finish('复制粘贴的虚空艾特?', at_sender=True) - imgs = get_message_imgs(event.json()) - msg = get_message_text(event.json()) - if not imgs and not msg: - return - if imgs: - img_hash = await get_fudu_img_hash(imgs[0], event.group_id) - else: - img_hash = '' - add_msg = msg + '|-|' + img_hash - if _fudulist.size(event.group_id) == 0: - _fudulist.append(event.group_id, add_msg) - elif _fudulist.check(event.group_id, add_msg): - _fudulist.append(event.group_id, add_msg) - else: - _fudulist.clear(event.group_id) - _fudulist.append(event.group_id, add_msg) - if _fudulist.size(event.group_id) > 2: - if random.random() < FUDU_PROBABILITY: - if random.random() < 0.2: - await fudu.finish("打断施法!") - if imgs and msg: - rst = msg + image(f'compare_{event.group_id}_img.jpg', 'temp') - elif imgs: - rst = image(f'compare_{event.group_id}_img.jpg', 'temp') - elif msg: - rst = msg - else: - rst = '' - if rst: - await fudu.send(rst) - _fudulist.clear(event.group_id) - - -async def get_fudu_img_hash(url, group_id): - async with aiohttp.ClientSession() as session: - async with session.get(url, proxy=get_local_proxy(), timeout=5) as response: - async with aiofiles.open(IMAGE_PATH + f"temp/compare_{group_id}_img.jpg", 'wb') as f: - await f.write(await response.read()) - img_hash = get_img_hash(IMAGE_PATH + f"temp/compare_{group_id}_img.jpg") - return str(img_hash) diff --git a/plugins/genshin/almanac/__init__.py b/plugins/genshin/almanac/__init__.py deleted file mode 100644 index 36122e09..00000000 --- a/plugins/genshin/almanac/__init__.py +++ /dev/null @@ -1,49 +0,0 @@ -from .alc import get_almanac_base64_str, load_data -import os -from util.utils import get_bot, scheduler -from nonebot import on_command -from models.level_user import LevelUser -from nonebot.typing import T_State -from nonebot.adapters.cqhttp import Bot, GroupMessageEvent -from util.init_result import image -from services.log import logger -from models.group_remind import GroupRemind - -FILE_PATH = os.path.dirname(__file__) - -almanac = on_command('原神黄历', priority=5, block=True) -reload = on_command('重载原神黄历数据', priority=5, block=True) - - -@almanac.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - almanac_base64 = get_almanac_base64_str() - mes = image(b64=almanac_base64) + "\n ※ 黄历数据来源于 genshin.pub" - await almanac.send(mes) - logger.info( - f"(USER {event.user_id}, GROUP {event.group_id if event.message_type != 'private' else 'private'})" - f" 发送查看原神黄历") - - -@reload.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - if await LevelUser.check_level(event.user_id, event.group_id, 5): - load_data() - await reload.send("重载成功") - - -@scheduler.scheduled_job( - 'cron', - hour=10, - minute=25, -) -async def _(): - # 每日提醒 - bot = get_bot() - gl = await bot.get_group_list(self_id=bot.self_id) - gl = [g['group_id'] for g in gl] - almanac_base64 = get_almanac_base64_str() - mes = image(b64=almanac_base64) + "\n ※ 黄历数据来源于 genshin.pub" - for gid in gl: - if await GroupRemind.get_status(gid, 'almanac'): - await bot.send_group_msg(group_id=int(gid), message=mes) diff --git a/plugins/genshin/almanac/__pycache__/__init__.cpython-39.pyc b/plugins/genshin/almanac/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 45815d12..00000000 Binary files a/plugins/genshin/almanac/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/genshin/almanac/__pycache__/alc.cpython-39.pyc b/plugins/genshin/almanac/__pycache__/alc.cpython-39.pyc deleted file mode 100644 index 00560e4b..00000000 Binary files a/plugins/genshin/almanac/__pycache__/alc.cpython-39.pyc and /dev/null differ diff --git a/plugins/genshin/almanac/alc.py b/plugins/genshin/almanac/alc.py deleted file mode 100644 index 45b0205a..00000000 --- a/plugins/genshin/almanac/alc.py +++ /dev/null @@ -1,123 +0,0 @@ -from PIL import Image, ImageDraw, ImageFont -from io import BytesIO - -import os -import json -import random -import base64 -import time - -FILE_PATH = os.path.dirname(__file__) -FONT_PATH = os.path.join(FILE_PATH, "汉仪文黑.ttf") - -data = {} # configs.json里的数据 - -almanac_data = { - # 生成的黄历base64字符串和黄历更新日期 - "date": "", - "almanac_base64_str": "" -} - -chinese = {"0": "", "1": "一", "2": "二", "3": "三", "4": "四", "5": "五", "6": "六", "7": "七", "8": "八", "9": "九"} - - -def month_to_chinese(month: str): - # 把日期数字转成中文数字 - m = int(month) - if m < 10: - return chinese[month[-1]] - elif m < 20: - return "十" + chinese[month[-1]] - else: - return chinese[month[0]] + "十" + chinese[month[-1]] - - -def load_data(): - # 载入config.json文件的数据 - global data - with open(os.path.join(FILE_PATH, 'config.json'), 'r', encoding='UTF-8') as f: - data = json.load(f) - - almanac_data["date"] = "" - almanac_data["almanac_base64_str"] = "" - - -load_data() - - -def seed_random_list(seed: str, l: list): - # 使用随机种子随机选择列表中的元素,相同的种子和列表将返回同样的输出 - seed = seed + str(l) - random.seed(seed) - index = random.random() * len(l) - return l[int(index)] - - -def generate_almanac(): - # 生成黄历图片,然后转换成base64保存到 almanac_data["almanac_base64_str"] - - seed = time.strftime("%Y-%m-%d") - offset = 1 - today_luck = [] - l = list(data.keys()) - - while len(today_luck) < 6: - # 随机6个不同的运势放到 today_luck - r = seed_random_list(str(offset) + seed, l) - if r in today_luck: - offset += 1 - else: - today_luck.append(r) - - back = Image.open(os.path.join(FILE_PATH, "back.png")) - - year = time.strftime("%Y") - month = month_to_chinese(time.strftime("%m")) + "月" - day = month_to_chinese(time.strftime("%d")) + "日" - - draw = ImageDraw.Draw(back) - draw.text((118, 165), year, fill="#8d7650ff", font=ImageFont.truetype(FONT_PATH, size=30), anchor="mm", - align="center") - draw.text((260, 165), day, fill="#f7f8f2ff", font=ImageFont.truetype(FONT_PATH, size=35), anchor="mm", - align="center") - draw.text((410, 165), month, fill="#8d7650ff", font=ImageFont.truetype(FONT_PATH, size=30), anchor="mm", - align="center") - - buff = Image.new("RGBA", (325, 160)) - debuff = Image.new("RGBA", (325, 160)) - - buff_draw = ImageDraw.Draw(buff) - debuff_draw = ImageDraw.Draw(debuff) - - for i in range(3): - buff_name = today_luck[i] - debuff_name = today_luck[(i + 3)] - - buff_effect = seed_random_list(seed, data[buff_name]["buff"]) - debuff_effect = seed_random_list(seed, data[debuff_name]["debuff"]) - - buff_draw.text((0, i * 53), buff_name, fill="#756141ff", font=ImageFont.truetype(FONT_PATH, size=25)) - debuff_draw.text((0, i * 53), debuff_name, fill="#756141ff", font=ImageFont.truetype(FONT_PATH, size=25)) - - buff_draw.text((0, i * 53 + 28), buff_effect, fill="#b5b3acff", font=ImageFont.truetype(FONT_PATH, size=19)) - debuff_draw.text((0, i * 53 + 28), debuff_effect, fill="#b5b3acff", font=ImageFont.truetype(FONT_PATH, size=19)) - - back.paste(buff, (150, 230), buff) - back.paste(debuff, (150, 400), debuff) - - bio = BytesIO() - back.save(bio, format='PNG') - base64_str = base64.b64encode(bio.getvalue()).decode() - - almanac_data["date"] = time.strftime("%Y-%m-%d") - almanac_data["almanac_base64_str"] = 'base64://' + base64_str - - -def get_almanac_base64_str(): - # if almanac_data["date"] == time.strftime("%Y-%m-%d"): - # return almanac_data["almanac_base64_str"] - # else: - # generate_almanac() - # return almanac_data["almanac_base64_str"] - generate_almanac() - return almanac_data["almanac_base64_str"] diff --git a/plugins/genshin/almanac/back.png b/plugins/genshin/almanac/back.png deleted file mode 100644 index bce9428b..00000000 Binary files a/plugins/genshin/almanac/back.png and /dev/null differ diff --git a/plugins/genshin/almanac/config.json b/plugins/genshin/almanac/config.json deleted file mode 100644 index ebd1e35b..00000000 --- a/plugins/genshin/almanac/config.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "抽卡":{ - "buff": ["欧气满满,十连出金","出金不歪"], - "debuff": ["武器大师","保底出金","金色会是痛苦大剑"] - }, - "刷世界boss":{ - "buff": ["双攻双爆角斗士"], - "debuff": ["只有保底材料","贪生怕死角斗士"] - }, - "刷风本":{ - "buff": ["会有极品猎人套","会掉真正的少女心","治疗加成少女头"], - "debuff": ["勇往直前少女心","少女飘摇的杀意","少女暴怒的容颜"] - }, - "刷火本":{ - "buff": ["魔女帽子火伤杯","暴伤魔女帽!","火伤魔女心!"], - "debuff": ["幡 然 醒 悟","这么阴间的地方真的会有魔女套吗?","不务正业火魔女","会匹配到3个卢姥爷"] - }, - "刷岩本":{ - "buff": ["悠久的磐岩伴你左右","岩神的庇护常在"], - "debuff": ["防御流星杯,你值得拥有"] - }, - "刷宗室":{ - "buff": ["物理伤害骑士道,元素精通宗室套"], - "debuff": ["贪生怕死骑士道,物理伤害宗室杯"] - }, - "刷冰本":{ - "buff": ["双暴词条概率up"], - "debuff": ["防御力船帽,无人可及"] - }, - "刷雷本":{ - "buff": ["愿雷鸟伴你左右"], - "debuff": ["来表演一个只掉平雷套的绝活","风神忽悠雷凶兆"] - }, - "锄大地":{ - "buff": ["会掉一大堆紫色材料"], - "debuff": ["深渊法师爱你哟","会被冰水法控到死"] - }, - "挖矿":{ - "buff": ["开矿出双材料"], - "debuff": ["去别人世界会被拒"] - }, - "刷天赋本":{ - "buff": ["金色!我看到了金色的书!"], - "debuff": ["2蓝2绿不会变"] - }, - "刷突破材料":{ - "buff": ["金色!我看到了金色的材料!"], - "debuff": ["2蓝2绿不会变"] - }, - "升级圣遗物":{ - "buff": ["稀有词条跳跳跳","会双爆拉满"], - "debuff": ["女 仆 狂 喜","无中生有防御力","生命拉满","完美避开双爆"] - }, - "打风魔龙":{ - "buff": ["看我一箭一个风魔鸡","今天特瓦林可以给想要的突破材料","5金加原胚!"], - "debuff": ["会不小心掉下平台","不小心被地板烫死了"] - }, - "打狼王":{ - "buff": ["今天安德琉斯的心情不错,可以py一下","5金加原胚!"], - "debuff": ["狼尾巴*1"] - }, - "打公子":{ - "buff": ["今天可以和公子py想要的突破材料","5金加原胚!"], - "debuff": ["要角没有!要命一条!"] - } -} - - - - diff --git a/plugins/genshin/almanac/汉仪文黑.ttf b/plugins/genshin/almanac/汉仪文黑.ttf deleted file mode 100644 index 891435dc..00000000 Binary files a/plugins/genshin/almanac/汉仪文黑.ttf and /dev/null differ diff --git a/plugins/genshin/material_remind/__init__.py b/plugins/genshin/material_remind/__init__.py deleted file mode 100644 index 0abd8bd4..00000000 --- a/plugins/genshin/material_remind/__init__.py +++ /dev/null @@ -1,72 +0,0 @@ -from nonebot import on_command -from nonebot.typing import T_State -from nonebot.adapters.cqhttp import Bot, MessageEvent -from util.init_result import image - -import time - -material = on_command('今日素材', aliases={'今日材料', '今天素材', '今天材料'}, priority=5, block=True) -role_material = on_command('天赋材料', priority=5, block=True) - - -def get_today_material(name: str): - # 返回今天的材料图片CQ码 - if name == '天赋材料': - return image('天赋材料.png', "genshin/material/") - week = time.strftime("%w") - png_name = '' - if week == "0": - return "今天是周日,所有材料副本都开放了。" - elif week in ["1", "4"]: - png_name = f"{name}_周一周四.png" - elif week in ["2", "5"]: - png_name = f"{name}_周二周五.png" - elif week in ["3", "6"]: - png_name = f"{name}_周三周六.png" - - return image(png_name, "genshin/material/") - - -# @sv.on_fullmatch('开启原神每日素材提醒') -# async def open_remind(bot , ev): -# gid = str(ev.group_id) -# if not (gid in group_list): -# group_list.append(gid) -# save_group_list() -# await bot.send(ev, "每日提醒已开启,每天8点会发送今日素材") -# -# -# @sv.on_fullmatch('关闭原神每日素材提醒') -# async def off_remind(bot , ev): -# gid = str(ev.group_id) -# if gid in group_list: -# group_list.remove(gid) -# save_group_list() -# await bot.send(ev, "每日提醒已关闭") - -@material.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - if time.strftime("%w") == "0": - await material.send("今天是周日,所有材料副本都开放了。") - return - arms_material_CQ = get_today_material("武器突破材料") - roles_material_CQ = get_today_material("角色天赋材料") - await material.send(arms_material_CQ + roles_material_CQ) - - -@role_material.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - await material.send(get_today_material("天赋材料")) - -# @sv.scheduled_job('cron', hour='8') -# async def material_remind(): -# # 每日提醒 -# if time.strftime("%w") == "0": -# # 如果今天是周日就不发了 -# return -# bot = get_bot() -# arms_material_CQ = get_today_material("武器突破材料") -# roles_material_CQ = get_today_material("角色天赋材料") -# for gid in group_list: -# await bot.send_group_msg(group_id=int(gid), message=arms_material_CQ) -# await bot.send_group_msg(group_id=int(gid), message=roles_material_CQ) diff --git a/plugins/genshin/material_remind/__pycache__/__init__.cpython-39.pyc b/plugins/genshin/material_remind/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 75200979..00000000 Binary files a/plugins/genshin/material_remind/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/genshin/qiu_qiu_translation/__init__.py b/plugins/genshin/qiu_qiu_translation/__init__.py deleted file mode 100644 index 6f10114e..00000000 --- a/plugins/genshin/qiu_qiu_translation/__init__.py +++ /dev/null @@ -1,37 +0,0 @@ -from .qiu_translation import qiu_qiu_word_translation, qiu_qiu_phrase_translation -from nonebot.adapters.cqhttp import Bot, MessageEvent -from nonebot.typing import T_State -from nonebot import on_command -from util.utils import get_message_text -from services.log import logger - - -qiuqiu = on_command("丘丘语翻译", aliases={"丘丘一下", "丘丘翻译"}, priority=5, block=True) - -suffix = "\n※ 只能从丘丘语翻译为中文,不能反向翻译\n" \ - "※ 注意空格,不要加入任何标点符号\n" \ - "※ 翻译数据来源于 米游社论坛" - - -@qiuqiu.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - txt = get_message_text(event.json()).lower() - if txt == "": - return - mes = qiu_qiu_phrase_translation(txt) - if not mes: - mes = qiu_qiu_word_translation(txt) - mes += suffix - # print(mes) - await qiuqiu.send(mes, at_sender=True) - logger.info( - f"(USER {event.user_id}, GROUP {event.group_id if event.message_type != 'private' else 'private'})" - f" 发送丘丘翻译:" + txt) - - - - - - - - diff --git a/plugins/genshin/qiu_qiu_translation/__pycache__/__init__.cpython-39.pyc b/plugins/genshin/qiu_qiu_translation/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index c9e8e5b0..00000000 Binary files a/plugins/genshin/qiu_qiu_translation/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/genshin/qiu_qiu_translation/__pycache__/qiu_translation.cpython-39.pyc b/plugins/genshin/qiu_qiu_translation/__pycache__/qiu_translation.cpython-39.pyc deleted file mode 100644 index 45faf564..00000000 Binary files a/plugins/genshin/qiu_qiu_translation/__pycache__/qiu_translation.cpython-39.pyc and /dev/null differ diff --git a/plugins/genshin/qiu_qiu_translation/qiu_qiu_dictionary.json b/plugins/genshin/qiu_qiu_translation/qiu_qiu_dictionary.json deleted file mode 100644 index 08d0f329..00000000 --- a/plugins/genshin/qiu_qiu_translation/qiu_qiu_dictionary.json +++ /dev/null @@ -1,127 +0,0 @@ -{ - "word": { - - "a": "啊", - - "beru": "做", - "biadam": "找死啊", - "biat": "暴揍", - "buka": "肚子", - - "celi": "元素", - - "dada": "厉害", - "dala": "什么", - "domu": "跳舞", - - "eleka": "此时此刻", - - "guru": "咕", - "gusha": "草", - - "ika": "敌人", - - "kundela": "活着", - "kuzi": "强大", - "kucha": "吃草", - - "la": "啦~", - "lata": "水元素", - - "mani": "给予", - "mi": "我", - "mimi": "我们", - "mita": "肉类", - "mosi": "吃", - "movo": "带来", - "muhe": "胜利", - - "ni": "风", - "nini": "风暴", - "nunu": "睡觉", - "nye": "不", - - "odomu": "朋友", - "olah": "你好", - - "plata": "盾牌", - "pupu": "噗噗", - - "sada": "唱歌", - "shato": "伴随", - "si": "什么", - - "tomo": "感激", - "todo": "放心", - "tiga": "矿石", - - "upa": "聚集", - "unu": "乌努", - - "valo": "谢谢你", - "vin": "酒", - - "ya": "人", - "yaya": "人们", - "ye": "家伙", - "yeye": "这些家伙", - "yo": "你", - "yoyo": "你们", - - "zido": "杀死" - - }, - "phrase": { - "beru si": "做什么", - "biadam": "可恶啊,找死啊,愤怒语气", - "biat": "打爆,暴揍;可恶的", - - "dada": " 极好的,厉害的", - "dala": "表示疑问,不明白的集合,翻译为哪个,什么", - - "guru-guru": "拟声词,形容肚子咕咕叫的声音,饥饿", - "guru guru": "拟声词,形容肚子咕咕叫的声音,饥饿", - "gusha": "植物类食物,不怎么好的,难过的", - - "kucha pupu": "拟声词,吃草时候的拟声词,咯吱噗噗,形容吃草吃得香,贬义", - - "mita": "肉类,好的,好东西,有时代丘丘人,丘丘人部落,好肉族", - "mosi mita": "吃肉,表示开心", - "mosi gusha": "吃草,表示难过", - "movo": "带来,搬运;可引申为收获,丰收", - "muhe": "胜利,战胜;成功的", - - "nini": "大量风元素,风暴,狂风", - "nye": "表示否定,没有了,不是", - - "pupu":"拟声词,噗噗,表示嘲讽", - - "sada": "唱歌,歌颂", - "shato": "乘着,伴随着", - - "upa": "凝聚,聚集,集合;聚落,部落", - "unu": "乌努,丘丘人所崇拜的神灵", - - "valo": "谢谢你,不客气/再见", - "vin": "酒的,喝酒有关的,酒桶盖子", - - "ya": "特指人类,一个人类", - "yaya": "人类的复数 ,大群人类", - "ye": "你这个家伙,蔑称;或用于地位高者对地位低者的称呼", - "yeye": "你们这些家伙,蔑称,ye的复数", - "yo": "你,友善称呼", - "yoyo": "你们,yo的复数,友善称呼ye", - - - - "nye mita da ye mosi zido": "再见,一路平安", - "vin plata dada": "你的酒桶盾牌真不错", - "kucha pupu gucha ye": "你咯吱噗噗的吃草的样子真的好搞笑", - "mani nini biaodomu": "愿风暴给予你死亡", - "celi dada mimi nunu": "赞美元素,我们睡觉吧", - "muhe ye": "你们是不可战胜的", - "ye dada": "你们可真棒", - "ye yika": "你们是敌人", - "nini zido": "愿风暴杀死你" - } -} \ No newline at end of file diff --git a/plugins/genshin/qiu_qiu_translation/qiu_translation.py b/plugins/genshin/qiu_qiu_translation/qiu_translation.py deleted file mode 100644 index f4e9ebc4..00000000 --- a/plugins/genshin/qiu_qiu_translation/qiu_translation.py +++ /dev/null @@ -1,71 +0,0 @@ -import json -import os - -FILE_PATH = os.path.dirname(__file__) - -QIU_QIU_WORD = {} -QIU_QIU_PHRASE = {} - -with open(os.path.join(FILE_PATH, 'qiu_qiu_dictionary.json'), 'r', encoding='UTF-8') as f: - data = json.load(f) - QIU_QIU_WORD = data["word"] - QIU_QIU_PHRASE = data["phrase"] - - -def compare_words(word): - # 比对word库是否有匹配的单词,有的话返回翻译,没有返回原词 - if word in QIU_QIU_WORD: - return QIU_QIU_WORD[word] - - return word - - -def compare_phrase(phrase): - # 比对phrase库是否有匹配的单词,有的话返回翻译,没有的话匹配word库,都没有返回原词 - if phrase in QIU_QIU_PHRASE: - return QIU_QIU_PHRASE[phrase] - if phrase in QIU_QIU_WORD: - return QIU_QIU_WORD[phrase] - - return phrase - - -def qiu_qiu_word_translation(txt: str): - # 对语句按空格分隔替换单词翻译 - txt_list = txt.split(" ") - mes = "你查询的的丘丘语意思为:\n" - - for word in txt_list: - tra_word = compare_words(word) - - if tra_word == word: - # 如果是原词表示没有翻译,前后加空格接回语句里 - if not mes[-1] == " ": - mes += " " - mes += tra_word - mes += " " - else: - mes += tra_word - mes += "\n" - return mes - - -def qiu_qiu_phrase_translation(phrase): - # 语句翻译,先看phrase库是不是有匹配的语句 - # 没有的话把单词拆开返回单词的意思 - tra_phrase = compare_phrase(phrase) - if tra_phrase != phrase: - return f"\n翻译丘丘语意思为:\n【{tra_phrase}】\n" - - txt_list = phrase.split(" ") - mes = "没有查到这句丘丘语,以下是单词的翻译\n" - for word in txt_list: - if word == " ": - continue - tra_word = compare_phrase(word) - if tra_word == word: - mes += f"{word} : 没有这个词的翻译\n" - else: - mes += f"{word} : {tra_word}\n" - - return mes diff --git a/plugins/genshin/query_resource_points/__init__.py b/plugins/genshin/query_resource_points/__init__.py deleted file mode 100644 index 8e170d54..00000000 --- a/plugins/genshin/query_resource_points/__init__.py +++ /dev/null @@ -1,96 +0,0 @@ -from nonebot import on_command, on_regex -from .query_resource import get_resource_map_mes, get_resource_list_mes, up_label_and_point_list -from util.utils import get_message_text, scheduler -from nonebot.adapters.cqhttp import Bot, MessageEvent -from nonebot.typing import T_State -import os -from services.log import logger -import re -try: - import ujson as json -except ModuleNotFoundError: - import json - -qr = on_command("原神资源查询", priority=5, block=True) -qr_lst = on_command("原神资源列表", priority=5, block=True) -rex_qr = on_regex('.*?(在哪|在哪里|哪有|哪里有).*?', priority=5, block=True) - - -with open(os.path.dirname(__file__) + '/resource_type_id.json', 'r', encoding='utf-8') as f: - in_list = [n['name'] for n in json.load(f).values()] - - -@qr.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - resource_name = get_message_text(event.json()) - if resource_name == "" or resource_name not in in_list: - return - - await qr.send(get_resource_map_mes(resource_name), at_sender=True) - logger.info( - f"(USER {event.user_id}, GROUP {event.group_id if event.message_type != 'private' else 'private'})" - f" 查询原神材料:" + resource_name) - - -@rex_qr.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - msg = get_message_text(event.json()) - if msg.find('在哪') != -1: - rs = re.search('(.*)在哪.*?', msg) - resource_name = rs.group(1) if rs else '' - else: - rs = re.search('.*?(哪有|哪里有)(.*)', msg) - resource_name = rs.group(2) if rs else '' - if resource_name: - msg = get_resource_map_mes(resource_name) - if msg == '发送 原神资源列表 查看所有资源名称': - return - await rex_qr.send(msg, at_sender=True) - logger.info( - f"(USER {event.user_id}, GROUP {event.group_id if event.message_type != 'private' else 'private'})" - f" 查询原神材料:" + resource_name) - - -@qr_lst.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - # 长条消息经常发送失败,所以只能这样了 - mes_list = [] - txt = get_resource_list_mes() - txt_list = txt.split("\n") - if event.message_type == 'group': - for txt in txt_list: - data = { - "type": "node", - "data": { - "name": f"这里是{list(bot.config.nickname)[0]}酱", - "uin": f"{bot.self_id}", - "content": txt - } - } - mes_list.append(data) - # await bot.send(ev, get_resource_list_mes(), at_sender=True) - if event.message_type == 'group': - await bot.send_group_forward_msg(group_id=event.group_id, messages=mes_list) - else: - rst = '' - for i in range(len(txt_list)): - rst += txt_list[i] + '\n' - if i % 5 == 0: - if rst: - await qr_lst.send(rst) - rst = '' - - # await qr_lst.send(Message(mes_list)) - - -@scheduler.scheduled_job( - 'cron', - hour=5, - minute=1, -) -async def _(): - try: - up_label_and_point_list() - logger.info(f'每日更新原神材料信息成功!') - except Exception as e: - logger.error(f'每日更新原神材料信息错误:{e}') diff --git a/plugins/genshin/query_resource_points/__pycache__/__init__.cpython-39.pyc b/plugins/genshin/query_resource_points/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 67a99089..00000000 Binary files a/plugins/genshin/query_resource_points/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/genshin/query_resource_points/__pycache__/query_resource.cpython-39.pyc b/plugins/genshin/query_resource_points/__pycache__/query_resource.cpython-39.pyc deleted file mode 100644 index 7515ff1f..00000000 Binary files a/plugins/genshin/query_resource_points/__pycache__/query_resource.cpython-39.pyc and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/0.png b/plugins/genshin/query_resource_points/icon/0.png deleted file mode 100644 index bdf2090b..00000000 Binary files a/plugins/genshin/query_resource_points/icon/0.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/111.png b/plugins/genshin/query_resource_points/icon/111.png deleted file mode 100644 index f4d2cbf0..00000000 Binary files a/plugins/genshin/query_resource_points/icon/111.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/112.png b/plugins/genshin/query_resource_points/icon/112.png deleted file mode 100644 index 9e65d4d1..00000000 Binary files a/plugins/genshin/query_resource_points/icon/112.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/114.png b/plugins/genshin/query_resource_points/icon/114.png deleted file mode 100644 index d40c7408..00000000 Binary files a/plugins/genshin/query_resource_points/icon/114.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/115.png b/plugins/genshin/query_resource_points/icon/115.png deleted file mode 100644 index 170c7cbe..00000000 Binary files a/plugins/genshin/query_resource_points/icon/115.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/116.png b/plugins/genshin/query_resource_points/icon/116.png deleted file mode 100644 index c4ef99d3..00000000 Binary files a/plugins/genshin/query_resource_points/icon/116.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/121.png b/plugins/genshin/query_resource_points/icon/121.png deleted file mode 100644 index 0688557d..00000000 Binary files a/plugins/genshin/query_resource_points/icon/121.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/122.png b/plugins/genshin/query_resource_points/icon/122.png deleted file mode 100644 index 50daa97b..00000000 Binary files a/plugins/genshin/query_resource_points/icon/122.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/123.png b/plugins/genshin/query_resource_points/icon/123.png deleted file mode 100644 index a5292464..00000000 Binary files a/plugins/genshin/query_resource_points/icon/123.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/124.png b/plugins/genshin/query_resource_points/icon/124.png deleted file mode 100644 index 5a2e1080..00000000 Binary files a/plugins/genshin/query_resource_points/icon/124.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/125.png b/plugins/genshin/query_resource_points/icon/125.png deleted file mode 100644 index 8b2a2f3b..00000000 Binary files a/plugins/genshin/query_resource_points/icon/125.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/126.png b/plugins/genshin/query_resource_points/icon/126.png deleted file mode 100644 index 69fb0e25..00000000 Binary files a/plugins/genshin/query_resource_points/icon/126.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/127.png b/plugins/genshin/query_resource_points/icon/127.png deleted file mode 100644 index 96deca99..00000000 Binary files a/plugins/genshin/query_resource_points/icon/127.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/128.png b/plugins/genshin/query_resource_points/icon/128.png deleted file mode 100644 index 2a9d7fe4..00000000 Binary files a/plugins/genshin/query_resource_points/icon/128.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/129.png b/plugins/genshin/query_resource_points/icon/129.png deleted file mode 100644 index 18dbf5da..00000000 Binary files a/plugins/genshin/query_resource_points/icon/129.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/130.png b/plugins/genshin/query_resource_points/icon/130.png deleted file mode 100644 index 819cfa94..00000000 Binary files a/plugins/genshin/query_resource_points/icon/130.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/132.png b/plugins/genshin/query_resource_points/icon/132.png deleted file mode 100644 index c5f6ccdc..00000000 Binary files a/plugins/genshin/query_resource_points/icon/132.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/133.png b/plugins/genshin/query_resource_points/icon/133.png deleted file mode 100644 index 4580c898..00000000 Binary files a/plugins/genshin/query_resource_points/icon/133.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/134.png b/plugins/genshin/query_resource_points/icon/134.png deleted file mode 100644 index 8fea3209..00000000 Binary files a/plugins/genshin/query_resource_points/icon/134.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/135.png b/plugins/genshin/query_resource_points/icon/135.png deleted file mode 100644 index 03dafbce..00000000 Binary files a/plugins/genshin/query_resource_points/icon/135.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/136.png b/plugins/genshin/query_resource_points/icon/136.png deleted file mode 100644 index 0b66d22e..00000000 Binary files a/plugins/genshin/query_resource_points/icon/136.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/137.png b/plugins/genshin/query_resource_points/icon/137.png deleted file mode 100644 index 1d2d1aeb..00000000 Binary files a/plugins/genshin/query_resource_points/icon/137.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/138.png b/plugins/genshin/query_resource_points/icon/138.png deleted file mode 100644 index 46c1aa8e..00000000 Binary files a/plugins/genshin/query_resource_points/icon/138.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/139.png b/plugins/genshin/query_resource_points/icon/139.png deleted file mode 100644 index 77faf73a..00000000 Binary files a/plugins/genshin/query_resource_points/icon/139.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/140.png b/plugins/genshin/query_resource_points/icon/140.png deleted file mode 100644 index 0f8c18d4..00000000 Binary files a/plugins/genshin/query_resource_points/icon/140.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/141.png b/plugins/genshin/query_resource_points/icon/141.png deleted file mode 100644 index 1f08de30..00000000 Binary files a/plugins/genshin/query_resource_points/icon/141.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/142.png b/plugins/genshin/query_resource_points/icon/142.png deleted file mode 100644 index 3e9fed51..00000000 Binary files a/plugins/genshin/query_resource_points/icon/142.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/144.png b/plugins/genshin/query_resource_points/icon/144.png deleted file mode 100644 index a2bd5345..00000000 Binary files a/plugins/genshin/query_resource_points/icon/144.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/145.png b/plugins/genshin/query_resource_points/icon/145.png deleted file mode 100644 index 7dbb019e..00000000 Binary files a/plugins/genshin/query_resource_points/icon/145.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/146.png b/plugins/genshin/query_resource_points/icon/146.png deleted file mode 100644 index 3e3eb1a7..00000000 Binary files a/plugins/genshin/query_resource_points/icon/146.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/147.png b/plugins/genshin/query_resource_points/icon/147.png deleted file mode 100644 index 0b1f1d6d..00000000 Binary files a/plugins/genshin/query_resource_points/icon/147.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/148.png b/plugins/genshin/query_resource_points/icon/148.png deleted file mode 100644 index 5af3c4d3..00000000 Binary files a/plugins/genshin/query_resource_points/icon/148.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/149.png b/plugins/genshin/query_resource_points/icon/149.png deleted file mode 100644 index 15c7b527..00000000 Binary files a/plugins/genshin/query_resource_points/icon/149.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/15.png b/plugins/genshin/query_resource_points/icon/15.png deleted file mode 100644 index ff293295..00000000 Binary files a/plugins/genshin/query_resource_points/icon/15.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/150.png b/plugins/genshin/query_resource_points/icon/150.png deleted file mode 100644 index 6505b52b..00000000 Binary files a/plugins/genshin/query_resource_points/icon/150.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/151.png b/plugins/genshin/query_resource_points/icon/151.png deleted file mode 100644 index 7e5f375a..00000000 Binary files a/plugins/genshin/query_resource_points/icon/151.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/152.png b/plugins/genshin/query_resource_points/icon/152.png deleted file mode 100644 index 13fa2bb2..00000000 Binary files a/plugins/genshin/query_resource_points/icon/152.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/153.png b/plugins/genshin/query_resource_points/icon/153.png deleted file mode 100644 index 0f0cd81a..00000000 Binary files a/plugins/genshin/query_resource_points/icon/153.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/154.png b/plugins/genshin/query_resource_points/icon/154.png deleted file mode 100644 index c64dc1a6..00000000 Binary files a/plugins/genshin/query_resource_points/icon/154.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/155.png b/plugins/genshin/query_resource_points/icon/155.png deleted file mode 100644 index c727d9bd..00000000 Binary files a/plugins/genshin/query_resource_points/icon/155.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/156.png b/plugins/genshin/query_resource_points/icon/156.png deleted file mode 100644 index 4bae16d4..00000000 Binary files a/plugins/genshin/query_resource_points/icon/156.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/157.png b/plugins/genshin/query_resource_points/icon/157.png deleted file mode 100644 index a2240d86..00000000 Binary files a/plugins/genshin/query_resource_points/icon/157.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/158.png b/plugins/genshin/query_resource_points/icon/158.png deleted file mode 100644 index 5557590a..00000000 Binary files a/plugins/genshin/query_resource_points/icon/158.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/159.png b/plugins/genshin/query_resource_points/icon/159.png deleted file mode 100644 index 65e7847d..00000000 Binary files a/plugins/genshin/query_resource_points/icon/159.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/16.png b/plugins/genshin/query_resource_points/icon/16.png deleted file mode 100644 index 335c5620..00000000 Binary files a/plugins/genshin/query_resource_points/icon/16.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/160.png b/plugins/genshin/query_resource_points/icon/160.png deleted file mode 100644 index ce63151f..00000000 Binary files a/plugins/genshin/query_resource_points/icon/160.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/161.png b/plugins/genshin/query_resource_points/icon/161.png deleted file mode 100644 index 529fb1ef..00000000 Binary files a/plugins/genshin/query_resource_points/icon/161.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/162.png b/plugins/genshin/query_resource_points/icon/162.png deleted file mode 100644 index 584445bd..00000000 Binary files a/plugins/genshin/query_resource_points/icon/162.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/163.png b/plugins/genshin/query_resource_points/icon/163.png deleted file mode 100644 index fff75557..00000000 Binary files a/plugins/genshin/query_resource_points/icon/163.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/164.png b/plugins/genshin/query_resource_points/icon/164.png deleted file mode 100644 index ecb3bf75..00000000 Binary files a/plugins/genshin/query_resource_points/icon/164.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/165.png b/plugins/genshin/query_resource_points/icon/165.png deleted file mode 100644 index 7d3f2cb2..00000000 Binary files a/plugins/genshin/query_resource_points/icon/165.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/166.png b/plugins/genshin/query_resource_points/icon/166.png deleted file mode 100644 index 3f79f9fb..00000000 Binary files a/plugins/genshin/query_resource_points/icon/166.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/167.png b/plugins/genshin/query_resource_points/icon/167.png deleted file mode 100644 index 2e4ee1b8..00000000 Binary files a/plugins/genshin/query_resource_points/icon/167.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/168.png b/plugins/genshin/query_resource_points/icon/168.png deleted file mode 100644 index 9f0dfc7a..00000000 Binary files a/plugins/genshin/query_resource_points/icon/168.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/169.png b/plugins/genshin/query_resource_points/icon/169.png deleted file mode 100644 index 78f77636..00000000 Binary files a/plugins/genshin/query_resource_points/icon/169.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/17.png b/plugins/genshin/query_resource_points/icon/17.png deleted file mode 100644 index 40b32bc6..00000000 Binary files a/plugins/genshin/query_resource_points/icon/17.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/171.png b/plugins/genshin/query_resource_points/icon/171.png deleted file mode 100644 index 589dc69c..00000000 Binary files a/plugins/genshin/query_resource_points/icon/171.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/172.png b/plugins/genshin/query_resource_points/icon/172.png deleted file mode 100644 index 7bb0c770..00000000 Binary files a/plugins/genshin/query_resource_points/icon/172.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/174.png b/plugins/genshin/query_resource_points/icon/174.png deleted file mode 100644 index 8b98f1f4..00000000 Binary files a/plugins/genshin/query_resource_points/icon/174.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/175.png b/plugins/genshin/query_resource_points/icon/175.png deleted file mode 100644 index f7b230b8..00000000 Binary files a/plugins/genshin/query_resource_points/icon/175.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/176.png b/plugins/genshin/query_resource_points/icon/176.png deleted file mode 100644 index 8ed71d50..00000000 Binary files a/plugins/genshin/query_resource_points/icon/176.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/177.png b/plugins/genshin/query_resource_points/icon/177.png deleted file mode 100644 index 6bba6626..00000000 Binary files a/plugins/genshin/query_resource_points/icon/177.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/178.png b/plugins/genshin/query_resource_points/icon/178.png deleted file mode 100644 index 7068d7fe..00000000 Binary files a/plugins/genshin/query_resource_points/icon/178.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/179.png b/plugins/genshin/query_resource_points/icon/179.png deleted file mode 100644 index 93ad62d1..00000000 Binary files a/plugins/genshin/query_resource_points/icon/179.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/18.png b/plugins/genshin/query_resource_points/icon/18.png deleted file mode 100644 index 834a9892..00000000 Binary files a/plugins/genshin/query_resource_points/icon/18.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/180.png b/plugins/genshin/query_resource_points/icon/180.png deleted file mode 100644 index a4f2cd33..00000000 Binary files a/plugins/genshin/query_resource_points/icon/180.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/181.png b/plugins/genshin/query_resource_points/icon/181.png deleted file mode 100644 index 35d88703..00000000 Binary files a/plugins/genshin/query_resource_points/icon/181.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/19.png b/plugins/genshin/query_resource_points/icon/19.png deleted file mode 100644 index 15c7b527..00000000 Binary files a/plugins/genshin/query_resource_points/icon/19.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/2.png b/plugins/genshin/query_resource_points/icon/2.png deleted file mode 100644 index 750b70ab..00000000 Binary files a/plugins/genshin/query_resource_points/icon/2.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/20.png b/plugins/genshin/query_resource_points/icon/20.png deleted file mode 100644 index 15c7b527..00000000 Binary files a/plugins/genshin/query_resource_points/icon/20.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/21.png b/plugins/genshin/query_resource_points/icon/21.png deleted file mode 100644 index 15c7b527..00000000 Binary files a/plugins/genshin/query_resource_points/icon/21.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/22.png b/plugins/genshin/query_resource_points/icon/22.png deleted file mode 100644 index 6d3903c2..00000000 Binary files a/plugins/genshin/query_resource_points/icon/22.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/23.png b/plugins/genshin/query_resource_points/icon/23.png deleted file mode 100644 index c741955a..00000000 Binary files a/plugins/genshin/query_resource_points/icon/23.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/24.png b/plugins/genshin/query_resource_points/icon/24.png deleted file mode 100644 index 552c8e0c..00000000 Binary files a/plugins/genshin/query_resource_points/icon/24.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/25.png b/plugins/genshin/query_resource_points/icon/25.png deleted file mode 100644 index f965ee0f..00000000 Binary files a/plugins/genshin/query_resource_points/icon/25.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/26.png b/plugins/genshin/query_resource_points/icon/26.png deleted file mode 100644 index d83e5d94..00000000 Binary files a/plugins/genshin/query_resource_points/icon/26.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/27.png b/plugins/genshin/query_resource_points/icon/27.png deleted file mode 100644 index 6505b52b..00000000 Binary files a/plugins/genshin/query_resource_points/icon/27.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/28.png b/plugins/genshin/query_resource_points/icon/28.png deleted file mode 100644 index 4a55f481..00000000 Binary files a/plugins/genshin/query_resource_points/icon/28.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/29.png b/plugins/genshin/query_resource_points/icon/29.png deleted file mode 100644 index ad5640d2..00000000 Binary files a/plugins/genshin/query_resource_points/icon/29.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/3.png b/plugins/genshin/query_resource_points/icon/3.png deleted file mode 100644 index e7acb4d1..00000000 Binary files a/plugins/genshin/query_resource_points/icon/3.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/30.png b/plugins/genshin/query_resource_points/icon/30.png deleted file mode 100644 index aee459ae..00000000 Binary files a/plugins/genshin/query_resource_points/icon/30.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/31.png b/plugins/genshin/query_resource_points/icon/31.png deleted file mode 100644 index e2011791..00000000 Binary files a/plugins/genshin/query_resource_points/icon/31.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/32.png b/plugins/genshin/query_resource_points/icon/32.png deleted file mode 100644 index 6920a7a0..00000000 Binary files a/plugins/genshin/query_resource_points/icon/32.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/33.png b/plugins/genshin/query_resource_points/icon/33.png deleted file mode 100644 index 29c9d4c7..00000000 Binary files a/plugins/genshin/query_resource_points/icon/33.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/34.png b/plugins/genshin/query_resource_points/icon/34.png deleted file mode 100644 index a95826fa..00000000 Binary files a/plugins/genshin/query_resource_points/icon/34.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/35.png b/plugins/genshin/query_resource_points/icon/35.png deleted file mode 100644 index 2b4490d4..00000000 Binary files a/plugins/genshin/query_resource_points/icon/35.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/36.png b/plugins/genshin/query_resource_points/icon/36.png deleted file mode 100644 index 16122c1c..00000000 Binary files a/plugins/genshin/query_resource_points/icon/36.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/37.png b/plugins/genshin/query_resource_points/icon/37.png deleted file mode 100644 index b7ee5e4b..00000000 Binary files a/plugins/genshin/query_resource_points/icon/37.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/38.png b/plugins/genshin/query_resource_points/icon/38.png deleted file mode 100644 index e2edc76e..00000000 Binary files a/plugins/genshin/query_resource_points/icon/38.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/39.png b/plugins/genshin/query_resource_points/icon/39.png deleted file mode 100644 index 084a54b2..00000000 Binary files a/plugins/genshin/query_resource_points/icon/39.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/40.png b/plugins/genshin/query_resource_points/icon/40.png deleted file mode 100644 index 7d19ceae..00000000 Binary files a/plugins/genshin/query_resource_points/icon/40.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/41.png b/plugins/genshin/query_resource_points/icon/41.png deleted file mode 100644 index 3e3eb753..00000000 Binary files a/plugins/genshin/query_resource_points/icon/41.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/42.png b/plugins/genshin/query_resource_points/icon/42.png deleted file mode 100644 index 65ffab67..00000000 Binary files a/plugins/genshin/query_resource_points/icon/42.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/43.png b/plugins/genshin/query_resource_points/icon/43.png deleted file mode 100644 index 14f37021..00000000 Binary files a/plugins/genshin/query_resource_points/icon/43.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/44.png b/plugins/genshin/query_resource_points/icon/44.png deleted file mode 100644 index f6e3abbc..00000000 Binary files a/plugins/genshin/query_resource_points/icon/44.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/45.png b/plugins/genshin/query_resource_points/icon/45.png deleted file mode 100644 index 09e54d44..00000000 Binary files a/plugins/genshin/query_resource_points/icon/45.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/46.png b/plugins/genshin/query_resource_points/icon/46.png deleted file mode 100644 index f3c0091d..00000000 Binary files a/plugins/genshin/query_resource_points/icon/46.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/47.png b/plugins/genshin/query_resource_points/icon/47.png deleted file mode 100644 index 588addf8..00000000 Binary files a/plugins/genshin/query_resource_points/icon/47.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/48.png b/plugins/genshin/query_resource_points/icon/48.png deleted file mode 100644 index e3588f05..00000000 Binary files a/plugins/genshin/query_resource_points/icon/48.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/49.png b/plugins/genshin/query_resource_points/icon/49.png deleted file mode 100644 index 9a8084d2..00000000 Binary files a/plugins/genshin/query_resource_points/icon/49.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/5.png b/plugins/genshin/query_resource_points/icon/5.png deleted file mode 100644 index 9f34678a..00000000 Binary files a/plugins/genshin/query_resource_points/icon/5.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/52.png b/plugins/genshin/query_resource_points/icon/52.png deleted file mode 100644 index d7a86d29..00000000 Binary files a/plugins/genshin/query_resource_points/icon/52.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/53.png b/plugins/genshin/query_resource_points/icon/53.png deleted file mode 100644 index edc32b6c..00000000 Binary files a/plugins/genshin/query_resource_points/icon/53.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/54.png b/plugins/genshin/query_resource_points/icon/54.png deleted file mode 100644 index 079fcd3a..00000000 Binary files a/plugins/genshin/query_resource_points/icon/54.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/55.png b/plugins/genshin/query_resource_points/icon/55.png deleted file mode 100644 index 0ad0c375..00000000 Binary files a/plugins/genshin/query_resource_points/icon/55.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/56.png b/plugins/genshin/query_resource_points/icon/56.png deleted file mode 100644 index 675b4b51..00000000 Binary files a/plugins/genshin/query_resource_points/icon/56.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/57.png b/plugins/genshin/query_resource_points/icon/57.png deleted file mode 100644 index 42059d7d..00000000 Binary files a/plugins/genshin/query_resource_points/icon/57.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/58.png b/plugins/genshin/query_resource_points/icon/58.png deleted file mode 100644 index 6d974f15..00000000 Binary files a/plugins/genshin/query_resource_points/icon/58.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/59.png b/plugins/genshin/query_resource_points/icon/59.png deleted file mode 100644 index ea647506..00000000 Binary files a/plugins/genshin/query_resource_points/icon/59.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/6.png b/plugins/genshin/query_resource_points/icon/6.png deleted file mode 100644 index 46dd6248..00000000 Binary files a/plugins/genshin/query_resource_points/icon/6.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/61.png b/plugins/genshin/query_resource_points/icon/61.png deleted file mode 100644 index bdb41098..00000000 Binary files a/plugins/genshin/query_resource_points/icon/61.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/62.png b/plugins/genshin/query_resource_points/icon/62.png deleted file mode 100644 index e2756288..00000000 Binary files a/plugins/genshin/query_resource_points/icon/62.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/63.png b/plugins/genshin/query_resource_points/icon/63.png deleted file mode 100644 index 8ab37ba9..00000000 Binary files a/plugins/genshin/query_resource_points/icon/63.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/64.png b/plugins/genshin/query_resource_points/icon/64.png deleted file mode 100644 index a071a2d2..00000000 Binary files a/plugins/genshin/query_resource_points/icon/64.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/65.png b/plugins/genshin/query_resource_points/icon/65.png deleted file mode 100644 index f0ad7543..00000000 Binary files a/plugins/genshin/query_resource_points/icon/65.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/66.png b/plugins/genshin/query_resource_points/icon/66.png deleted file mode 100644 index fba56f23..00000000 Binary files a/plugins/genshin/query_resource_points/icon/66.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/67.png b/plugins/genshin/query_resource_points/icon/67.png deleted file mode 100644 index 6a7718bb..00000000 Binary files a/plugins/genshin/query_resource_points/icon/67.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/68.png b/plugins/genshin/query_resource_points/icon/68.png deleted file mode 100644 index 2e1c8b45..00000000 Binary files a/plugins/genshin/query_resource_points/icon/68.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/69.png b/plugins/genshin/query_resource_points/icon/69.png deleted file mode 100644 index 40b32bc6..00000000 Binary files a/plugins/genshin/query_resource_points/icon/69.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/70.png b/plugins/genshin/query_resource_points/icon/70.png deleted file mode 100644 index 185edcbb..00000000 Binary files a/plugins/genshin/query_resource_points/icon/70.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/71.png b/plugins/genshin/query_resource_points/icon/71.png deleted file mode 100644 index 338673ca..00000000 Binary files a/plugins/genshin/query_resource_points/icon/71.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/72.png b/plugins/genshin/query_resource_points/icon/72.png deleted file mode 100644 index bc594d88..00000000 Binary files a/plugins/genshin/query_resource_points/icon/72.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/73.png b/plugins/genshin/query_resource_points/icon/73.png deleted file mode 100644 index 91bbb218..00000000 Binary files a/plugins/genshin/query_resource_points/icon/73.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/74.png b/plugins/genshin/query_resource_points/icon/74.png deleted file mode 100644 index 52ba1db2..00000000 Binary files a/plugins/genshin/query_resource_points/icon/74.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/75.png b/plugins/genshin/query_resource_points/icon/75.png deleted file mode 100644 index 8a1bcf7c..00000000 Binary files a/plugins/genshin/query_resource_points/icon/75.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/76.png b/plugins/genshin/query_resource_points/icon/76.png deleted file mode 100644 index 0db7ac5f..00000000 Binary files a/plugins/genshin/query_resource_points/icon/76.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/77.png b/plugins/genshin/query_resource_points/icon/77.png deleted file mode 100644 index a18d10d4..00000000 Binary files a/plugins/genshin/query_resource_points/icon/77.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/78.png b/plugins/genshin/query_resource_points/icon/78.png deleted file mode 100644 index 123bbab2..00000000 Binary files a/plugins/genshin/query_resource_points/icon/78.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/79.png b/plugins/genshin/query_resource_points/icon/79.png deleted file mode 100644 index 0ad0c375..00000000 Binary files a/plugins/genshin/query_resource_points/icon/79.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/8.png b/plugins/genshin/query_resource_points/icon/8.png deleted file mode 100644 index e41899b9..00000000 Binary files a/plugins/genshin/query_resource_points/icon/8.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/80.png b/plugins/genshin/query_resource_points/icon/80.png deleted file mode 100644 index 59b29e15..00000000 Binary files a/plugins/genshin/query_resource_points/icon/80.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/81.png b/plugins/genshin/query_resource_points/icon/81.png deleted file mode 100644 index 63e1103c..00000000 Binary files a/plugins/genshin/query_resource_points/icon/81.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/82.png b/plugins/genshin/query_resource_points/icon/82.png deleted file mode 100644 index c4b08c12..00000000 Binary files a/plugins/genshin/query_resource_points/icon/82.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/83.png b/plugins/genshin/query_resource_points/icon/83.png deleted file mode 100644 index 52ba1db2..00000000 Binary files a/plugins/genshin/query_resource_points/icon/83.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/85.png b/plugins/genshin/query_resource_points/icon/85.png deleted file mode 100644 index ba15fa7c..00000000 Binary files a/plugins/genshin/query_resource_points/icon/85.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/87.png b/plugins/genshin/query_resource_points/icon/87.png deleted file mode 100644 index 42978116..00000000 Binary files a/plugins/genshin/query_resource_points/icon/87.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/9.png b/plugins/genshin/query_resource_points/icon/9.png deleted file mode 100644 index 4765b4e0..00000000 Binary files a/plugins/genshin/query_resource_points/icon/9.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/90.png b/plugins/genshin/query_resource_points/icon/90.png deleted file mode 100644 index 05f6f4c0..00000000 Binary files a/plugins/genshin/query_resource_points/icon/90.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/91.png b/plugins/genshin/query_resource_points/icon/91.png deleted file mode 100644 index cb391933..00000000 Binary files a/plugins/genshin/query_resource_points/icon/91.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/92.png b/plugins/genshin/query_resource_points/icon/92.png deleted file mode 100644 index 9119776b..00000000 Binary files a/plugins/genshin/query_resource_points/icon/92.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/93.png b/plugins/genshin/query_resource_points/icon/93.png deleted file mode 100644 index bf8164cd..00000000 Binary files a/plugins/genshin/query_resource_points/icon/93.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/94.png b/plugins/genshin/query_resource_points/icon/94.png deleted file mode 100644 index 8b51144b..00000000 Binary files a/plugins/genshin/query_resource_points/icon/94.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/box.png b/plugins/genshin/query_resource_points/icon/box.png deleted file mode 100644 index dadec344..00000000 Binary files a/plugins/genshin/query_resource_points/icon/box.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/icon/box_alpha.png b/plugins/genshin/query_resource_points/icon/box_alpha.png deleted file mode 100644 index 0c634fa2..00000000 Binary files a/plugins/genshin/query_resource_points/icon/box_alpha.png and /dev/null differ diff --git a/plugins/genshin/query_resource_points/query_resource.py b/plugins/genshin/query_resource_points/query_resource.py deleted file mode 100644 index 7637ffae..00000000 --- a/plugins/genshin/query_resource_points/query_resource.py +++ /dev/null @@ -1,283 +0,0 @@ -from urllib import request -from PIL import Image, ImageMath -from io import BytesIO -import json -import os -import time -import base64 -from configs.path_config import IMAGE_PATH -from util.init_result import image - -LABEL_URL = 'https://api-static.mihoyo.com/common/blackboard/ys_obc/v1/map/label/tree?app_sn=ys_obc' -POINT_LIST_URL = 'https://api-static.mihoyo.com/common/blackboard/ys_obc/v1/map/point/list?map_id=2&app_sn=ys_obc' - -header = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) ' \ - 'Chrome/84.0.4147.105 Safari/537.36' - -FILE_PATH = os.path.dirname(__file__) - -MAP_PATH = os.path.join(IMAGE_PATH, "genshin", "seek_god_eye", "icon", "map_icon.jpg") -MAP_IMAGE = Image.open(MAP_PATH) -MAP_SIZE = MAP_IMAGE.size - -# resource_point里记录的坐标是相对坐标,是以蒙德城的大雕像为中心的,所以图片合成时需要转换坐标 -CENTER = (3505, 1907) - -zoom = 0.75 -resource_icon_offset = (-int(150 * 0.5 * zoom), -int(150 * zoom)) - -data = { - "all_resource_type": { - # 这个字典保存所有资源类型, - # "1": { - # "id": 1, - # "name": "传送点", - # "icon": "", - # "parent_id": 0, - # "depth": 1, - # "node_type": 1, - # "jump_type": 0, - # "jump_target_id": 0, - # "display_priority": 0, - # "children": [] - # }, - }, - "can_query_type_list": { - # 这个字典保存所有可以查询的资源类型名称和ID,这个字典只有名称和ID - # 上边字典里"depth": 2的类型才可以查询,"depth": 1的是1级目录,不能查询 - # "七天神像":"2" - # "风神瞳":"5" - - }, - "all_resource_point_list": [ - # 这个列表保存所有资源点的数据 - # { - # "id": 2740, - # "label_id": 68, - # "x_pos": -1789, - # "y_pos": 2628, - # "author_name": "✟紫灵心✟", - # "ctime": "2020-10-29 10:41:21", - # "display_state": 1 - # }, - ], - "date": "" # 记录上次更新"all_resource_point_list"的日期 -} - - -def up_icon_image(sublist): - # 检查是否有图标,没有图标下载保存到本地 - id = sublist["id"] - icon_url = sublist["icon"] - - icon_path = os.path.join(FILE_PATH, "icon", f"{id}.png") - - if not os.path.exists(icon_path): - schedule = request.Request(icon_url) - schedule.add_header('User-Agent', header) - with request.urlopen(schedule) as f: - icon = Image.open(f) - icon = icon.resize((150, 150)) - - box_alpha = Image.open(os.path.join(FILE_PATH, "icon", "box_alpha.png")).getchannel("A") - box = Image.open(os.path.join(FILE_PATH, "icon", "box.png")) - - try: - icon_alpha = icon.getchannel("A") - icon_alpha = ImageMath.eval("convert(a*b/256, 'L')", a=icon_alpha, b=box_alpha) - except ValueError: - # 米游社的图有时候会没有alpha导致报错,这时候直接使用box_alpha当做alpha就行 - icon_alpha = box_alpha - - icon2 = Image.new("RGBA", (150, 150), "#00000000") - icon2.paste(icon, (0, -10)) - - bg = Image.new("RGBA", (150, 150), "#00000000") - bg.paste(icon2, mask=icon_alpha) - bg.paste(box, mask=box) - - with open(icon_path, "wb") as icon_file: - bg.save(icon_file) - - -def up_label_and_point_list(): - # 更新label列表和资源点列表 - - schedule = request.Request(LABEL_URL) - schedule.add_header('User-Agent', header) - with request.urlopen(schedule, timeout=5) as f: - if f.code != 200: # 检查返回的状态码是否是200 - raise ValueError(f"资源标签列表初始化失败,错误代码{f.code}") - label_data = json.loads(f.read().decode('utf-8')) - - for label in label_data["data"]["tree"]: - data["all_resource_type"][str(label["id"])] = label - - for sublist in label["children"]: - data["all_resource_type"][str(sublist["id"])] = sublist - data["can_query_type_list"][sublist["name"]] = str(sublist["id"]) - up_icon_image(sublist) - - label["children"] = [] - - schedule = request.Request(POINT_LIST_URL) - schedule.add_header('User-Agent', header) - with request.urlopen(schedule) as f: - if f.code != 200: # 检查返回的状态码是否是200 - raise ValueError(f"资源点列表初始化失败,错误代码{f.code}") - test = json.loads(f.read().decode('utf-8')) - data["all_resource_point_list"] = test["data"]["point_list"] - - data["date"] = time.strftime("%d") - - -# def load_resource_type_id(): -# with open(os.path.join(FILE_PATH,'resource_type_id.json'), 'r', encoding='UTF-8') as f: -# json_data = json.load(f) -# for id in json_data.keys(): -# data["all_resource_type"][id] = json_data[id] -# if json_data[id]["depth"] != 1: -# data["can_query_type_list"][json_data[id]["name"]] = id - - -# 初始化 -# load_resource_type_id() -up_label_and_point_list() - - -class Resource_map(object): - - def __init__(self, resource_name): - self.resource_id = str(data["can_query_type_list"][resource_name]) - - # 地图要要裁切的左上角和右下角坐标 - # 这里初始化为地图的大小 - self.x_start = MAP_SIZE[0] - self.y_start = MAP_SIZE[1] - self.x_end = 0 - self.y_end = 0 - - self.map_image = MAP_IMAGE.copy() - - self.resource_icon = Image.open(self.get_icon_path()) - self.resource_icon = self.resource_icon.resize((int(150 * zoom), int(150 * zoom))) - - self.resource_xy_list = self.get_resource_point_list() - - def get_icon_path(self): - # 检查有没有图标,有返回正确图标,没有返回默认图标 - icon_path = os.path.join(FILE_PATH, "icon", f"{self.resource_id}.png") - - if os.path.exists(icon_path): - return icon_path - else: - return os.path.join(FILE_PATH, "icon", "0.png") - - def get_resource_point_list(self): - temp_list = [] - for resource_point in data["all_resource_point_list"]: - if str(resource_point["label_id"]) == self.resource_id: - # 获取xy坐标,然后加上中心点的坐标完成坐标转换 - x = resource_point["x_pos"] + CENTER[0] - y = resource_point["y_pos"] + CENTER[1] - temp_list.append((int(x), int(y))) - return temp_list - - def paste(self): - for x, y in self.resource_xy_list: - # 把资源图片贴到地图上 - self.map_image.paste(self.resource_icon, (x + resource_icon_offset[0], y + resource_icon_offset[1]), - self.resource_icon) - - # 找出4个方向最远的坐标,用于后边裁切 - self.x_start = min(x, self.x_start) - self.y_start = min(y, self.y_start) - self.x_end = max(x, self.x_end) - self.y_end = max(y, self.y_end) - - def crop(self): - - # 先把4个方向扩展150像素防止把资源图标裁掉 - self.x_start -= 150 - self.y_start -= 150 - self.x_end += 150 - self.y_end += 150 - - # 如果图片裁切的太小会看不出资源的位置在哪,检查图片裁切的长和宽看够不够1000,不到1000的按1000裁切 - if (self.x_end - self.x_start) < 1000: - center = int((self.x_end + self.x_start) / 2) - self.x_start = center - 500 - self.x_end = center + 500 - if (self.y_end - self.y_start) < 1000: - center = int((self.y_end + self.y_start) / 2) - self.y_start = center - 500 - self.y_end = center + 500 - - self.map_image = self.map_image.crop((self.x_start, self.y_start, self.x_end, self.y_end)) - - def get_cq_cod(self): - - if not self.resource_xy_list: - return "没有这个资源的信息" - - self.paste() - - self.crop() - - bio = BytesIO() - self.map_image.save(bio, format='JPEG') - base64_str = 'base64://' + base64.b64encode(bio.getvalue()).decode() - - return image(b64=base64_str) - - def get_resource_count(self): - return len(self.resource_xy_list) - - -def get_resource_map_mes(name): - if data["date"] != time.strftime("%d"): - up_label_and_point_list() - - if not (name in data["can_query_type_list"]): - return f"没有 {name} 这种资源。\n发送 原神资源列表 查看所有资源名称" - - map = Resource_map(name) - count = map.get_resource_count() - - if not count: - return f"没有找到 {name} 资源的位置,可能米游社wiki还没更新。" - - mes = f"资源 {name} 的位置如下\n" - mes += map.get_cq_cod() - - mes += f"\n\n※ {name} 一共找到 {count} 个位置点\n※ 数据来源于米游社wiki" - return mes - - -def get_resource_list_mes(): - temp = {} - - for id in data["all_resource_type"].keys(): - # 先找1级目录 - if data["all_resource_type"][id]["depth"] == 1: - temp[id] = [] - - for id in data["all_resource_type"].keys(): - # 再找2级目录 - if data["all_resource_type"][id]["depth"] == 2: - temp[str(data["all_resource_type"][id]["parent_id"])].append(id) - - mes = "当前资源列表如下:\n" - - for resource_type_id in temp.keys(): - - if resource_type_id in ["1", "12", "50", "51", "95", "131"]: - # 在游戏里能查到的数据这里就不列举了,不然消息太长了 - continue - - mes += f"{data['all_resource_type'][resource_type_id]['name']}:" - for resource_id in temp[resource_type_id]: - mes += f"{data['all_resource_type'][resource_id]['name']}," - mes += "\n" - - return mes diff --git a/plugins/genshin/query_resource_points/resource_type_id.json b/plugins/genshin/query_resource_points/resource_type_id.json deleted file mode 100644 index 9459f34b..00000000 --- a/plugins/genshin/query_resource_points/resource_type_id.json +++ /dev/null @@ -1,926 +0,0 @@ -{ - "1": { - "id": 1, - "name": "传送点", - "icon": "", - "parent_id": 0, - "depth": 1, - "node_type": 1, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "2": { - "id": 2, - "name": "七天神像", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/c59585d1fabc9c22ad3fcf94e1622aa8_357413506633071859.png", - "parent_id": 1, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "3": { - "id": 3, - "name": "传送锚点", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/0cc42d15134cbb724304050fd0bbcaac_8799482478853097434.png", - "parent_id": 1, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "4": { - "id": 4, - "name": "神瞳", - "icon": "", - "parent_id": 0, - "depth": 1, - "node_type": 1, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "5": { - "id": 5, - "name": "风神瞳", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/4b568dcdea1c699456464c611ce87e4f_3484482126589511603.png", - "parent_id": 4, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "6": { - "id": 6, - "name": "岩神瞳", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/f4409292be83f81d0c41c350a91ebac1_355618004292502793.png", - "parent_id": 4, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "7": { - "id": 7, - "name": "地灵龛", - "icon": "", - "parent_id": 0, - "depth": 1, - "node_type": 1, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "8": { - "id": 8, - "name": "蒙德地灵龛", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/a9f458cf7ba149ec659aabb581050a0b_3339433578214432669.png", - "parent_id": 7, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "9": { - "id": 9, - "name": "璃月地灵龛", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/a9f458cf7ba149ec659aabb581050a0b_3479171218459475297.png", - "parent_id": 7, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "10": { - "id": 10, - "name": "区域特产", - "icon": "", - "parent_id": 0, - "depth": 1, - "node_type": 1, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "29": { - "id": 29, - "name": "落落莓", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/11e1861e2b94d1b1e132d61c0f7c3948_5882174105995719914.png", - "parent_id": 10, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "30": { - "id": 30, - "name": "绝云椒椒", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/3184e356629e8b071a878063d1c0df94_5172487424247849295.png", - "parent_id": 10, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "31": { - "id": 31, - "name": "嘟嘟莲", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/07a2252a60301893294ef377e563f0e7_7014418407781853378.png", - "parent_id": 10, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "32": { - "id": 32, - "name": "清心", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/0de9385a957ef0cb981a5ed6a6984f57_7797138076139828289.png", - "parent_id": 10, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "33": { - "id": 33, - "name": "小灯草", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/348fe1164e9330226b225c011aea4d5a_2068903308538485227.png", - "parent_id": 10, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "34": { - "id": 34, - "name": "琉璃袋", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/77dc4532fe938a24c4cc714d77d48b0d_6612669651078791213.png", - "parent_id": 10, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "35": { - "id": 35, - "name": "塞西莉亚花", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/e55cfc43f5e483362e9ddf433653d326_9031812646608361297.png", - "parent_id": 10, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "36": { - "id": 36, - "name": "霓裳花", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/e22d205c11b39b9b6984a4ec8adefeb2_2210397206297609865.png", - "parent_id": 10, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "37": { - "id": 37, - "name": "蒲公英籽", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/a348a4302f58f499bdf89025d2cb2cdb_2244957478004520779.png", - "parent_id": 10, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "38": { - "id": 38, - "name": "琉璃百合", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/dfe6d92e18060cd724ebadd73ba084c6_7141991283452930467.png", - "parent_id": 10, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "39": { - "id": 39, - "name": "慕风蘑菇", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/d0f4c83add3dc326ffc92b5fedb6f82c_3118392491847470850.png", - "parent_id": 10, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "40": { - "id": 40, - "name": "石珀", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/5789d9dc9c8840f21f9afc2437e9026e_8487232206600716291.png", - "parent_id": 10, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "41": { - "id": 41, - "name": "钩钩果", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/7dedeee543b94525f0812a18eb09b7d7_4938366361261655916.png", - "parent_id": 10, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "42": { - "id": 42, - "name": "夜泊石", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/51adcbda83a2f2b4422db9ad4908245b_7898256673375056193.png", - "parent_id": 10, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "43": { - "id": 43, - "name": "风车菊", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/387684f5c9a891135e05f95192b6dc21_2171784899125537458.png", - "parent_id": 10, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "11": { - "id": 11, - "name": "矿物", - "icon": "", - "parent_id": 0, - "depth": 1, - "node_type": 1, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "15": { - "id": 15, - "name": "白铁块", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/4d0e329b0458a918d376bbbabd4415cd_9079005216548585535.png", - "parent_id": 11, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "16": { - "id": 16, - "name": "水晶块", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/ceede1f6fa9a3e53986b5ac63e2aacb9_3251440935681461856.png", - "parent_id": 11, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "12": { - "id": 12, - "name": "怪物(精英)", - "icon": "", - "parent_id": 0, - "depth": 1, - "node_type": 1, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "19": { - "id": 19, - "name": "火斧丘丘暴徒", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/cef1444b97c8f49cd8cd8aa10e5448ae_1229715974301029440.png", - "parent_id": 12, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "20": { - "id": 20, - "name": "木盾丘丘暴徒", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/cef1444b97c8f49cd8cd8aa10e5448ae_2049522587981126653.png", - "parent_id": 12, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "21": { - "id": 21, - "name": "岩盾丘丘暴徒", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/cef1444b97c8f49cd8cd8aa10e5448ae_4383986804076887911.png", - "parent_id": 12, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "22": { - "id": 22, - "name": "火深渊法师", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/3c287ea61919d856723ba802fd91677f_2936850964636137610.png", - "parent_id": 12, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "23": { - "id": 23, - "name": "水深渊法师", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/5d59b593551bb62506096c76bd55ab2a_5561999899365928315.png", - "parent_id": 12, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "24": { - "id": 24, - "name": "冰深渊法师", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/4b9b07114f30df8715f41835d3215add_6327856690043584281.png", - "parent_id": 12, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "25": { - "id": 25, - "name": "愚人众 债务处理人", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/359e5697e4609a7f34714bfa65cce97e_7545179401283346969.png", - "parent_id": 12, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "26": { - "id": 26, - "name": "愚人众 雷萤术士", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/a73112218e1329ae4728a096554258d7_4082505538504798279.png", - "parent_id": 12, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "27": { - "id": 27, - "name": "遗迹守卫", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/86ddf140b786c6a2a73b038e341403a7_6217455819326456307.png", - "parent_id": 12, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "28": { - "id": 28, - "name": "遗迹猎者", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/99ce18638304f8169918c85436d0585c_5415189466598569723.png", - "parent_id": 12, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "47": { - "id": 47, - "name": "冰霜骗骗花", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/14/75276545/54904a37ab2165e5b8ad91c7ee805061_2703681786862158841.png", - "parent_id": 12, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "48": { - "id": 48, - "name": "炽热骗骗花", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/14/75276545/1848c68a09d54637721529abb35b22a1_7882961499456527312.png", - "parent_id": 12, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "49": { - "id": 49, - "name": "幼岩龙蜥", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/14/75276545/83d1ef1dbb3b6d489c0b150886597cbc_5647365818975751099.png", - "parent_id": 12, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "53": { - "id": 53, - "name": "丘丘岩盔王", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/17/75276545/a6e1a33b8f4bd4c8a091f69ead200948_2480904266424771100.png", - "parent_id": 12, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "54": { - "id": 54, - "name": "愚人众先遣队", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/17/75276545/8dd741d0f58dc6abef2f9ee6d278a062_7759801496426769012.png", - "parent_id": 12, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "13": { - "id": 13, - "name": "宝箱", - "icon": "", - "parent_id": 0, - "depth": 1, - "node_type": 1, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "17": { - "id": 17, - "name": "普通的宝箱", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/35cf41aad7620ce6d5dc516defb967f7_7806440070871726330.png", - "parent_id": 13, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "44": { - "id": 44, - "name": "精致的宝箱", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/14/75276545/35cf41aad7620ce6d5dc516defb967f7_6214340810257945197.png", - "parent_id": 13, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "45": { - "id": 45, - "name": "珍贵的宝箱", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/14/75276545/44a7de58782f36f15bec044c1069da76_7523256410581248233.png", - "parent_id": 13, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "46": { - "id": 46, - "name": "华丽的宝箱", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/14/75276545/35cf41aad7620ce6d5dc516defb967f7_3987566332689612662.png", - "parent_id": 13, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "14": { - "id": 14, - "name": "解谜", - "icon": "", - "parent_id": 0, - "depth": 1, - "node_type": 1, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "18": { - "id": 18, - "name": "指引仙灵", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/08/75276545/8de3558f991ac422463712dd095278b3_109842752079072307.png", - "parent_id": 14, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "64": { - "id": 64, - "name": "限时挑战", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/21/75795471/a6978cb8965e81de4a25accbf6c236ce_6189233402996409228.png", - "parent_id": 14, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "65": { - "id": 65, - "name": "风车机关", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/10/21/75795471/de87958fa1e78efcc84da49aad61dede_7547151797455251961.jpg", - "parent_id": 14, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "66": { - "id": 66, - "name": "漂浮的风史莱姆", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/10/21/75795471/de87958fa1e78efcc84da49aad61dede_6780166156178323412.jpg", - "parent_id": 14, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "67": { - "id": 67, - "name": "压力机关", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/10/21/75795471/de87958fa1e78efcc84da49aad61dede_5932273944571249310.jpg", - "parent_id": 14, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "68": { - "id": 68, - "name": "蓬蓬果", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/10/21/75795471/de87958fa1e78efcc84da49aad61dede_7627546850715675857.jpg", - "parent_id": 14, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "69": { - "id": 69, - "name": "挖掘宝箱", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/10/21/75795471/de87958fa1e78efcc84da49aad61dede_200949033774003499.jpg", - "parent_id": 14, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "70": { - "id": 70, - "name": "元素方碑", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/10/21/75795471/de87958fa1e78efcc84da49aad61dede_8520221369291334139.jpg", - "parent_id": 14, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "71": { - "id": 71, - "name": "火炬机关", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/10/21/75795471/de87958fa1e78efcc84da49aad61dede_1061118532437351431.jpg", - "parent_id": 14, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "72": { - "id": 72, - "name": "巨型碎石", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/10/21/75795471/de87958fa1e78efcc84da49aad61dede_6449674692302465374.jpg", - "parent_id": 14, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "73": { - "id": 73, - "name": "小石堆", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/10/21/75795471/de87958fa1e78efcc84da49aad61dede_7798666829547657712.jpg", - "parent_id": 14, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "74": { - "id": 74, - "name": "拔植物", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/10/21/75795471/de87958fa1e78efcc84da49aad61dede_3891992353724563278.jpg", - "parent_id": 14, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "75": { - "id": 75, - "name": "被束缚的宝箱", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/10/21/75795471/de87958fa1e78efcc84da49aad61dede_7069442788377617628.jpg", - "parent_id": 14, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "76": { - "id": 76, - "name": "岩种子", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/10/21/75795471/de87958fa1e78efcc84da49aad61dede_6714446188416963945.jpg", - "parent_id": 14, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "77": { - "id": 77, - "name": "微解谜", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/10/21/75795471/de87958fa1e78efcc84da49aad61dede_3053004782269703586.jpg", - "parent_id": 14, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "50": { - "id": 50, - "name": "怪物(普通)", - "icon": "", - "parent_id": 0, - "depth": 1, - "node_type": 1, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "55": { - "id": 55, - "name": "丘丘人", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/17/75276545/74c2350936386d12f84e4244b8bd9750_8061221501486024583.png", - "parent_id": 50, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "56": { - "id": 56, - "name": "射手丘丘人", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/17/75276545/74c2350936386d12f84e4244b8bd9750_8668908145618002848.png", - "parent_id": 50, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "57": { - "id": 57, - "name": "丘丘萨满", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/17/75276545/fbd2f8a868f6c3a6f587d57d655f40c9_1156685569894627424.png", - "parent_id": 50, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "58": { - "id": 58, - "name": "盗宝团", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/17/75276545/a9ecb7952e877dfd7c1dfae5132c7181_242314377398779361.png", - "parent_id": 50, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "59": { - "id": 59, - "name": "史莱姆", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/17/75276545/de444c63df86b407045c0cca2d9c24b2_761844897909742071.png", - "parent_id": 50, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "51": { - "id": 51, - "name": "世界任务", - "icon": "", - "parent_id": 0, - "depth": 1, - "node_type": 1, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "52": { - "id": 52, - "name": "世界任务", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/16/75795471/c7263000d1f1ec150eddd27fca4d8630_2386396225561541114.png", - "parent_id": 51, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "60": { - "id": 60, - "name": "材料", - "icon": "", - "parent_id": 0, - "depth": 1, - "node_type": 1, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "61": { - "id": 61, - "name": "冰雾花花朵", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/17/75276545/cca41572bb14d20c094ce9af77eefda9_2844359998862121652.png", - "parent_id": 60, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "62": { - "id": 62, - "name": "烈焰花花蕊", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/17/75276545/82a7a8327bfa630eb5e52695a2b456e9_4760074611076337816.png", - "parent_id": 60, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - }, - "63": { - "id": 63, - "name": "电气水晶", - "icon": "https://uploadstatic.mihoyo.com/ys-obc/2020/09/17/75276545/aab9020763a7bee1fb532b7117b21fd1_5874466862813696108.png", - "parent_id": 60, - "depth": 2, - "node_type": 2, - "jump_type": 0, - "jump_target_id": 0, - "display_priority": 0, - "children": [] - } -} \ No newline at end of file diff --git a/plugins/group_handle/__init__.py b/plugins/group_handle/__init__.py deleted file mode 100644 index 52ca7f4a..00000000 --- a/plugins/group_handle/__init__.py +++ /dev/null @@ -1,125 +0,0 @@ -from nonebot import on_notice, on_request -from configs.path_config import IMAGE_PATH, DATA_PATH -from util.init_result import image -import os -import random -from models.group_member_info import GroupInfoUser -from datetime import datetime -from services.log import logger -from models.group_remind import GroupRemind -from nonebot.adapters.cqhttp import Bot, GroupIncreaseNoticeEvent, GroupDecreaseNoticeEvent, GroupRequestEvent -from nonebot.adapters.cqhttp.exception import ActionFailed -from pathlib import Path -from nonebot import require -try: - import ujson as json -except ModuleNotFoundError: - import json - - -export = require("admin_bot_manage") - -# 群员增加处理 -group_increase_handle = on_notice(priority=5) -# 群员减少处理 -group_decrease_handle = on_notice(priority=5) -# (群管理)加群同意请求 -add_group = on_request(priority=5) - - -@group_increase_handle.handle() -async def _(bot: Bot, event: GroupIncreaseNoticeEvent, state: dict): - if event.user_id == int(bot.self_id): - await export.update_member_info(event.group_id) - else: - join_time = datetime.now() - user_info = await bot.get_group_member_info(group_id=event.group_id, user_id=event.user_id) - if await GroupInfoUser.insert( - user_info['user_id'], - user_info['group_id'], - user_info['nickname'], - join_time, - ): - logger.info(f"用户{user_info['user_id']} 所属{user_info['group_id']} 更新成功") - else: - logger.info(f"用户{user_info['user_id']} 所属{user_info['group_id']} 更新失败") - if await GroupRemind.get_status(event.group_id, 'hy'): - msg = '' - img = '' - at_flag = False - custom_welcome_msg_json = Path() / "data" / "custom_welcome_msg" / "custom_welcome_msg.json" - if custom_welcome_msg_json.exists(): - data = json.load(open(custom_welcome_msg_json, 'r')) - if data.get(str(event.group_id)): - msg = data[str(event.group_id)] - if msg.find('[at]') != -1: - msg = msg.replace('[at]', '') - at_flag = True - if os.path.exists(DATA_PATH + f'custom_welcome_msg/{event.group_id}.jpg'): - img = image(abspath=DATA_PATH + f'custom_welcome_msg/{event.group_id}.jpg') - if msg or img: - await group_increase_handle.send("\n" + msg + img, at_sender=at_flag) - else: - await group_increase_handle.send( - '新人快跑啊!!本群现状↓(快使用自定义!)' + image(random.choice(os.listdir(IMAGE_PATH + "qxz/")), "qxz")) - - -@group_decrease_handle.handle() -async def _(bot: Bot, event: GroupDecreaseNoticeEvent, state: dict): - # 真寻被踢出群 - if event.sub_type == 'kick_me': - group_id = event.group_id - operator_id = event.operator_id - try: - operator_name = (await GroupInfoUser.select_member_info(event.operator_id, event.group_id)).user_name - except AttributeError: - operator_name = 'None' - coffee = int(list(bot.config.superusers)[0]) - await bot.send_private_msg( - user_id=coffee, - message=f'报告..\n' - f'我被 {operator_name}({operator_id})\n' - f'踢出了 {group_id}') - return - try: - user_name = (await GroupInfoUser.select_member_info(event.user_id, event.group_id)).user_name - except AttributeError: - user_name = str(event.user_id) - rst = '' - if event.sub_type == 'leave': - rst = f'{user_name}离开了我们...' - if event.sub_type == 'kick': - try: - operator_name = (await GroupInfoUser.select_member_info(event.operator_id, event.group_id)).user_name - except AttributeError: - operator_name = event.operator_id - rst = f'{user_name} 被 {operator_name} 送走了.' - try: - await group_decrease_handle.send(f"{rst}") - except ActionFailed: - return - if await GroupInfoUser.delete_member_info(event.user_id, event.group_id): - logger.info(f"用户{user_name}, qq={event.user_id} 所属{event.group_id} 删除成功") - else: - logger.info(f"用户{user_name}, qq={event.user_id} 所属{event.group_id} 删除失败") - - -@add_group.handle() -async def _(bot: Bot, event: GroupRequestEvent, state: dict): - pass - # user_info = await bot._get_vip_info(user_id=event.user_id) - # if user_info['level'] > 16: - # bot.set - - - - - - - - - - - - - diff --git a/plugins/group_handle/__pycache__/__init__.cpython-38.pyc b/plugins/group_handle/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 052dcad8..00000000 Binary files a/plugins/group_handle/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/group_handle/__pycache__/__init__.cpython-39.pyc b/plugins/group_handle/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 18c53520..00000000 Binary files a/plugins/group_handle/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/group_welcome_msg.py b/plugins/group_welcome_msg.py deleted file mode 100644 index 0b5bc0b9..00000000 --- a/plugins/group_welcome_msg.py +++ /dev/null @@ -1,40 +0,0 @@ -from nonebot import on_command -from nonebot.typing import T_State -from nonebot.adapters.cqhttp import Bot, GroupMessageEvent -from nonebot.adapters.cqhttp.permission import GROUP -from configs.path_config import DATA_PATH -from util.init_result import image -import os -from pathlib import Path -try: - import ujson as json -except ModuleNotFoundError: - import json - -view_custom_welcome = on_command('群欢迎消息', aliases={'查看群欢迎消息', '查看当前群欢迎消息'}, permission=GROUP, priority=5, block=True) - - -@view_custom_welcome.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - img = '' - msg = '' - if os.path.exists(DATA_PATH + f'custom_welcome_msg/{event.group_id}.jpg'): - img = image(abspath=DATA_PATH + f'custom_welcome_msg/{event.group_id}.jpg') - custom_welcome_msg_json = Path() / "data" / "custom_welcome_msg" / "custom_welcome_msg.json" - if custom_welcome_msg_json.exists(): - data = json.load(open(custom_welcome_msg_json, 'r')) - if data.get(str(event.group_id)): - msg = data[str(event.group_id)] - if msg.find('[at]') != -1: - msg = msg.replace('[at]', '') - if img or msg: - await view_custom_welcome.finish(msg + img, at_sender=True) - - - - - - - - - diff --git a/plugins/help/__init__.py b/plugins/help/__init__.py deleted file mode 100644 index 0c1e3ee8..00000000 --- a/plugins/help/__init__.py +++ /dev/null @@ -1,35 +0,0 @@ -from nonebot import on_command -from nonebot.adapters.cqhttp import Bot, GroupMessageEvent, PrivateMessageEvent -from nonebot.typing import T_State -from nonebot.rule import to_me -from configs.path_config import DATA_PATH -from util.init_result import image -import os -from .data_source import create_help_img, create_group_help_img -from nonebot import require - -export = require("nonebot_plugin_manager") - -__plugin_name__ = '帮助' - - -if not os.path.exists(DATA_PATH + 'group_help/'): - os.mkdir(DATA_PATH + 'group_help/') -create_help_img() -for file in os.listdir(DATA_PATH + 'group_help/'): - os.remove(DATA_PATH + 'group_help/' + file) - -_help = on_command("功能", rule=to_me(), aliases={"帮助", 'help'}, priority=1, block=True) - - -@_help.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - if not os.path.exists(DATA_PATH + f'group_help/{event.group_id}.png'): - create_group_help_img(event.group_id) - await _help.finish(image(abspath=DATA_PATH + f'group_help/{event.group_id}.png')) - - -@_help.handle() -async def _(bot: Bot, event: PrivateMessageEvent, state: T_State): - await _help.finish(image('help.png')) - diff --git a/plugins/help/__pycache__/__init__.cpython-38.pyc b/plugins/help/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 5799dfe6..00000000 Binary files a/plugins/help/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/help/__pycache__/__init__.cpython-39.pyc b/plugins/help/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 960f0cb7..00000000 Binary files a/plugins/help/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/help/__pycache__/config.cpython-38.pyc b/plugins/help/__pycache__/config.cpython-38.pyc deleted file mode 100644 index 8549f4cf..00000000 Binary files a/plugins/help/__pycache__/config.cpython-38.pyc and /dev/null differ diff --git a/plugins/help/__pycache__/config.cpython-39.pyc b/plugins/help/__pycache__/config.cpython-39.pyc deleted file mode 100644 index e6e147c1..00000000 Binary files a/plugins/help/__pycache__/config.cpython-39.pyc and /dev/null differ diff --git a/plugins/help/__pycache__/data_source.cpython-38.pyc b/plugins/help/__pycache__/data_source.cpython-38.pyc deleted file mode 100644 index 07934ed1..00000000 Binary files a/plugins/help/__pycache__/data_source.cpython-38.pyc and /dev/null differ diff --git a/plugins/help/__pycache__/data_source.cpython-39.pyc b/plugins/help/__pycache__/data_source.cpython-39.pyc deleted file mode 100644 index 31015e7c..00000000 Binary files a/plugins/help/__pycache__/data_source.cpython-39.pyc and /dev/null differ diff --git a/plugins/help/config.py b/plugins/help/config.py deleted file mode 100644 index 5a57e26d..00000000 --- a/plugins/help/config.py +++ /dev/null @@ -1,52 +0,0 @@ - -# 实用 -utility_help = { - 'update_pic': '一些对图片的操作 --> 指令:操作图片/图片/修改图片(包含 10 种图片操作)', - 'search_buff_skin_price': 'BUFF皮肤底价查询 --> 指令:查询皮肤(代理ip不得劲)', - 'weather': '天气查询 --> 指令:xx天气', - 'yiqing': '实时疫情数据 --> 指令:疫情查询/疫情/查询疫情', - 'bt': 'bt(磁力搜索){仅支持私聊,懂的都懂} --> 指令:bt', - 'reimu': '老司机必备!{仅支持私聊,懂的都懂}-> 指令:上车', - 'what_anime': '靠图识番 --> 指令:识番', - 'nonebot_plugin_picsearcher': '以图搜图 --> 指令:识图/这是什么/上一张图是什么', - 'search_anime': '找不到想看的动漫吗? --> 指令:搜番', - 'songpicker2': '来一首歌听听? --> 指令:点歌', - 'epic': 'epic速速白嫖 --> 指令:epic', - 'pixiv_r': 'P站排行榜直接冲 --> 指令:p站排行(可含参数)', - 'pixiv_s': 'P站的图随便搜搜 --> 指令:搜图(可含参数)', - 'translate': '出国旅游助手(狗头) --> 指令:英翻/翻英/日翻/翻日/韩翻/翻韩' -} -# 娱乐 -entertainment_help = { - 'sign_in': '签到(影响色图几率和开箱次数) --> 指令:签到/我的签到/好感度排行', - 'send_img': '发送图片 --> 指令:美图/萝莉/壁纸', - 'send_setu': '不要小看涩图啊混蛋! --> 指令:色图/n张色图/n张xx色图/查色图/...(请查看 色图 帮助)', - 'white2black_img': '黑白草图 --> 指令:黑白图/黑白草图', - 'coser': '三次元也不戳 --> 指令:coser', - 'jitang': '不喝点什么不舒服 --> 指令:鸡汤/语录', - 'send_dinggong_voice': '骂我(傲娇?) --> 指令:骂老子', - 'poke': '戳一戳发送语音美图萝莉图不美哉?', - 'open_cases': '模拟开箱(戒赌) --> 指令:开箱(N连开箱[N<=30])/我的开箱/群开箱统计/我的金色', - 'luxun': '鲁迅说过 --> 指令:鲁迅说', - 'fake_msg': '构造一个假消息 --> 指令:假消息', - 'shop': '商店系统(初始送100金币) --> 指令:商店/我的金币/购买道具/使用道具', - 'draw_card_p': '换个地方当非酋TvT... --> 指令:方舟一井/方舟N抽(0 指令:原神一井/原神N抽(0 指令:赛马娘一井/赛马娘N抽/赛马娘卡一井/赛马娘卡N抽(0 直接查看 骰子娘帮助!', - 'one_friend': '我有一个朋友想问问... --> 指令:我有一个朋友想问问xxx(内容)', - 'nickname': '区区昵称! --> 指令:以后叫我xx(昵称)/我是谁/取消昵称', - 'almanac': '这是一张正经的黄历 --> 指令:原神黄历', - 'material_remind': '看看原神今天要刷什么 --> 指令:今日素材/天赋材料', - 'qiu_qiu_translation': '这家伙到底在说什么? --> 指令:丘丘翻译/丘丘一下/丘丘语翻译', - 'query_resource_points': '地图资源速速查看 --> 指令:原神资源查询xx/原神资源列表/哪里有xx/xx在哪(xx=资源名称)', -} -# 其他 -other_help = [ - '群内csgo服务器(指定群) --> 指令:服务器/ip(其他群请私聊)', - '查看当前的群欢迎消息 --> 指令:群欢迎消息', - '这是一份正经的自我介绍 --> 指令:自我介绍', - '不得看看自己权力多大? --> 指令:我的权限', - '有人记得你是什么时候加入我们的 --> 指令:我的信息', - '让我看看更新了什么 --> 指令:更新信息' -] diff --git a/plugins/help/data_source.py b/plugins/help/data_source.py deleted file mode 100644 index 0d273f6f..00000000 --- a/plugins/help/data_source.py +++ /dev/null @@ -1,175 +0,0 @@ -from util.img_utils import CreateImg -from configs.path_config import IMAGE_PATH, DATA_PATH -import ujson as json -import os -from .config import * -from nonebot import require - -export = require("nonebot_plugin_manager") - -width = 1200 -e_height = 0 -u_height = 700 -o_height = 1250 -# f_height = - - -def create_help_img(): - if os.path.exists(IMAGE_PATH + 'help.png'): - os.remove(IMAGE_PATH + 'help.png') - h = (100 + len(utility_help) * 24 + len(entertainment_help) * 24 + len(other_help) * 24) * 2 - A = CreateImg(width, h - 200, font_size=24) - e = CreateImg(width, len(entertainment_help) * 42, font_size=24) - rst = '' - i = 0 - for cmd in entertainment_help: - rst += f'{i + 1}.{entertainment_help[cmd]}\n' - i += 1 - e.text((10, 10), '娱乐功能:') - e.text((40, 40), rst) - u = CreateImg(width, len(utility_help) * 40 + 50, font_size=24, color='black') - rst = '' - i = 0 - for cmd in utility_help: - rst += f'{i + 1}.{utility_help[cmd]}\n' - i += 1 - u.text((10, 10), '实用功能:', fill=(255, 255, 255)) - u.text((40, 40), rst, fill=(255, 255, 255)) - o = CreateImg(width, len(other_help) * 40, font_size=24) - rst = '' - i = 0 - for i in range(len(other_help)): - rst += f'{i + 1}.{other_help[i]}\n' - i += 1 - o.text((10, 10), '其他功能:') - o.text((40, 40), rst) - A.paste(e, (0, 0)) - A.paste(u, (0, u_height)) - A.paste(o, (0, o_height)) - A.text((10, h * 0.72), '大部分交互功能可以通过输入‘取消’,‘算了’来取消当前交互\n对我说 “指令名 帮助” 获取对应详细帮助\n' - '可以通过 “滴滴滴- 后接内容” 联系管理员(有趣的想法尽管来吧!<还有Bug和建议>)\n[群管理员请看 管理员帮助(群主与管理员自带 5 级权限)]') - A.text((10, h * 0.79), f"【注】「色图概率:好感度 + 70%\n" - f"\t\t每 3 点好感度 + 1次开箱,初始 20 次\n" - f"\t\t开启/关闭功能只需输入‘开启/关闭 指令名’(每个功能的第一个指令)」\n" - f"\t\t示例:开启签到") - A.save(IMAGE_PATH + 'help.png') - - -def create_group_help_img(group_id: int): - group_id = str(group_id) - try: - with open(DATA_PATH + 'manager/plugin_list.json', 'r', encoding='utf8') as f: - plugin_list = json.load(f) - except (ValueError, FileNotFoundError): - pass - h = (100 + len(utility_help) * 24 + len(entertainment_help) * 24 + len(other_help) * 24) * 2 - A = CreateImg(1200, h - 200, font_size=24) - u = CreateImg(1200, len(utility_help) * 40, font_size=24, color='black') - o = CreateImg(1200, len(other_help) * 40, font_size=24) - e = CreateImg(width, len(entertainment_help) * 42, font_size=24) - rst = '' - i = 1 - # print(plugin_list) - for cmd in entertainment_help.keys(): - # dfg = '_' - # if cmd == 'draw_card_p': - # cmd = 'draw_card' - # dfg = 'p' - # elif cmd == 'draw_card_g': - # cmd = 'draw_card' - # dfg = 'g' - # flag = '√' - # if group_id in plugin_list[cmd]: - # if not plugin_list[cmd][group_id]: - # flag = '×' - # if cmd in ['nickname']: - # flag = '-' - flag, dfg = parse_cmd(cmd, group_id, plugin_list) - if dfg: - cmd = rcmd(dfg) - # if dfg == 'p': - # cmd = 'draw_card_p' - # elif dfg == 'g': - # cmd = 'draw_card_g' - rst += f'【{flag}】{i}.{entertainment_help[cmd]}\n' - i += 1 - e.text((10, 10), '娱乐功能:') - e.text((40, 40), rst) - - rst = '' - i = 1 - for cmd in utility_help.keys(): - # flag = '√' - # if group_id in plugin_list[cmd]: - # if not plugin_list[cmd][group_id]: - # flag = '×' - # if cmd in ['bt', 'reimu']: - # flag = '-' - flag, dfg = parse_cmd(cmd, group_id, plugin_list) - rst += f'【{flag}】{i}.{utility_help[cmd]}\n' - i += 1 - u.text((10, 10), '实用功能:', fill=(255, 255, 255)) - u.text((40, 40), rst, fill=(255, 255, 255)) - - rst = '' - for i in range(len(other_help)): - rst += f'{i + 1}.{other_help[i]}\n' - o.text((10, 10), '其他功能:') - o.text((40, 40), rst) - - A.paste(e, (0, 0)) - A.paste(u, (0, u_height)) - A.paste(o, (0, o_height)) - # A.text((width, 10), f'总开关【{"√" if data["总开关"] else "×"}】') - A.text((10, h * 0.72), '大部分交互功能可以通过输入‘取消’,‘算了’来取消当前交互\n对我说 “指令名 帮助” 获取对应详细帮助\n' - '可以通过 “滴滴滴- 后接内容” 联系管理员(有趣的想法尽管来吧!<还有Bug和建议>)' - '\n[群管理员请看 管理员帮助(群主与管理员自带 5 级权限)]') - A.text((10, h * 0.79), f"【注】「色图概率:好感度 + 70%\n" - f"\t\t每 3 点好感度 + 1次开箱,初始 20 次\n" - f"\t\t开启/关闭功能只需输入‘开启/关闭 指令名’(每个功能的第一个指令)」\n" - f"\t\t示例:开启签到\n" - f"\t\t可以通过管理员开关自动发送消息(早晚安等)\n" - f"\t\t^请查看管理员帮助^") - A.save(DATA_PATH + f'group_help/{group_id}.png') - - -def parse_cmd(cmd, group_id, plugin_list): - flag = '√' - dfg = None - if cmd == 'draw_card_p': - cmd = 'draw_card' - dfg = 'p' - elif cmd == 'draw_card_g': - cmd = 'draw_card' - dfg = 'g' - elif cmd == 'draw_card_h': - cmd = 'draw_card' - dfg = 'h' - elif cmd == 'pixiv_r': - cmd = 'pixiv' - dfg = 'r' - elif cmd == 'pixiv_s': - cmd = 'pixiv' - dfg = 's' - if group_id in plugin_list[cmd]: - if not plugin_list[cmd][group_id]: - flag = '×' - if cmd in ['bt', 'reimu', 'nickname']: - flag = '- ' - return flag, dfg - - -def rcmd(dfg): - if dfg == 'p': - return 'draw_card_p' - if dfg == 'g': - return 'draw_card_g' - if dfg == 'g': - return 'draw_card_h' - if dfg == 'r': - return 'pixiv_r' - if dfg == 's': - return 'pixiv_s' - - - diff --git a/plugins/hook.py b/plugins/hook.py deleted file mode 100644 index 6786284b..00000000 --- a/plugins/hook.py +++ /dev/null @@ -1,152 +0,0 @@ -from nonebot.matcher import Matcher -from nonebot.message import run_preprocessor, IgnoredException -from nonebot.typing import T_State -from nonebot.adapters.cqhttp import Bot, MessageEvent, PrivateMessageEvent, GroupMessageEvent -from configs.config import BAN_RESULT, admin_plugins_auth, MALICIOUS_BAN_TIME, MALICIOUS_CHECK_TIME, MALICIOUS_BAN_COUNT -from models.ban_user import BanUser -from util.utils import is_number, static_flmt, BanCheckLimiter -from util.init_result import at -from services.log import logger -from models.level_user import LevelUser -try: - import ujson as json -except ModuleNotFoundError: - import json - - -# 检查是否被ban -@run_preprocessor -async def _(matcher: Matcher, bot: Bot, event: MessageEvent, state: T_State): - if matcher.type == 'message' and matcher.priority not in [1, 9]: - if await BanUser.isban(event.user_id) and str(event.user_id) not in bot.config.superusers: - time = await BanUser.check_ban_time(event.user_id) - if is_number(time): - time = abs(int(time)) - if time < 60: - time = str(time) + ' 秒' - else: - time = str(int(time / 60)) + ' 分' - else: - time = str(time) + ' 分' - if event.message_type == 'group': - if not static_flmt.check(event.user_id): - raise IgnoredException('用户处于黑名单中') - static_flmt.start_cd(event.user_id) - if matcher.priority != 9: - await bot.send_group_msg(group_id=event.group_id, - message=at(event.user_id) + BAN_RESULT + f' 在..在 {time}后才会理你喔') - else: - if not static_flmt.check(event.user_id): - raise IgnoredException('用户处于黑名单中') - static_flmt.start_cd(event.user_id) - if matcher.priority != 9: - await bot.send_private_msg(user_id=event.user_id, - message=at(event.user_id) + BAN_RESULT + f' 在..在 {time}后才会理你喔') - raise IgnoredException('用户处于黑名单中') - - -_blmt = BanCheckLimiter(MALICIOUS_BAN_TIME, MALICIOUS_BAN_COUNT) - - -# 恶意触发命令检测 -@run_preprocessor -async def _(matcher: Matcher, bot: Bot, event: GroupMessageEvent, state: T_State): - if matcher.type == 'message' and matcher.priority not in [1, 9]: - if state["_prefix"]["raw_command"]: - # print(state["_prefix"]["raw_command"]) - if _blmt.check(f'{event.user_id}{state["_prefix"]["raw_command"]}'): - if await BanUser.ban(event.user_id, 9, MALICIOUS_BAN_TIME * 60): - logger.info(f'USER {event.user_id} 触发了恶意触发检测') - # await update_img.finish('检测到恶意触发命令,您将被封禁 30 分钟', at_sender=True) - if event.message_type == 'group': - if not static_flmt.check(event.user_id): - return - static_flmt.start_cd(event.user_id) - await bot.send_group_msg(group_id=event.group_id, - message=at(event.user_id) + '检测到恶意触发命令,您将被封禁 30 分钟') - else: - if not static_flmt.check(event.user_id): - return - static_flmt.start_cd(event.user_id) - await bot.send_private_msg(user_id=event.user_id, - message=at(event.user_id) + '检测到恶意触发命令,您将被封禁 30 分钟') - raise IgnoredException('检测到恶意触发命令') - _blmt.add(f'{event.user_id}{state["_prefix"]["raw_command"]}') - - -# 权限检测 -@run_preprocessor -async def _(matcher: Matcher, bot: Bot, event: MessageEvent, state: T_State): - if await BanUser.isban(event.user_id): - return - if matcher.module in admin_plugins_auth.keys() and matcher.priority not in [1, 9]: - if event.message_type == 'group': - if not await LevelUser.check_level(event.user_id, event.group_id, admin_plugins_auth[matcher.module]): - await bot.send_group_msg(group_id=event.group_id, - message=f'{at(event.user_id)}你的权限不足喔,该功能需要的权限等级:' - f'{admin_plugins_auth[matcher.module]}') - raise IgnoredException('权限不足') - else: - if not await LevelUser.check_level(event.user_id, 0, admin_plugins_auth[matcher.module]): - await bot.send_private_msg(user_id=event.user_id, - message=f'你的权限不足喔,该功能需要的权限等级:{admin_plugins_auth[matcher.module]}') - raise IgnoredException('权限不足') - - -# 为什么AI会自己和自己聊天 -@run_preprocessor -async def _(matcher: Matcher, bot: Bot, event: PrivateMessageEvent, state: T_State): - if matcher.type == 'message' and event.user_id == int(bot.self_id): - raise IgnoredException('为什么AI会自己和自己聊天') - - -# 有命令就别说话了 -@run_preprocessor -async def _(matcher: Matcher, bot: Bot, event: MessageEvent, state: T_State): - if matcher.type == 'message': - if state["_prefix"]["raw_command"] and matcher.module == 'ai': - raise IgnoredException('有命令就别说话了') - - -# _ulmt = UserExistLimiter() -# -# -# # 是否有命令正在处理 -# @run_preprocessor -# async def _(matcher: Matcher, bot: Bot, event: Event, state: T_State): -# if matcher.module == 'admin_bot_manage': -# return -# if event.user_id == bot.self_id: -# raise IgnoredException('自己和自己聊天?') -# print(state["_prefix"]["raw_command"]) -# print(matcher.type) -# if (event.is_tome() and (state["_prefix"]["raw_command"] and matcher.type == 'message') -# and matcher.module == 'ai') or not static_group_dict[event.group_id]['总开关']: -# raise IgnoredException('Ai给爷爬?') -# # if matcher.module in ['ai']: -# # raise IgnoredException('Ai给爷爬?') -# if matcher.type == 'message' and matcher.priority not in [1, 8, 9]: -# if _ulmt.check(event.user_id): -# if event.message_type == 'group': -# await bot.send_group_msg(group_id=event.group_id, message=at(event.user_id) + '您有命令正在处理,等一哈!') -# else: -# await bot.send_private_msg(user_id=event.user_id, message='您有命令正在处理,等一哈!') -# raise IgnoredException('有命令正在处理') -# _ulmt.set_True(event.user_id) -# -# -# # 结束正在处理的命令 -# @run_postprocessor -# async def _(matcher: Matcher, bot: Bot, event: Event, state: T_State): -# _ulmt.set_False(event.user_id) -# -# -# # 结束正在处理的命令 -# @event_preprocessor -# async def _(bot: Bot, event: Event, state: T_State): -# try: -# _ulmt.set_False(event.user_id) -# except AttributeError: -# pass - - diff --git a/plugins/jitang.py b/plugins/jitang.py deleted file mode 100644 index 3ab1c011..00000000 --- a/plugins/jitang.py +++ /dev/null @@ -1,35 +0,0 @@ -from nonebot import on_command -from util.user_agent import get_user_agent -from bs4 import BeautifulSoup -from services.log import logger -from nonebot.adapters.cqhttp import Bot, Event -from nonebot.typing import T_State -import aiohttp - - -__plugin_name__ = '鸡汤' -__plugin_usage__ = '用法: 要喝一点鸡汤吗?' - - -url = "https://new.toodo.fun/funs/content?type=du" - - -jitang = on_command("鸡汤", aliases={"毒鸡汤"}, priority=5, block=True) - - -@jitang.handle() -async def _(bot: Bot, event: Event, state: T_State): - if str(event.get_message()) in ['帮助']: - await jitang.finish(__plugin_usage__) - try: - async with aiohttp.ClientSession(headers=get_user_agent()) as session: - async with session.get(url, timeout=7) as response: - soup = BeautifulSoup(await response.text(), 'lxml') - result = (soup.find_all('h3', {'class': 'text-center'}))[0].text - await jitang.send(result) - logger.info( - f"(USER {event.user_id}, GROUP {event.group_id if event.message_type != 'private' else 'private'})" - f" 发送鸡汤:" + result) - except Exception as e: - await jitang.send("出错啦!再试一次吧!", at_sender=True) - logger.info(f'鸡汤error e:{e}') diff --git a/plugins/last_chat/__init__.py b/plugins/last_chat/__init__.py deleted file mode 100644 index a41f0166..00000000 --- a/plugins/last_chat/__init__.py +++ /dev/null @@ -1,53 +0,0 @@ -from nonebot import on_message -from nonebot.adapters.cqhttp.permission import GROUP -from nonebot.typing import T_State -from nonebot.adapters.cqhttp import Bot, GroupMessageEvent -import time -from .data_source import cancel_all_notice, save_data, get_data, set_data_value -from services.log import logger - - -__plugin_name__ = '查看群最后聊天时间 [Hidden]' - - -last_chat = on_message(priority=1, block=False, permission=GROUP) - - -@last_chat.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - time_data = await get_data() - set_data_value(event.group_id, time.time()) - if event.group_id in time_data['_group']: - time_data['_group'].remove(event.group_id) - set_data_value('_group', time_data['_group']) - for key in time_data.keys(): - if key not in ['check_time', '_group']: - if key not in time_data['_group']: - if time.time() - time_data[key] > 60 * 60 * 36: - await cancel_all_notice(key) - time_data["_group"].append(key) - set_data_value('_group', time_data['_group']) - logger.info(f'GROUP {event.group_id} 因群内发言时间大于36小时被取消全部通知') - if time.time() - time_data['check_time'] > 60 * 60 * 1: - set_data_value('check_time', time.time()) - save_data() - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/last_chat/__pycache__/__init__.cpython-38.pyc b/plugins/last_chat/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index ed75ce66..00000000 Binary files a/plugins/last_chat/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/last_chat/__pycache__/__init__.cpython-39.pyc b/plugins/last_chat/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 57db412d..00000000 Binary files a/plugins/last_chat/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/last_chat/__pycache__/data_source.cpython-38.pyc b/plugins/last_chat/__pycache__/data_source.cpython-38.pyc deleted file mode 100644 index 64b24a31..00000000 Binary files a/plugins/last_chat/__pycache__/data_source.cpython-38.pyc and /dev/null differ diff --git a/plugins/last_chat/__pycache__/data_source.cpython-39.pyc b/plugins/last_chat/__pycache__/data_source.cpython-39.pyc deleted file mode 100644 index b6d809c2..00000000 Binary files a/plugins/last_chat/__pycache__/data_source.cpython-39.pyc and /dev/null differ diff --git a/plugins/last_chat/data_source.py b/plugins/last_chat/data_source.py deleted file mode 100644 index 14e827a6..00000000 --- a/plugins/last_chat/data_source.py +++ /dev/null @@ -1,74 +0,0 @@ -from configs.path_config import DATA_PATH -from util.utils import get_bot -from models.group_remind import GroupRemind -from datetime import datetime -import time -from services.log import logger -try: - import ujson as json -except ModuleNotFoundError: - import json - - -time_data = {} - - -async def init(): - global time_data - bot = get_bot() - gl = await bot.get_group_list(self_id=bot.self_id) - gl = [g['group_id'] for g in gl] - data = read_data('group_last_chat_time.json') - for g in gl: - if not data.get(g): - time_data[g] = time.time() - if not time_data.get('check_time'): - time_data['check_time'] = time.time() - if not time_data.get('_group'): - time_data['_group'] = [] - save_data() - return time_data - - -def read_data(file_name: str): - try: - with open(DATA_PATH + file_name, 'r', encoding='utf8') as f: - return json.load(f) - except (ValueError, FileNotFoundError): - return {} - - -def save_data(): - with open(DATA_PATH + 'group_last_chat_time.json', 'w') as f: - json.dump(time_data, f, indent=4) - logger.info(f'自动存储 group_last_chat_time.json 时间:{str(datetime.now()).split(".")[0]}') - - -command_list = ['zwa', 'hy', 'kxcz', 'blpar', 'epic', 'pa'] - - -# 取消全部通知 -async def cancel_all_notice(group_id): - group_id = int(group_id) - for command in command_list: - if await GroupRemind.get_status(group_id, command): - await GroupRemind.set_status(group_id, command, False) - logger.info(f'关闭了 {group_id} 群的全部通知') - - -async def get_data(): - global time_data - if not time_data: - time_data = await init() - return time_data - - -def set_data_value(key, value): - global time_data - time_data[key] = value - - - - - - diff --git a/plugins/luxun/__init__.py b/plugins/luxun/__init__.py deleted file mode 100644 index 10ec89b8..00000000 --- a/plugins/luxun/__init__.py +++ /dev/null @@ -1,64 +0,0 @@ -from PIL import ImageFont, ImageDraw, Image -import textwrap -from configs.path_config import IMAGE_PATH, TTF_PATH -from nonebot import on_command -from nonebot.typing import T_State -from nonebot.adapters.cqhttp import Bot, MessageEvent -from util.init_result import image -from services.log import logger -from util.utils import UserExistLimiter, get_message_text -from util.img_utils import pic2b64 - -_ulmt = UserExistLimiter() - - -luxun = on_command("鲁迅说过", aliases={"鲁迅说"}) - - -@luxun.handle() -async def handle(bot: Bot, event: MessageEvent, state: T_State): - if _ulmt.check(event.user_id): - await luxun.finish('你的鲁迅正在说,等会', at_sender=True) - args = get_message_text(event.json()) - if args: - state["content"] = args if args else '烦了,不说了' - - -@luxun.got("content", prompt="你让鲁迅说点啥?") -async def handle_event(bot: Bot, event: MessageEvent, state: T_State): - filename = str(event.user_id) + "_.jpg" - content = state["content"].strip() - if content.startswith(',') or content.startswith(','): - content = content[1:] - _ulmt.set_True(event.user_id) - if len(content) > 20: - _ulmt.set_False(event.user_id) - await luxun.finish("太长了, 鲁迅说不完!", at_sender=True) - else: - if len(content) >= 12: - content = content[:12] + '\n' + content[12:] - img = image(b64=process_pic(content, filename)) - logger.info(f"USER {event.user_id} GROUP " - f"{event.group_id if event.message_type != 'private' else 'private'} 鲁迅说过 {content}") - await luxun.send(img) - _ulmt.set_False(event.user_id) - - -def process_pic(content, filename) -> str: - text = content - para = textwrap.wrap(text, width=15) - MAX_W, MAX_H = 480, 280 - bk_img = Image.open(IMAGE_PATH + "other/luxun.jpg") - font_path = TTF_PATH + "/msyh.ttf" - font = ImageFont.truetype(font_path, 37) - font2 = ImageFont.truetype(font_path, 30) - draw = ImageDraw.Draw(bk_img) - current_h, pad = 300, 10 - for line in para: - w, h = draw.textsize(line, font=font) - draw.text(((MAX_W - w) / 2, current_h), line, font=font) - current_h += h + pad - draw.text((320, 400), "——鲁迅", font=font2, fill=(255, 255, 255)) - return pic2b64(bk_img) - - diff --git a/plugins/luxun/__pycache__/__init__.cpython-38.pyc b/plugins/luxun/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index a35c3560..00000000 Binary files a/plugins/luxun/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/luxun/__pycache__/__init__.cpython-39.pyc b/plugins/luxun/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index d808d7ad..00000000 Binary files a/plugins/luxun/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/move_img/__init__.py b/plugins/move_img/__init__.py deleted file mode 100644 index fd2a9e80..00000000 --- a/plugins/move_img/__init__.py +++ /dev/null @@ -1,84 +0,0 @@ -import os -from services.log import logger -from nonebot import on_command -from nonebot.rule import to_me -from nonebot.typing import T_State -from nonebot.adapters.cqhttp import Bot, MessageEvent -from configs.config import IMAGE_DIR_LIST -from util.utils import is_number, cn2py -from configs.path_config import IMAGE_PATH - - -__plugin_name__ = '移动图片' -__plugin_usage__ = '移动图片帮助:\n\t' \ - '1.查看列表 --> 指令: 移动图片 列表/目录\n\t' \ - '2.移动图片 源 目的 id\n\t\t示例: 移动图片 色图 美图 1234' - - -move_img = on_command('移动图片', priority=5, rule=to_me(), block=True) - - -@move_img.args_parser -async def parse(bot: Bot, event: MessageEvent, state: T_State): - if str(event.get_message()) in ['取消', '算了']: - await move_img.finish("已取消操作..", at_sender=True) - if state["_current_key"] in ['source_path', 'destination_path']: - if str(event.get_message()) not in IMAGE_DIR_LIST: - await move_img.reject("此目录不正确,请重新输入目录!") - state[state["_current_key"]] = str(event.get_message()) - if state["_current_key"] == 'id': - if not is_number(str(event.get_message())): - await move_img.reject("id不正确!请重新输入数字...") - state[state["_current_key"]] = str(event.get_message()) - - -@move_img.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - raw_arg = str(event.get_message()).strip() - if raw_arg: - args = raw_arg.split(" ") - if args[0] in ['帮助']: - await move_img.finish(__plugin_usage__) - if len(args) >= 3 and args[0] in IMAGE_DIR_LIST and args[1] in IMAGE_DIR_LIST and is_number(args[2]): - state['source_path'] = args[0] - state['destination_path'] = args[1] - state['id'] = args[2] - else: - await move_img.finish("参数错误,请重试", at_sender=True) - - -@move_img.got("source_path", prompt="要从哪个图库移出?") -@move_img.got("destination_path", prompt="要移动到哪个图库?") -@move_img.got("id", prompt="要移动的图片id是?") -async def _(bot: Bot, event: MessageEvent, state: T_State): - img_id = state['id'] - source_path = IMAGE_PATH + cn2py(state['source_path']) - destination_path = IMAGE_PATH + cn2py(state['destination_path']) - max_id = len(os.listdir(source_path)) - 1 - des_max_id = len(os.listdir(destination_path)) - if int(img_id) > max_id or int(img_id) < 0: - await move_img.finish(f"Id超过上下限,上限:{max_id}", at_sender=True) - try: - os.rename(source_path + img_id + ".jpg", destination_path + str(des_max_id) + ".jpg") - logger.info(f"移动 {source_path}{img_id}.jpg ---> {destination_path}{des_max_id} 移动成功") - except Exception as e: - logger.warning(f"移动 {source_path}{img_id}.jpg ---> {destination_path}{des_max_id} 移动失败 e:{e}") - await move_img.finish(f"移动图片id:{img_id} 失败了...", at_sender=True) - if max_id > 0: - try: - os.rename(source_path + str(max_id) + ".jpg", source_path + img_id + ".jpg") - logger.info(f"{source_path}{max_id}.jpg 替换 {source_path}{img_id}.jpg 成功") - except Exception as e: - logger.warning(f"{source_path}{max_id}.jpg 替换 {source_path}{img_id}.jpg 失败 e:{e}") - await move_img.finish(f"替换图片id:{max_id} -> {img_id} 失败了...", at_sender=True) - logger.info(f"USER {event.user_id} GROUP {event.group_id if event.message_type != 'private' else 'private'} ->" - f" {source_path} --> {destination_path} (id:{img_id}) 移动图片成功") - await move_img.finish(f"移动图片 id:{img_id} --> id:{des_max_id}成功", at_sender=True) - - - - - - - - diff --git a/plugins/move_img/__pycache__/__init__.cpython-38.pyc b/plugins/move_img/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index b3d09ef1..00000000 Binary files a/plugins/move_img/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/move_img/__pycache__/__init__.cpython-39.pyc b/plugins/move_img/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 94716921..00000000 Binary files a/plugins/move_img/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/mute.py b/plugins/mute.py deleted file mode 100644 index 17544058..00000000 --- a/plugins/mute.py +++ /dev/null @@ -1,129 +0,0 @@ -from nonebot import on_message, on_command -from nonebot.adapters.cqhttp import Bot, GroupMessageEvent -from nonebot.adapters.cqhttp.permission import GROUP -from util.utils import get_message_text, is_number, get_message_imgs, get_local_proxy -from nonebot.typing import T_State -import time -from nonebot.adapters.cqhttp.exception import ActionFailed -from configs.path_config import DATA_PATH, IMAGE_PATH -from util.img_utils import get_img_hash -from services.log import logger -import aiohttp -import aiofiles -from configs.config import MUTE_DEFAULT_COUNT, MUTE_DEFAULT_TIME, MUTE_DEFAULT_DURATION -try: - import ujson as json -except ModuleNotFoundError: - import json - -__plugin_name__ = '刷屏禁言' - - -mute = on_message(priority=1, block=False) -mute_setting = on_command('mute_setting', aliases={'设置检测时间', '设置检测次数', '设置禁言时长', '刷屏检测设置'}, permission=GROUP, block=True) - - -def get_data(): - try: - with open(DATA_PATH + 'group_mute_data.json', 'r', encoding='utf8') as f: - data = json.load(f) - except (ValueError, FileNotFoundError): - data = {} - return data - - -def save_data(): - global mute_data - with open(DATA_PATH + 'group_mute_data.json', 'w', encoding='utf8') as f: - json.dump(mute_data, f, indent=4) - - -async def download_img_and_hash(url, group_id): - async with aiohttp.ClientSession() as session: - async with session.get(url, proxy=get_local_proxy(), timeout=10) as response: - async with aiofiles.open(IMAGE_PATH + f'temp/mute_{group_id}_img.jpg', 'wb') as f: - await f.write(await response.read()) - return str(get_img_hash(IMAGE_PATH + f'temp/mute_{group_id}_img.jpg')) - - -mute_dict = {} -mute_data = get_data() - - -@mute.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - group_id = str(event.group_id) - msg = get_message_text(event.json()) - imgs = get_message_imgs(event.json()) - img_hash = '' - for img in imgs: - img_hash += await download_img_and_hash(img, event.group_id) - msg += img_hash - if not mute_data.get(group_id): - mute_data[group_id] = { - 'count': MUTE_DEFAULT_COUNT, - 'time': MUTE_DEFAULT_TIME, - 'duration': MUTE_DEFAULT_DURATION - } - if not mute_dict.get(event.user_id): - mute_dict[event.user_id] = { - 'time': time.time(), - 'count': 1, - 'msg': msg - } - else: - if state["_prefix"]["raw_command"] or not msg: - return - if msg and msg.find(mute_dict[event.user_id]['msg']) != -1: - mute_dict[event.user_id]['count'] += 1 - else: - mute_dict[event.user_id]['time'] = time.time() - mute_dict[event.user_id]['count'] = 1 - mute_dict[event.user_id]['msg'] = msg - if time.time() - mute_dict[event.user_id]['time'] > mute_data[group_id]['time']: - mute_dict[event.user_id]['time'] = time.time() - mute_dict[event.user_id]['count'] = 1 - if mute_dict[event.user_id]['count'] > mute_data[group_id]['count'] and\ - time.time() - mute_dict[event.user_id]['time'] < mute_data[group_id]['time']: - try: - if mute_data[group_id]['duration'] != 0: - await bot.set_group_ban(group_id=event.group_id, user_id=event.user_id, - duration=mute_data[group_id]['duration']) - await mute.send('检测到恶意刷屏,真寻要把你关进小黑屋!', at_sender=True) - mute_dict[event.user_id]['count'] = 0 - logger.info(f'USER {event.user_id} GROUP {event.group_id} ' - f'检测刷屏 被禁言 {mute_data[group_id]["duration"] / 60} 分钟') - except ActionFailed: - pass - - -@mute_setting.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - group_id = str(event.group_id) - if not mute_data.get(group_id): - mute_data[group_id] = { - 'count': 10, - 'time': 7, - 'duration': 0 - } - msg = get_message_text(event.json()) - if state["_prefix"]["raw_command"] == '刷屏检测设置': - await mute_setting.finish(f'最大次数:{mute_data[group_id]["count"]} 次\n' - f'规定时间:{mute_data[group_id]["time"]} 秒\n' - f'禁言时长:{mute_data[group_id]["duration"] / 60} 分钟\n' - f'【在规定时间内发送相同消息超过最大次数则禁言\n当禁言时长为0时关闭此功能】') - if not is_number(msg): - await mute.finish('设置的参数必须是数字啊!', at_sender=True) - if state["_prefix"]["raw_command"] == '设置检测时间': - mute_data[group_id]['time'] = int(msg) - msg += '秒' - if state["_prefix"]["raw_command"] == '设置检测次数': - mute_data[group_id]['count'] = int(msg) - msg += ' 次' - if state["_prefix"]["raw_command"] == '设置禁言时长': - mute_data[group_id]['duration'] = int(msg) * 60 - msg += ' 分钟' - await mute_setting.send(f'刷屏检测:{state["_prefix"]["raw_command"]}为 {msg}') - logger.info(f'USER {event.user_id} GROUP {group_id} {state["_prefix"]["raw_command"]}:{msg}') - save_data() - diff --git a/plugins/my_info.py b/plugins/my_info.py deleted file mode 100644 index 5e2fa712..00000000 --- a/plugins/my_info.py +++ /dev/null @@ -1,40 +0,0 @@ -from nonebot import on_command -from nonebot.adapters.cqhttp.permission import GROUP -from nonebot.typing import T_State -from nonebot.adapters.cqhttp import Bot, GroupMessageEvent -from models.group_member_info import GroupInfoUser -from datetime import timedelta -from models.level_user import LevelUser - -__plugin_name__ = '更新群组成员列表 [Hidden]' -__plugin_usage__ = ( - '用法:\n' - '更新群员的信息' -) - - -get_my_group_info = on_command("我的信息", permission=GROUP, priority=1, block=True) -my_level = on_command('我的权限', permission=GROUP, priority=5, block=True) - - -@get_my_group_info.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - result = await get_member_info(event.user_id, event.group_id) - await get_my_group_info.finish(result) - - -async def get_member_info(user_qq: int, group_id: int) -> str: - user = await GroupInfoUser.select_member_info(user_qq, group_id) - if user is None: - return "该群员不在列表中,请更新群成员信息" - result = "" - result += "昵称:" + user.user_name + "\n" - result += "加群时间:" + str(user.user_join_time.date() + timedelta(hours=8)) - return result - - -@my_level.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - if (level := await LevelUser.get_user_level(event.user_id, event.group_id)) == -1: - await my_level.finish('您目前没有任何权限了,硬要说的话就是0吧~', at_sender=True) - await my_level.finish(f'您目前的权限等级:{level}', at_sender=True) \ No newline at end of file diff --git a/plugins/nickname.py b/plugins/nickname.py deleted file mode 100644 index 844e9939..00000000 --- a/plugins/nickname.py +++ /dev/null @@ -1,168 +0,0 @@ -from nonebot import on_command -from nonebot.typing import T_State -from nonebot.adapters.cqhttp import Bot, GroupMessageEvent, PrivateMessageEvent -from nonebot.rule import to_me -from util.utils import get_message_text -from models.group_member_info import GroupInfoUser -from models.friend_user import FriendUser -import random -from models.ban_user import BanUser -from services.log import logger - -nickname = on_command('nickname', - aliases={'以后叫我', '以后请叫我', '称呼我', '以后请称呼我', '以后称呼我', '叫我', '请叫我'}, - rule=to_me(), priority=5, block=True) - -my_nickname = on_command('my_name', aliases={'我叫什么', '我是谁', '我的名字'}, rule=to_me(), priority=5, block=True) - - -cancel_nickname = on_command('取消昵称', rule=to_me(), priority=5, block=True) - - -@nickname.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - msg = get_message_text(event.json()) - if not msg: - await nickname.finish('叫你空白?叫你虚空?叫你无名??', at_sender=True) - if len(msg) > 10: - await nickname.finish('昵称可不能超过10个字!', at_sender=True) - if await GroupInfoUser.set_group_member_nickname(event.user_id, event.group_id, msg): - if len(msg) < 5: - if random.random() < 0.5: - msg = "~".join(msg) - await nickname.send(random.choice([ - '好啦好啦,我知道啦,{},以后就这么叫你吧', - '嗯嗯,小真寻记住你的昵称了哦,{}', - '好突然,突然要叫你昵称什么的...{}..', - '小真寻会好好记住的{}的,放心吧', - '好..好.,那窝以后就叫你{}了.' - ]).format(msg)) - logger.info(f'USER {event.user_id} GROUP {event.group_id} 设置群昵称 {msg}') - else: - await nickname.send('设置昵称失败,请更新群组成员信息!', at_sender=True) - logger.warning(f'USER {event.user_id} GROUP {event.group_id} 设置群昵称 {msg} 失败') - - -@nickname.handle() -async def _(bot: Bot, event: PrivateMessageEvent, state: T_State): - msg = get_message_text(event.json()) - if not msg: - await nickname.finish('叫你空白?叫你虚空?叫你无名??', at_sender=True) - if len(msg) > 10: - await nickname.finish('不要超过10个字!', at_sender=True) - if await FriendUser.set_friend_nickname(event.user_id, msg): - await nickname.send(random.choice([ - '好啦好啦,我知道啦,{},以后就这么叫你吧', - '嗯嗯,小真寻记住你的昵称了哦,{}', - '好突然,突然要叫你昵称什么的...{}..', - '小真寻会好好记住的{}的,放心吧', - '好..好.,那窝以后就叫你{}了.' - ]).format(msg)) - logger.info(f'USER {event.user_id} 设置昵称 {msg}') - else: - await nickname.send('设置昵称失败了,明天再来试一试!或联系管理员更新好友!', at_sender=True) - logger.warning(f'USER {event.user_id} 设置昵称 {msg} 失败') - - -@my_nickname.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - try: - nickname = await GroupInfoUser.get_group_member_nickname(event.user_id, event.group_id) - except AttributeError: - nickname = '' - if nickname: - await my_nickname.send(random.choice([ - '我肯定记得你啊,你是{}啊', - '我不会忘记你的,你也不要忘记我!{}', - '哼哼,真寻记忆力可是很好的,{}', - '嗯?你是失忆了嘛...{}..', - '不要小看真寻的记忆力啊!笨蛋{}!QAQ', - '哎?{}..怎么了吗..突然这样问..' - ]).format(nickname)) - else: - try: - nickname = (await GroupInfoUser.select_member_info(event.user_id, event.group_id)).user_name - except AttributeError: - nickname = event.user_id - await my_nickname.finish(random.choice([ - '对不起,我只记得一串神秘代码..{}\n【群管理快更新群组成员信息!】' - ]).format(nickname)) - await my_nickname.send(random.choice([ - '没..没有昵称嘛,{}', - '啊,你是{}啊,我想叫你的昵称!', - '是{}啊,有什么事吗?', - '你是{}?' - ]).format(nickname)) - - -@my_nickname.handle() -async def _(bot: Bot, event: PrivateMessageEvent, state: T_State): - nickname = await FriendUser.get_friend_nickname(event.user_id) - if nickname: - await my_nickname.send(random.choice([ - '我肯定记得你啊,你是{}啊', - '我不会忘记你的,你也不要忘记我!{}', - '哼哼,真寻记忆力可是很好的,{}', - '嗯?你是失忆了嘛...{}..', - '不要小看真寻的记忆力啊!笨蛋{}!QAQ', - '哎?{}..怎么了吗..突然这样问..' - ]).format(nickname)) - else: - nickname = await FriendUser.get_user_name(event.user_id) - if nickname: - await my_nickname.send(random.choice([ - '没..没有昵称嘛,{}', - '啊,你是{}啊,我想叫你的昵称!', - '是{}啊,有什么事吗?', - '你是{}?' - ]).format(nickname)) - else: - nickname = event.user_id - await my_nickname.finish(random.choice([ - '对不起,我只记得一串神秘代码..{}\n【火速联系管理员更新好友列表!】' - ]).format(nickname)) - - -@cancel_nickname.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - nickname = await GroupInfoUser.get_group_member_nickname(event.user_id, event.group_id) - if nickname: - await cancel_nickname.send(random.choice([ - '呜..真寻睡一觉就会忘记的..和梦一样..{}', - '窝知道了..{}..', - '是真寻哪里做的不好嘛..好吧..晚安{}', - '呃,{},下次我绝对绝对绝对不会再忘记你!', - '可..可恶!{}!太可恶了!呜' - ]).format(nickname)) - await GroupInfoUser.set_group_member_nickname(event.user_id, event.group_id, '') - await BanUser.ban(event.user_id, 9, 60) - else: - await cancel_nickname.send('你在做梦吗?你没有昵称啊', at_sender=True) - - -@cancel_nickname.handle() -async def _(bot: Bot, event: PrivateMessageEvent, state: T_State): - nickname = await FriendUser.get_user_name(event.user_id) - if nickname: - await cancel_nickname.send(random.choice([ - '呜..真寻睡一觉就会忘记的..和梦一样..{}', - '窝知道了..{}..', - '是真寻哪里做的不好嘛..好吧..晚安{}', - '呃,{},下次我绝对绝对绝对不会再忘记你!', - '可..可恶!{}!太可恶了!呜' - ]).format(nickname)) - await FriendUser.get_user_name(event.user_id) - await BanUser.ban(event.user_id, 9, 60) - else: - await cancel_nickname.send('你在做梦吗?你没有昵称啊', at_sender=True) - - - - - - - - - - - diff --git a/plugins/nonebot_plugin_cocdicer/__init__.py b/plugins/nonebot_plugin_cocdicer/__init__.py deleted file mode 100644 index 5dae4b6f..00000000 --- a/plugins/nonebot_plugin_cocdicer/__init__.py +++ /dev/null @@ -1,72 +0,0 @@ -from .data_source import rd, help_message, st, en -from .madness import ti, li -from .create import Investigator -from .san_check import sc - -from nonebot.plugin import on_startswith -from nonebot.adapters.cqhttp import Bot, Event - -rdhelp = on_startswith("骰子娘帮助", priority=2) -stcommand = on_startswith(".st", priority=2) -encommand = on_startswith(".en", priority=2) -ticommand = on_startswith(".ti", priority=2) -licommand = on_startswith(".li", priority=2) -coc = on_startswith(".coc", priority=2) -sccommand = on_startswith(".sc", priority=2) -rdcommand = on_startswith(".r", priority=3) - - -@rdhelp.handle() -async def rdhelphandler(bot: Bot): - await rdhelp.finish(help_message()) - - -@stcommand.handle() -async def stcommandhandler(bot: Bot): - await rdhelp.finish(st()) - - -@encommand.handle() -async def enhandler(bot: Bot, event: Event): - args = str(event.get_message())[3:].strip() - await encommand.finish(en(args)) - - -@rdcommand.handle() -async def rdcommandhandler(bot: Bot, event: Event): - args = str(event.get_message())[2:].strip() - uid = event.get_session_id() - if args and not("." in args): - rrd = rd(args) - if type(rrd) == str: - await rdcommand.finish(rrd) - elif type(rrd) == list: - await bot.send_private_msg(user_id=uid, message=rrd[0]) - - -@coc.handle() -async def cochandler(bot: Bot, event: Event): - args = str(event.get_message())[4:].strip() - try: - args = int(args) - except: - args = 20 - inv = Investigator() - inv.age_change(args) - await coc.finish(inv.output()) - - -@ticommand.handle() -async def ticommandhandler(bot: Bot): - await ticommand.finish(ti()) - - -@licommand.handle() -async def licommandhandler(bot: Bot): - await licommand.finish(li()) - - -@sccommand.handle() -async def schandler(bot: Bot, event: Event): - args = str(event.get_message())[3:].strip() - await sccommand.finish(sc(args.lower())) diff --git a/plugins/nonebot_plugin_cocdicer/__pycache__/__init__.cpython-38.pyc b/plugins/nonebot_plugin_cocdicer/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 0bd616db..00000000 Binary files a/plugins/nonebot_plugin_cocdicer/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/nonebot_plugin_cocdicer/__pycache__/__init__.cpython-39.pyc b/plugins/nonebot_plugin_cocdicer/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 4c10f4a5..00000000 Binary files a/plugins/nonebot_plugin_cocdicer/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/nonebot_plugin_cocdicer/__pycache__/create.cpython-38.pyc b/plugins/nonebot_plugin_cocdicer/__pycache__/create.cpython-38.pyc deleted file mode 100644 index ecabf908..00000000 Binary files a/plugins/nonebot_plugin_cocdicer/__pycache__/create.cpython-38.pyc and /dev/null differ diff --git a/plugins/nonebot_plugin_cocdicer/__pycache__/create.cpython-39.pyc b/plugins/nonebot_plugin_cocdicer/__pycache__/create.cpython-39.pyc deleted file mode 100644 index 3a1b2aca..00000000 Binary files a/plugins/nonebot_plugin_cocdicer/__pycache__/create.cpython-39.pyc and /dev/null differ diff --git a/plugins/nonebot_plugin_cocdicer/__pycache__/data_source.cpython-38.pyc b/plugins/nonebot_plugin_cocdicer/__pycache__/data_source.cpython-38.pyc deleted file mode 100644 index cab8de52..00000000 Binary files a/plugins/nonebot_plugin_cocdicer/__pycache__/data_source.cpython-38.pyc and /dev/null differ diff --git a/plugins/nonebot_plugin_cocdicer/__pycache__/data_source.cpython-39.pyc b/plugins/nonebot_plugin_cocdicer/__pycache__/data_source.cpython-39.pyc deleted file mode 100644 index 5fde385e..00000000 Binary files a/plugins/nonebot_plugin_cocdicer/__pycache__/data_source.cpython-39.pyc and /dev/null differ diff --git a/plugins/nonebot_plugin_cocdicer/__pycache__/madness.cpython-38.pyc b/plugins/nonebot_plugin_cocdicer/__pycache__/madness.cpython-38.pyc deleted file mode 100644 index c657a445..00000000 Binary files a/plugins/nonebot_plugin_cocdicer/__pycache__/madness.cpython-38.pyc and /dev/null differ diff --git a/plugins/nonebot_plugin_cocdicer/__pycache__/madness.cpython-39.pyc b/plugins/nonebot_plugin_cocdicer/__pycache__/madness.cpython-39.pyc deleted file mode 100644 index 78cd6f2a..00000000 Binary files a/plugins/nonebot_plugin_cocdicer/__pycache__/madness.cpython-39.pyc and /dev/null differ diff --git a/plugins/nonebot_plugin_cocdicer/__pycache__/messages.cpython-38.pyc b/plugins/nonebot_plugin_cocdicer/__pycache__/messages.cpython-38.pyc deleted file mode 100644 index 513aca28..00000000 Binary files a/plugins/nonebot_plugin_cocdicer/__pycache__/messages.cpython-38.pyc and /dev/null differ diff --git a/plugins/nonebot_plugin_cocdicer/__pycache__/messages.cpython-39.pyc b/plugins/nonebot_plugin_cocdicer/__pycache__/messages.cpython-39.pyc deleted file mode 100644 index c024f9ff..00000000 Binary files a/plugins/nonebot_plugin_cocdicer/__pycache__/messages.cpython-39.pyc and /dev/null differ diff --git a/plugins/nonebot_plugin_cocdicer/__pycache__/san_check.cpython-38.pyc b/plugins/nonebot_plugin_cocdicer/__pycache__/san_check.cpython-38.pyc deleted file mode 100644 index 9086d936..00000000 Binary files a/plugins/nonebot_plugin_cocdicer/__pycache__/san_check.cpython-38.pyc and /dev/null differ diff --git a/plugins/nonebot_plugin_cocdicer/__pycache__/san_check.cpython-39.pyc b/plugins/nonebot_plugin_cocdicer/__pycache__/san_check.cpython-39.pyc deleted file mode 100644 index 0538a8a1..00000000 Binary files a/plugins/nonebot_plugin_cocdicer/__pycache__/san_check.cpython-39.pyc and /dev/null differ diff --git a/plugins/nonebot_plugin_cocdicer/create.py b/plugins/nonebot_plugin_cocdicer/create.py deleted file mode 100644 index 30b66d78..00000000 --- a/plugins/nonebot_plugin_cocdicer/create.py +++ /dev/null @@ -1,147 +0,0 @@ -import random - - -build_dict = {64: -2, 84: -1, 124: 0, 164: 1, - 204: 2, 284: 3, 364: 4, 444: 5, 524: 6} -db_dict = {-2: "-2", -1: "-1", 0: "0", 1: "1d4", - 2: "1d6", 3: "2d6", 4: "3d6", 5: "4d6", 6: "5d6"} - - -def randattr(time: int = 3, ex: int = 0): - r = 0 - for _ in range(time): - r += random.randint(1, 6) - return (r+ex)*5 - - -class Investigator(object): - def __init__(self) -> None: - self.age = 20 - self.str = randattr() - self.con = randattr() - self.siz = randattr(2, 6) - self.dex = randattr() - self.app = randattr() - self.int = randattr(2, 6) - self.pow = randattr() - self.edu = randattr(2, 6) - self.luc = randattr() - - def body_build(self) -> int: - build = self.str + self.con - for i, j in build_dict.items(): - if build <= i: - return j - return - - def db(self) -> str: - return db_dict[self.body_build()] - - def lp_max(self) -> int: - return (self.con+self.siz)//10 - - def mov(self) -> int: - r = 8 - if self.age >= 80: - r -= 5 - elif self.age >= 70: - r -= 4 - elif self.age >= 60: - r -= 3 - elif self.age >= 50: - r -= 2 - elif self.age >= 40: - r -= 1 - if self.str < self.siz and self.dex < self.siz: - return r-1 - elif self.str > self.siz and self.dex > self.siz: - return r+1 - else: - return r - - def edu_up(self) -> str: - edu_check = random.randint(1, 100) - if edu_check > self.edu: - edu_en = random.randint(1, 10) - self.edu += edu_en - else: - return "教育成长检定D100=%d,小于%d,无增长。" % (edu_check, self.edu) - if self.edu > 99: - self.edu = 99 - return "教育成长检定D100=%d,成长1D10=%d,成长到了最高值99!" % (edu_check, edu_en) - else: - return "教育成长检定D100=%d,成长1D10=%d,成长到了%d" % (edu_check, edu_en, self.edu) - - def edu_ups(self, times) -> str: - r = "" - for _ in range(times): - r += self.edu_up() - return r - - def sum_down(self, sum) -> str: - if self.str + self.con + self.dex-45 < sum: - self.str = 15 - self.con = 15 - self.dex = 15 - else: - str_lost = random.randint(0, min(sum, self.str-15)) - while sum - str_lost > self.con + self.dex-30: - str_lost = random.randint(0, min(sum, self.str-15)) - self.str -= str_lost - sum -= str_lost - con_lost = random.randint(0, min(sum, self.con-15)) - while sum - con_lost > self.dex-15: - con_lost = random.randint(0, min(sum, self.con-15)) - self.con -= con_lost - sum -= con_lost - self.dex -= sum - return - - def age_change(self, age: int = 20) -> str: - if age < 15: - return "年龄过小,无法担当调查员" - elif age >= 90: - return "该调查员已经作古。" - self.age = age - if 15 <= age < 20: - self.str -= 5 - self.siz -= 5 - self.edu -= 5 - luc = randattr() - self.luc = luc if luc > self.luc else self.luc - return "力量、体型、教育值-5,幸运增强判定一次" - elif age < 40: - self.edu_up() - return "教育增强判定一次" - elif age < 50: - self.app -= 5 - self.sum_down(5) - self.edu_ups(2) - return "外貌-5,力量、体型、敏捷合计降低5,教育增强判定两次" - elif age < 60: - self.app -= 10 - self.sum_down(10) - self.edu_ups(3) - return "外貌-10,力量、体型、敏捷合计降低10,教育增强判定三次" - elif age < 70: - self.app -= 15 - self.sum_down(20) - self.edu_ups(4) - return "外貌-15,力量、体型、敏捷合计降低20,教育增强判定四次" - elif age < 80: - self.app -= 20 - self.sum_down(40) - self.edu_ups(4) - return "外貌-20,力量、体型、敏捷合计降低40,教育增强判定四次" - elif age < 90: - self.app -= 25 - self.sum_down(80) - self.edu_ups(4) - return "外貌-25,力量、体型、敏捷合计降低80,教育增强判定四次" - - def __repr__(self) -> str: - return "调查员 年龄:%d\n力量:%d 体质:%d 体型:%d\n敏捷:%d 外貌:%d 智力:%d\n意志:%d 教育:%d 幸运:%d\nDB:%s 生命值:%d 移动速度:%d" % ( - self.age, self.str, self.con, self.siz, self.dex, self.app, self.int, self.pow, self.edu, self.luc, self.db(), self.lp_max(), self.mov()) - - def output(self) -> str: - return self.__repr__() diff --git a/plugins/nonebot_plugin_cocdicer/data_source.py b/plugins/nonebot_plugin_cocdicer/data_source.py deleted file mode 100644 index 3e2bb074..00000000 --- a/plugins/nonebot_plugin_cocdicer/data_source.py +++ /dev/null @@ -1,249 +0,0 @@ -# 参考[OlivaDiceDocs](https://oliva.dicer.wiki/userdoc)实现的nonebot2骰娘插件 -import re -import random -from .messages import * - - -class Mylist(list): - def next(self, index: int): - if index < self.__len__()-1: - return self[index+1] - else: - return "" - - -def help_message(): - return main_help_message - - -def dhr(t, o): - if t == 0 and o == 0: - return 100 - else: - return t*10+o - - -def st(): - result = random.randint(1, 20) - if result < 4: - rstr = "右腿" - elif result < 7: - rstr = "左腿" - elif result < 11: - rstr = "腹部" - elif result < 16: - rstr = "胸部" - elif result < 18: - rstr = "右臂" - elif result < 20: - rstr = "左臂" - elif result < 21: - rstr = "头部" - return "D20=%d:命中了%s" % (result, rstr) - - -def en(arg: str) -> str: - try: - arg = int(arg) - except: - return en_help_message - check = random.randint(1, 100) - if check > arg or check > 95: - plus = random.randint(1, 10) - r = "判定值%d,判定成功,技能成长%d+%d=%d" % (check, arg, plus, arg+plus) - return r + "\n温馨提示:如果技能提高到90%或更高,增加2D6理智点数。" - else: - return "判定值%d,判定失败,技能无成长。" % check - - -class Dices(object): - def __init__(self): - self.dices = 1 - self.faces = 100 - self.a = False - self.anum = 0 - self.h = False - self.times = 1 - self.bp = 0 - self._bp_result = "" - self._tens_place = None - self._ones_place = None - self._head = "" - self._mid = "" - self._end = "" - self.result = 0 - self.a_check_mode = self.a_check - self._a_check_result = "" - self.ex_dice = None - self.ex_dice_type = 1 - self._ex_result = "" - - def real_dice(self): - if self.faces == 100: - self._tens_place = random.randint(0, 9) - self._ones_place = random.randint(0, 9) - self.result += dhr(self._tens_place, self._ones_place) - return dhr(self._tens_place, self._ones_place) - else: - rint = random.randint(1, self.faces) - self.result += rint - return rint - - def bp_dice(self): - if not self.bp or self.faces != 100 or self.dices != 1: - self._bp_result = "" - return self._bp_result - self._bp_result = " -> 十位:%d,个位:%d" % ( - self._tens_place, self._ones_place) - bp = self.bp - while bp > 0: - bd = random.randint(0, 9) - self._bp_result += ",奖励:%d" % bd - if dhr(bd, self._ones_place) < dhr(self._tens_place, self._ones_place): - self._tens_place = bd - self.result = dhr(self._tens_place, self._ones_place) - bp -= 1 - while bp < 0: - bd = random.randint(0, 9) - self._bp_result += ",惩罚:%d" % bd - if dhr(bd, self._ones_place) > dhr(self._tens_place, self._ones_place): - self._tens_place = bd - self.set_result() - bp += 1 - return self._bp_result - - def a_check(self): - if not (self.a and self.anum and self.faces == 100 and self.dices == 1): - self._a_check_result = "" - return self._a_check_result - if self.result == 100: - self._a_check_result = " 大失败!" - elif self.anum < 50 and self.result > 95: - self._a_check_result = "\n检定值%d %d>95 大失败!" % ( - self.anum, self.result) - elif self.result == 1: - self._a_check_result = " 大成功!" - elif self.result <= self.anum // 5: - self._a_check_result = "\n检定值%d %d≤%d 极难成功" % ( - self.anum, self.result, self.anum // 5) - elif self.result <= self.anum // 2: - self._a_check_result = "\n检定值%d %d≤%d 困难成功" % ( - self.anum, self.result, self.anum // 2) - elif self.result <= self.anum: - self._a_check_result = "\n检定值%d %d≤%d 成功" % ( - self.anum, self.result, self.anum) - else: - self._a_check_result = "\n检定值%d %d>%d 失败" % ( - self.anum, self.result, self.anum) - return self._a_check_result - - def xdy(self): - self.result = 0 - if self.dices == 1: - self.real_dice() - self.bp_dice() - self.a_check() - return "" - else: - dice_results = [] - for _ in range(self.dices): - dice_result = self.real_dice() - dice_results.append(str(dice_result)) - return "(%s)" % "+".join(dice_results) - - def _ex_handle(self): - if not self.ex_dice: - self._ex_result = "" - elif type(self.ex_dice) == int: - ex_result = self.ex_dice_type*self.ex_dice - self._ex_result = "%s%s%d" % (str( - self.result) if self.dices == 1 else "", "+" if self.ex_dice_type == 1 else "-", self.ex_dice) - self.result += ex_result - elif type(self.ex_dice) == Dices: - self.ex_dice.roll - ex_result = self.ex_dice_type*self.ex_dice.result - self._ex_result = "%s%s%d" % (str( - self.result) if self.dices == 1 else "", "+" if self.ex_dice_type == 1 else "-", self.ex_dice) - self.result += ex_result - return self._ex_result - - def roll(self): - r = "%d次投掷:" % self.times - if self.times != 1: - r += "\n" - for _ in range(self.times): - xdyr = self.xdy() - self._ex_handle() - self._head = "%sD%d%s=" % ( - "" if self.dices == 1 else str(self.dices), - self.faces, - "" if not self.ex_dice else ( - ("+" if self.ex_dice_type == 1 else "-") + str(self.ex_dice) if type(self.ex_dice) == int else (str(self.ex_dice.dices)+"D"+self.ex_dice.faces)) - ) - self._mid = "%s%s=" % (xdyr, self._ex_result) - self._end = "%d%s%s" % ( - self.result, self._bp_result, self._a_check_result) - r += "%s%s%s" % (self._head, self._mid if self.dices != - 1 or self.ex_dice else "", self._end) - self.times -= 1 - if self.times: - r += "\n" - return r - - -def prework(args: list, start=0): - for i in range(start, len(args), 1): - if not re.search("\\d+", args[i]) and len(args[i]) > 1: - p = args.pop(i) - for j in list(p): - args.insert(i, j) - i += 1 - if prework(args, i): - break - return True - - -def rd(arg: str): - try: - h = False - dices = Dices() - args = re.split("(\\d+)", arg.lower()) - prework(args) - args = Mylist(args) - for i in range(len(args)): - if args[i] == "a": - dices.a = True - elif args[i] == "#" and re.search("\\d+", args.next(i)): - dices.times = int(args[i+1]) - elif args[i] == "b": - dices.bp += 1 - elif args[i] == "p": - dices.bp -= 1 - elif args[i] == "d" and re.search("\\d+", args.next(i)): - dices.faces = int(args[i+1]) - elif args[i] == " " and re.search("\\d+", args.next(i)) and dices.a: - dices.anum = int(args[i+1]) - elif args[i] == "h": - h = True - elif re.search("\\d+", args[i]): - if args.next(i) == "d": - dices.dices = int(args[i]) - elif args[i-1] == " " and dices.a: - dices.anum = int(args[i]) - elif args[i] in ["-", "+"]: - dices.ex_dice_type = (-1 if args[i] == "-" else 1) - if args.next(i+1) == "d": - dices.ex_dice = Dices() - dices.ex_dice.dices = int(args.next(i)) - dices.ex_dice.faces = int(args.next(i+2)) - elif args.next(i): - dices.ex_dice = int(args.next(i)) - if h: - return [dices.roll()] - return dices.roll() - except: - return r_help_message - - -if __name__ == "__main__": - rd("2d100") diff --git a/plugins/nonebot_plugin_cocdicer/madness.py b/plugins/nonebot_plugin_cocdicer/madness.py deleted file mode 100644 index 6fd85bb2..00000000 --- a/plugins/nonebot_plugin_cocdicer/madness.py +++ /dev/null @@ -1,36 +0,0 @@ -import random - -from .messages import temporary_madness, madness_end, phobias, manias - - -def ti(): - i = random.randint(1, 10) - r = "临时疯狂判定1D10=%d\n" % i - r += temporary_madness[i-1] - if i == 9: - j = random.randint(1, 100) - r += "\n恐惧症状为:\n" - r += phobias[j-1] - elif i == 10: - j = random.randint(1, 100) - r += "\n狂躁症状为:\n" - r += manias[j-1] - r += "\n该症状将会持续1D10=%d" % random.randint(1, 10) - return r - - -def li(): - i = random.randint(1, 10) - r = "总结疯狂判定1D10=%d\n" % i - r += madness_end[i-1] - if i in [2, 3, 6, 9, 10]: - r += "\n调查员将在1D10=%d小时后醒来" % random.randint(1, 10) - if i == 9: - j = random.randint(1, 100) - r += "\n恐惧症状为:\n" - r += phobias[j-1] - elif i == 10: - j = random.randint(1, 100) - r += "\n狂躁症状为:\n" - r += manias[j-1] - return r diff --git a/plugins/nonebot_plugin_cocdicer/messages.py b/plugins/nonebot_plugin_cocdicer/messages.py deleted file mode 100644 index 20883424..00000000 --- a/plugins/nonebot_plugin_cocdicer/messages.py +++ /dev/null @@ -1,258 +0,0 @@ -main_help_message: str = "本骰娘由nonebot2强力驱动\n" \ - ".r 投掷指令 todo\n" \ - " d 制定骰子面数\n" \ - " a 检定\n" \ - " h 暗骰\n" \ - " # 多轮检定\n" \ - " bp 奖励骰&惩罚骰\n" \ - " +/- 附加计算 todo\n" \ - ".sc 疯狂检定\n" \ - ".st 射击命中判定\n" \ - ".ti 临时疯狂症状\n" \ - ".li 总结疯狂症状\n" \ - ".coc coc角色作成\n" \ - ".en 技能成长" -r_help_message: str = ".r[dah#bp] a_number [+/-]ex_number\n" \ - "d:骰子设定指令,标准格式为xdy,x为骰子数量y为骰子面数;\n" \ - "a:检定指令,根据后续a_number设定数值检定;\n" \ - "h:暗骰指令,骰子结构将会私聊发送给该指令者;\n" \ - "#:多轮投掷指令,#后接数字即可设定多轮投掷;\n" \ - "bp:奖励骰与惩罚骰;\n" \ - "+/-:附加计算指令,目前仅支持数字\n" \ - "示例:\n" \ - ".r#2bba 70:两次投掷 1D100 ,附加两个奖励骰,判定值为70\n" \ - ".rah:D100暗骰,由于没有 a_number 参数,判定将被忽略\n" \ - ".ra2d8+10 70:2D8+10,由于非D100,判定将被忽略" -sc_help_message: str = ".sc success/failure san_number\n" \ - "success:判定成功降低 san 值,支持 x 或 xdy 语法( x 与 y 为数字);\n" \ - "failure:判定失败降低 san 值,支持语法如上;\n" \ - "san_number:当前 san 值。" -en_help_message: str = ".en skill_level\nskill_level:需要成长的技能当前等级。" -temporary_madness = [ - "1) 失忆: 调查员会发现自己身处于一个安全的地点却没有任何来到这里的记忆。例如,调查员前一刻还在家中吃着早饭,下一刻就已经直面着不知名的怪物。这将会持续1D10轮。", - "2) 假性残疾:调查员陷入了心理性的失明,失聪以及躯体缺失感中,持续1D10轮。", - "3) 暴力倾向: 调查员陷入了六亲不认的暴力行为中,对周围的敌人与友方进行着无差别的攻击,持续1D10轮。", - "4) 偏执: 调查员陷入了严重的偏执妄想之中,持续1D10轮。有人在暗中窥视着他们,同伴中有人背叛了他们,没有人可以信任,万事皆虚。", - "5) 人际依赖: 守密人适当参考调查员的背景中重要之人的条目,调查员因为一些原因而降他人误认为了他重要的人并且努力的会与那个人保持那种关系,持续1D10轮。", - "6) 昏厥: 调查员当场昏倒,并需要1D10轮才能苏醒。", - "7) 逃避行为: 调查员会用任何的手段试图逃离现在所处的位置,即使这意味着开走唯一一辆交通工具并将其它人抛诸脑后,调查员会试图逃离1D10轮。", - "8) 竭嘶底里:调查员表现出大笑,哭泣,嘶吼,害怕等的极端情绪表现,持续1D10轮。", - "9) 恐惧: 调查员通过一次D100或者由守密人选择,来从恐惧症状表中选择一个恐惧源,就算这一恐惧的事物是并不存在的,调查员的症状会持续1D10轮。", - "10) 躁狂: 调查员通过一次D100或者由守密人选择,来从躁狂症状表中选择一个躁狂的诱因,这个症状将会持续1D10轮。" -] -madness_end = [ - "1) 失忆(Amnesia):回过神来,调查员们发现自己身处一个陌生的地方,并忘记了自己是谁。记忆会随时间恢复。", - "2) 被窃(Robbed):调查员在1D10小时后恢复清醒,发觉自己被盗,身体毫发无损。如果调查员携带着宝贵之物(见调查员背景),做幸运检定来决定其是否被盗。所有有价值的东西无需检定自动消失。", - "3) 遍体鳞伤(Battered):调查员在1D10小时后恢复清醒,发现自己身上满是拳痕和瘀伤。生命值减少到疯狂前的一半,但这不会造成重伤。调查员没有被窃。这种伤害如何持续到现在由守秘人决定。", - "4) 暴力倾向(Violence):调查员陷入强烈的暴力与破坏欲之中。调查员回过神来可能会理解自己做了什么也可能毫无印象。调查员对谁或何物施以暴力,他们是杀人还是仅仅造成了伤害,由守秘人决定。", - "5) 极端信念(Ideology/Beliefs):查看调查员背景中的思想信念,调查员会采取极端和疯狂的表现手段展示他们的思想信念之一。比如一个信教者会在地铁上高声布道。", - "6) 重要之人(Significant People):考虑调查员背景中的重要之人,及其重要的原因。在1D10小时或更久的时间中,调查员将不顾一切地接近那个人,并为他们之间的关系做出行动。", - "7) 被收容(Institutionalized):调查员在精神病院病房或警察局牢房中回过神来,他们可能会慢慢回想起导致自己被关在这里的事情。", - "8) 逃避行为(Flee in panic):调查员恢复清醒时发现自己在很远的地方,也许迷失在荒郊野岭,或是在驶向远方的列车或长途汽车上。", - "9) 恐惧(Phobia):调查员患上一个新的恐惧症状。在表Ⅸ:恐惧症状表上骰1个D100来决定症状,或由守秘人选择一个。调查员在1D10小时后回过神来,并开始为避开恐惧源而采取任何措施。", - "10) 狂躁(Mania):调查员患上一个新的狂躁症状。在表Ⅹ:狂躁症状表上骰1个D100来决定症状,或由守秘人选择一个。调查员会在1D10小时后恢复理智。在这次疯狂发作中,调查员将完全沉浸于其新的狂躁症状。这症状是否会表现给旁人则取决于守秘人和此调查员。" -] -phobias = [ - "1) 洗澡恐惧症(Ablutophobia):对于洗涤或洗澡的恐惧。", - "2) 恐高症(Acrophobia):对于身处高处的恐惧。", - "3) 飞行恐惧症(Aerophobia):对飞行的恐惧。", - "4) 广场恐惧症(Agoraphobia):对于开放的(拥挤)公共场所的恐惧。", - "5) 恐鸡症(Alektorophobia):对鸡的恐惧。", - "6) 大蒜恐惧症(Alliumphobia):对大蒜的恐惧。", - "7) 乘车恐惧症(Amaxophobia):对于乘坐地面载具的恐惧。", - "8) 恐风症(Ancraophobia):对风的恐惧。", - "9) 男性恐惧症(Androphobia):对于成年男性的恐惧。", - "10) 恐英症(Anglophobia):对英格兰或英格兰文化的恐惧。", - "11) 恐花症(Anthophobia):对花的恐惧。", - "12) 截肢者恐惧症(Apotemnophobia):对截肢者的恐惧。", - "13) 蜘蛛恐惧症(Arachnophobia):对蜘蛛的恐惧。", - "14) 闪电恐惧症(Astraphobia):对闪电的恐惧。", - "15) 废墟恐惧症(Atephobia):对遗迹或残址的恐惧。", - "16) 长笛恐惧症(Aulophobia):对长笛的恐惧。", - "17) 细菌恐惧症(Bacteriophobia):对细菌的恐惧。", - "18) 导弹/子弹恐惧症(Ballistophobia):对导弹或子弹的恐惧。", - "19) 跌落恐惧症(Basophobia):对于跌倒或摔落的恐惧。", - "20) 书籍恐惧症(Bibliophobia):对书籍的恐惧。", - "21) 植物恐惧症(Botanophobia):对植物的恐惧。", - "22) 美女恐惧症(Caligynephobia):对美貌女性的恐惧。", - "23) 寒冷恐惧症(Cheimaphobia):对寒冷的恐惧。", - "24) 恐钟表症(Chronomentrophobia):对于钟表的恐惧。", - "25) 幽闭恐惧症(Claustrophobia):对于处在封闭的空间中的恐惧。", - "26) 小丑恐惧症(Coulrophobia):对小丑的恐惧。", - "27) 恐犬症(Cynophobia):对狗的恐惧。", - "28) 恶魔恐惧症(Demonophobia):对邪灵或恶魔的恐惧。", - "29) 人群恐惧症(Demophobia):对人群的恐惧。", - "30) 牙科恐惧症①(Dentophobia):对牙医的恐惧。", - "31) 丢弃恐惧症(Disposophobia):对于丢弃物件的恐惧(贮藏癖)。", - "32) 皮毛恐惧症(Doraphobia):对动物皮毛的恐惧。", - "33) 过马路恐惧症(Dromophobia):对于过马路的恐惧。", - "34) 教堂恐惧症(Ecclesiophobia):对教堂的恐惧。", - "35) 镜子恐惧症(Eisoptrophobia):对镜子的恐惧。", - "36) 针尖恐惧症(Enetophobia):对针或大头针的恐惧。", - "37) 昆虫恐惧症(Entomophobia):对昆虫的恐惧。", - "38) 恐猫症(Felinophobia):对猫的恐惧。", - "39) 过桥恐惧症(Gephyrophobia):对于过桥的恐惧。", - "40) 恐老症(Gerontophobia):对于老年人或变老的恐惧。", - "41) 恐女症(Gynophobia):对女性的恐惧。", - "42) 恐血症(Haemaphobia):对血的恐惧。", - "43) 宗教罪行恐惧症(Hamartophobia):对宗教罪行的恐惧。", - "44) 触摸恐惧症(Haphophobia):对于被触摸的恐惧。", - "45) 爬虫恐惧症(Herpetophobia):对爬行动物的恐惧。", - "46) 迷雾恐惧症(Homichlophobia):对雾的恐惧。", - "47) 火器恐惧症(Hoplophobia):对火器的恐惧。", - "48) 恐水症(Hydrophobia):对水的恐惧。", - "49) 催眠恐惧症(Hypnophobia):对于睡眠或被催眠的恐惧。", - "50) 白袍恐惧症(Iatrophobia):对医生的恐惧。", - "51) 鱼类恐惧症(Ichthyophobia):对鱼的恐惧。", - "52) 蟑螂恐惧症(Katsaridaphobia):对蟑螂的恐惧。", - "53) 雷鸣恐惧症(Keraunophobia):对雷声的恐惧。", - "54) 蔬菜恐惧症(Lachanophobia):对蔬菜的恐惧。", - "55) 噪音恐惧症(Ligyrophobia):对刺耳噪音的恐惧。", - "56) 恐湖症(Limnophobia):对湖泊的恐惧。", - "57) 机械恐惧症(Mechanophobia):对机器或机械的恐惧。", - "58) 巨物恐惧症(Megalophobia):对于庞大物件的恐惧。", - "59) 捆绑恐惧症(Merinthophobia):对于被捆绑或紧缚的恐惧。", - "60) 流星恐惧症(Meteorophobia):对流星或陨石的恐惧。", - "61) 孤独恐惧症(Monophobia):对于一人独处的恐惧。", - "62) 不洁恐惧症(Mysophobia):对污垢或污染的恐惧。", - "63) 黏液恐惧症(Myxophobia):对黏液(史莱姆)的恐惧。", - "64) 尸体恐惧症(Necrophobia):对尸体的恐惧。", - "65) 数字8恐惧症(Octophobia):对数字8的恐惧。", - "66) 恐牙症(Odontophobia):对牙齿的恐惧。", - "67) 恐梦症(Oneirophobia):对梦境的恐惧。", - "68) 称呼恐惧症(Onomatophobia):对于特定词语的恐惧。", - "69) 恐蛇症(Ophidiophobia):对蛇的恐惧。", - "70) 恐鸟症(Ornithophobia):对鸟的恐惧。", - "71) 寄生虫恐惧症(Parasitophobia):对寄生虫的恐惧。", - "72) 人偶恐惧症(Pediophobia):对人偶的恐惧。", - "73) 吞咽恐惧症(Phagophobia):对于吞咽或被吞咽的恐惧。", - "74) 药物恐惧症(Pharmacophobia):对药物的恐惧。", - "75) 幽灵恐惧症(Phasmophobia):对鬼魂的恐惧。", - "76) 日光恐惧症(Phenogophobia):对日光的恐惧。", - "77) 胡须恐惧症(Pogonophobia):对胡须的恐惧。", - "78) 河流恐惧症(Potamophobia):对河流的恐惧。", - "79) 酒精恐惧症(Potophobia):对酒或酒精的恐惧。", - "80) 恐火症(Pyrophobia):对火的恐惧。", - "81) 魔法恐惧症(Rhabdophobia):对魔法的恐惧。", - "82) 黑暗恐惧症(Scotophobia):对黑暗或夜晚的恐惧。", - "83) 恐月症(Selenophobia):对月亮的恐惧。", - "84) 火车恐惧症(Siderodromophobia):对于乘坐火车出行的恐惧。", - "85) 恐星症(Siderophobia):对星星的恐惧。", - "86) 狭室恐惧症(Stenophobia):对狭小物件或地点的恐惧。", - "87) 对称恐惧症(Symmetrophobia):对对称的恐惧。", - "88) 活埋恐惧症(Taphephobia):对于被活埋或墓地的恐惧。", - "89) 公牛恐惧症(Taurophobia):对公牛的恐惧。", - "90) 电话恐惧症(Telephonophobia):对电话的恐惧。", - "91) 怪物恐惧症①(Teratophobia):对怪物的恐惧。", - "92) 深海恐惧症(Thalassophobia):对海洋的恐惧。", - "93) 手术恐惧症(Tomophobia):对外科手术的恐惧。", - "94) 十三恐惧症(Triskadekaphobia):对数字13的恐惧症。", - "95) 衣物恐惧症(Vestiphobia):对衣物的恐惧。", - "96) 女巫恐惧症(Wiccaphobia):对女巫与巫术的恐惧。", - "97) 黄色恐惧症(Xanthophobia):对黄色或“黄”字的恐惧。", - "98) 外语恐惧症(Xenoglossophobia):对外语的恐惧。", - "99) 异域恐惧症(Xenophobia):对陌生人或外国人的恐惧。", - "100) 动物恐惧症(Zoophobia):对动物的恐惧。" -] -manias = [ - "1) 沐浴癖(Ablutomania):执着于清洗自己。", - "2) 犹豫癖(Aboulomania):病态地犹豫不定。", - "3) 喜暗狂(Achluomania):对黑暗的过度热爱。", - "4) 喜高狂(Acromaniaheights):狂热迷恋高处。", - "5) 亲切癖(Agathomania):病态地对他人友好。", - "6) 喜旷症(Agromania):强烈地倾向于待在开阔空间中。", - "7) 喜尖狂(Aichmomania):痴迷于尖锐或锋利的物体。", - "8) 恋猫狂(Ailuromania):近乎病态地对猫友善。", - "9) 疼痛癖(Algomania):痴迷于疼痛。", - "10) 喜蒜狂(Alliomania):痴迷于大蒜。", - "11) 乘车癖(Amaxomania):痴迷于乘坐车辆。", - "12) 欣快癖(Amenomania):不正常地感到喜悦。", - "13) 喜花狂(Anthomania):痴迷于花朵。", - "14) 计算癖(Arithmomania):狂热地痴迷于数字。", - "15) 消费癖(Asoticamania):鲁莽冲动地消费。", - "16) 隐居癖(Automania):过度地热爱独自隐居(原文如此,存疑,Automania实际上是恋车癖)。", - "17) 芭蕾癖(Balletmania):痴迷于芭蕾舞。", - "18) 窃书癖(Biliokleptomania):无法克制偷窃书籍的冲动。", - "19) 恋书狂(Bibliomania):痴迷于书籍和/或阅读。", - "20) 磨牙癖(Bruxomania):无法克制磨牙的冲动。", - "21) 灵臆症(Cacodemomania):病态地坚信自己已被一个邪恶的灵体占据。", - "22) 美貌狂(Callomania):痴迷于自身的美貌。", - "23) 地图狂(Cartacoethes):在何时何处都无法控制查阅地图的冲动。", - "24) 跳跃狂(Catapedamania):痴迷于从高处跳下。", - "25) 喜冷症(Cheimatomania):对寒冷或寒冷的物体的反常喜爱。", - "26) 舞蹈狂(Choreomania):无法控制地起舞或发颤。", - "27) 恋床癖(Clinomania):过度地热爱待在床上。", - "28) 恋墓狂(Coimetormania):痴迷于墓地。", - "29) 色彩狂(Coloromania):痴迷于某种颜色。", - "30) 小丑狂(Coulromania):痴迷于小丑。", - "31) 恐惧狂(Countermania):执着于经历恐怖的场面。", - "32) 杀戮癖(Dacnomania):痴迷于杀戮。", - "33) 魔臆症(Demonomania):病态地坚信自己已被恶魔附身。", - "34) 抓挠癖(Dermatillomania):执着于抓挠自己的皮肤。", - "35) 正义狂(Dikemania):痴迷于目睹正义被伸张。", - "36) 嗜酒狂(Dipsomania):反常地渴求酒精。", - "37) 毛皮狂(Doramania):痴迷于拥有毛皮。(存疑)", - "38) 赠物癖(Doromania):痴迷于赠送礼物。", - "39) 漂泊症(Drapetomania):执着于逃离。", - "40) 漫游癖(Ecdemiomania):执着于四处漫游。", - "41) 自恋狂(Egomania):近乎病态地以自我为中心或自我崇拜。", - "42) 职业狂(Empleomania):对于工作的无尽病态渴求。", - "43) 臆罪症(Enosimania):病态地坚信自己带有罪孽。", - "44) 学识狂(Epistemomania):痴迷于获取学识。", - "45) 静止癖(Eremiomania):执着于保持安静。", - "46) 乙醚上瘾(Etheromania):渴求乙醚。", - "47) 求婚狂(Gamomania):痴迷于进行奇特的求婚。", - "48) 狂笑癖(Geliomania):无法自制地,强迫性的大笑。", - "49) 巫术狂(Goetomania):痴迷于女巫与巫术。", - "50) 写作癖(Graphomania):痴迷于将每一件事写下来。", - "51) 裸体狂(Gymnomania):执着于裸露身体。", - "52) 妄想狂(Habromania):近乎病态地充满愉快的妄想(而不顾现实状况如何)。", - "53) 蠕虫狂(Helminthomania):过度地喜爱蠕虫。", - "54) 枪械狂(Hoplomania):痴迷于火器。", - "55) 饮水狂(Hydromania):反常地渴求水分。", - "56) 喜鱼癖(Ichthyomania):痴迷于鱼类。", - "57) 图标狂(Iconomania):痴迷于图标与肖像。", - "58) 偶像狂(Idolomania):痴迷于甚至愿献身于某个偶像。", - "59) 信息狂(Infomania):痴迷于积累各种信息与资讯。", - "60) 射击狂(Klazomania):反常地执着于射击。", - "61) 偷窃癖(Kleptomania):反常地执着于偷窃。", - "62) 噪音癖(Ligyromania):无法自制地执着于制造响亮或刺耳的噪音。", - "63) 喜线癖(Linonomania):痴迷于线绳。", - "64) 彩票狂(Lotterymania):极端地执着于购买彩票。", - "65) 抑郁症(Lypemania):近乎病态的重度抑郁倾向。", - "66) 巨石狂(Megalithomania):当站在石环中或立起的巨石旁时,就会近乎病态地写出各种奇怪的创意。", - "67) 旋律狂(Melomania):痴迷于音乐或一段特定的旋律。", - "68) 作诗癖(Metromania):无法抑制地想要不停作诗。", - "69) 憎恨癖(Misomania):憎恨一切事物,痴迷于憎恨某个事物或团体。", - "70) 偏执狂(Monomania):近乎病态地痴迷与专注某个特定的想法或创意。", - "71) 夸大癖(Mythomania):以一种近乎病态的程度说谎或夸大事物。", - "72) 臆想症(Nosomania):妄想自己正在被某种臆想出的疾病折磨。", - "73) 记录癖(Notomania):执着于记录一切事物(例如摄影)。", - "74) 恋名狂(Onomamania):痴迷于名字(人物的、地点的、事物的)。", - "75) 称名癖(Onomatomania):无法抑制地不断重复某个词语的冲动。", - "76) 剔指癖(Onychotillomania):执着于剔指甲。", - "77) 恋食癖(Opsomania):对某种食物的病态热爱。", - "78) 抱怨癖(Paramania):一种在抱怨时产生的近乎病态的愉悦感。", - "79) 面具狂(Personamania):执着于佩戴面具。", - "80) 幽灵狂(Phasmomania):痴迷于幽灵。", - "81) 谋杀癖(Phonomania):病态的谋杀倾向。", - "82) 渴光癖(Photomania):对光的病态渴求。", - "83) 背德癖(Planomania):病态地渴求违背社会道德(原文如此,存疑,Planomania实际上是漂泊症)。", - "84) 求财癖(Plutomania):对财富的强迫性的渴望。", - "85) 欺骗狂(Pseudomania):无法抑制的执着于撒谎。", - "86) 纵火狂(Pyromania):执着于纵火。", - "87) 提问狂(Questiong-Asking Mania):执着于提问。", - "88) 挖鼻癖(Rhinotillexomania):执着于挖鼻子。", - "89) 涂鸦癖(Scribbleomania):沉迷于涂鸦。", - "90) 列车狂(Siderodromomania):认为火车或类似的依靠轨道交通的旅行方式充满魅力。", - "91) 臆智症(Sophomania):臆想自己拥有难以置信的智慧。", - "92) 科技狂(Technomania):痴迷于新的科技。", - "93) 臆咒狂(Thanatomania):坚信自己已被某种死亡魔法所诅咒。", - "94) 臆神狂(Theomania):坚信自己是一位神灵。", - "95) 抓挠癖(Titillomaniac):抓挠自己的强迫倾向。", - "96) 手术狂(Tomomania):对进行手术的不正常爱好。", - "97) 拔毛癖(Trichotillomania):执着于拔下自己的头发。", - "98) 臆盲症(Typhlomania):病理性的失明。", - "99) 嗜外狂(Xenomania):痴迷于异国的事物。", - "100) 喜兽癖(Zoomania):对待动物的态度近乎疯狂地友好。" -] diff --git a/plugins/nonebot_plugin_cocdicer/san_check.py b/plugins/nonebot_plugin_cocdicer/san_check.py deleted file mode 100644 index 1b8b2570..00000000 --- a/plugins/nonebot_plugin_cocdicer/san_check.py +++ /dev/null @@ -1,38 +0,0 @@ -from .data_source import Dices -from .messages import sc_help_message - -import re - - -def number_or_dice(arg: str): - if "d" in arg: - d = Dices() - if dices := re.search(r"\d+d", arg): - d.dices = int(dices.group()[:-1]) - if faces := re.search(r"d\d+", arg): - d.faces = int(faces.group()[1:]) - d.roll() - return d - else: - return int(arg) - - -def sc(arg: str) -> str: - a_num = re.search(r" \d+", arg) - success = re.search(r"\d*d\d+|\d+", arg) - failure = re.search(r"[\/]+(\d*d\d+|\d+)", arg) - if not (a_num and success and failure): - return sc_help_message - check_dice = Dices() - check_dice.a = True - check_dice.anum = int(a_num.group()[1:]) - success = number_or_dice(success.group()) - failure = number_or_dice(failure.group()[1:]) - r = "San Check" + check_dice.roll()[4:] - result = success if check_dice.result <= check_dice.anum else failure - r += "\n理智降低了" - if type(result) == int: - r += "%d点" % result - else: - r = r + result._head + str(result.result) - return r diff --git a/plugins/nonebot_plugin_manager/__init__.py b/plugins/nonebot_plugin_manager/__init__.py deleted file mode 100644 index 30a2c3f5..00000000 --- a/plugins/nonebot_plugin_manager/__init__.py +++ /dev/null @@ -1,110 +0,0 @@ -from nonebot.plugin import on_shell_command, get_loaded_plugins, export -from nonebot.matcher import Matcher -from nonebot.typing import T_State -from nonebot.exception import IgnoredException -from nonebot.message import run_preprocessor -from nonebot.adapters.cqhttp import Event, Bot, GroupMessageEvent, PrivateMessageEvent -from configs.config import plugins2name_dict -from models.ban_user import BanUser -from .data import ( - block_plugin, - unblock_plugin, - get_group_plugin_list, - auto_update_plugin_list, -) -from .parser import npm_parser - -# 导出给其他插件使用 -export = export() -export.block_plugin = block_plugin -export.unblock_plugin = unblock_plugin -export.unblock_plugin = unblock_plugin -export.get_group_plugin_list = get_group_plugin_list - -# 注册 shell_like 事件响应器 -plugin_manager = on_shell_command("npm", parser=npm_parser, priority=1) - - -# 在 Matcher 运行前检测其是否启用 -@run_preprocessor -async def _(matcher: Matcher, bot: Bot, event: Event, state: T_State): - plugin = matcher.module - group_id = _get_group_id(event) - loaded_plugin_list = _get_loaded_plugin_list() - plugin_list = auto_update_plugin_list(loaded_plugin_list) - - # 无视本插件的 Matcher - if plugin not in plugins2name_dict or matcher.priority in [1, 9] or await BanUser.isban(event.user_id): - return - try: - if isinstance(event, PrivateMessageEvent) and plugin_list[plugin]["default"]: - return - except: - pass - - # print(matcher.module) - # print(f'plugin_list[plugin]["default"] = {plugin_list[plugin]["default"]}') - # print(f'{matcher.module} -> this is hook') - if not plugin_list[plugin]["default"]: - if event.message_type == 'group': - await bot.send_group_msg(group_id=event.group_id, message='此功能正在维护...') - else: - await bot.send_private_msg(user_id=event.user_id, message='此功能正在维护...') - raise IgnoredException(f"Nonebot Plugin Manager has blocked {plugin} !") - # print(plugin_list[plugin]) - # print(group_id) - # print(plugin_list[plugin][group_id]) - # print(not plugin_list[plugin][group_id]) - if group_id in plugin_list[plugin]: - if not plugin_list[plugin][group_id]: - if plugin != 'ai' and matcher.type == 'message': - await bot.send_group_msg(group_id=event.group_id, message='该群未开启此功能..') - raise IgnoredException(f"Nonebot Plugin Manager has blocked {plugin} !") - - -@plugin_manager.handle() -async def _(bot: Bot, event: Event, state: T_State): - args = state["args"] - group_id = _get_group_id(event) - is_admin = _is_admin(event) - is_superuser = _is_superuser(bot, event) - if group_id == 0: - group_id = 'default' - - if hasattr(args, "handle"): - await plugin_manager.finish(args.handle(args, group_id, is_admin, is_superuser)) - - -# 获取插件列表,并自动排除本插件 -def _get_loaded_plugin_list() -> list: - return list( - filter( - lambda plugin: plugin != "nonebot_plugin_manager", - map(lambda plugin: plugin.name, get_loaded_plugins()), - ) - ) - - -def _get_group_id(event: Event) -> str: - try: - group_id = event.group_id - except AttributeError: - group_id = "default" - return str(group_id) if group_id else "default" - - -def _is_admin(event: Event) -> bool: - return ( - event.sender.role in ["admin", "owner"] - if isinstance(event, GroupMessageEvent) - else False - ) - - -def _is_superuser(bot: Bot, event: Event) -> bool: - return str(event.user_id) in bot.config.superusers - - -plugins_dict = { - -} diff --git a/plugins/nonebot_plugin_manager/__pycache__/__init__.cpython-38.pyc b/plugins/nonebot_plugin_manager/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index ce945162..00000000 Binary files a/plugins/nonebot_plugin_manager/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/nonebot_plugin_manager/__pycache__/__init__.cpython-39.pyc b/plugins/nonebot_plugin_manager/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 6d7a0f8c..00000000 Binary files a/plugins/nonebot_plugin_manager/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/nonebot_plugin_manager/__pycache__/data.cpython-38.pyc b/plugins/nonebot_plugin_manager/__pycache__/data.cpython-38.pyc deleted file mode 100644 index adcdae69..00000000 Binary files a/plugins/nonebot_plugin_manager/__pycache__/data.cpython-38.pyc and /dev/null differ diff --git a/plugins/nonebot_plugin_manager/__pycache__/data.cpython-39.pyc b/plugins/nonebot_plugin_manager/__pycache__/data.cpython-39.pyc deleted file mode 100644 index 4fcf6459..00000000 Binary files a/plugins/nonebot_plugin_manager/__pycache__/data.cpython-39.pyc and /dev/null differ diff --git a/plugins/nonebot_plugin_manager/__pycache__/handle.cpython-38.pyc b/plugins/nonebot_plugin_manager/__pycache__/handle.cpython-38.pyc deleted file mode 100644 index 4f9dc5cf..00000000 Binary files a/plugins/nonebot_plugin_manager/__pycache__/handle.cpython-38.pyc and /dev/null differ diff --git a/plugins/nonebot_plugin_manager/__pycache__/handle.cpython-39.pyc b/plugins/nonebot_plugin_manager/__pycache__/handle.cpython-39.pyc deleted file mode 100644 index 681d10ea..00000000 Binary files a/plugins/nonebot_plugin_manager/__pycache__/handle.cpython-39.pyc and /dev/null differ diff --git a/plugins/nonebot_plugin_manager/__pycache__/parser.cpython-38.pyc b/plugins/nonebot_plugin_manager/__pycache__/parser.cpython-38.pyc deleted file mode 100644 index 1dabebd2..00000000 Binary files a/plugins/nonebot_plugin_manager/__pycache__/parser.cpython-38.pyc and /dev/null differ diff --git a/plugins/nonebot_plugin_manager/__pycache__/parser.cpython-39.pyc b/plugins/nonebot_plugin_manager/__pycache__/parser.cpython-39.pyc deleted file mode 100644 index 301f46fc..00000000 Binary files a/plugins/nonebot_plugin_manager/__pycache__/parser.cpython-39.pyc and /dev/null differ diff --git a/plugins/nonebot_plugin_manager/data.py b/plugins/nonebot_plugin_manager/data.py deleted file mode 100644 index 56c0c486..00000000 --- a/plugins/nonebot_plugin_manager/data.py +++ /dev/null @@ -1,121 +0,0 @@ -import json -import httpx -from pathlib import Path -from configs.config import plugins2name_dict - -_DATA_PATH = Path() / "data" / "manager" / "plugin_list.json" - - -def get_store_plugin_info(plugin: str) -> str: - store_plugin_list = _get_store_plugin_list() - if plugin in store_plugin_list: - plugin = store_plugin_list[plugin] - return ( - f"ID: {plugin['id']}\n" - f"Name: {plugin['name']}\n" - f"Description: {plugin['desc']}\n" - f"Version: {httpx.get('https://pypi.org/pypi/'+plugin['link']+'/json').json()['info']['version']}\n" - f"Author: {plugin['author']}\n" - f"Repo: https://github.com/{plugin['repo']}" - ) - else: - return "查无此插件!" - - -def get_group_plugin_list(group_id: str) -> dict: - plugin_list = _load_plugin_list() - group_plugin_list = {} - for plugin in plugin_list: - if group_id in plugin_list[plugin]: - group_plugin_list[plugin] = plugin_list[plugin][group_id] - else: - group_plugin_list[plugin] = plugin_list[plugin]["default"] - return group_plugin_list - - -def get_store_pulgin_list() -> str: - message = "商店插件列表如下:" - for plugin in _get_store_plugin_list(): - if plugin in _load_plugin_list() or plugin == "nonebot_plugin_manager": - message += f"\n[o] {plugin}" - else: - message += f"\n[x] {plugin}" - return message - - -def auto_update_plugin_list(loaded_plugin_list: list, keep_history: bool = False): - plugin_list = _load_plugin_list() - for plugin in loaded_plugin_list: - if plugin not in plugin_list: - plugin_list[plugin] = {"default": True} - if not keep_history: - plugin_list = { - key: plugin_list[key] for key in plugin_list if key in loaded_plugin_list - } - _dump_plugin_list(plugin_list) - return plugin_list - - -def block_plugin(group_id: str, *plugins: str): - return _update_plugin_list(group_id, True, *plugins) - - -def unblock_plugin(group_id: str, *plugins: str): - return _update_plugin_list(group_id, False, *plugins) - - -# 获取商店插件列表 -def _get_store_plugin_list() -> dict: - store_plugin_list = {} - for plugin in httpx.get( - "https://cdn.jsdelivr.net/gh/nonebot/nonebot2@master/docs/.vuepress/public/plugins.json" - ).json(): - store_plugin_list.update({plugin["id"]: plugin}) - return store_plugin_list - - -# 更新插件列表 -def _update_plugin_list(group_id: str, block: bool, *plugins: str) -> str: - plugin_list = _load_plugin_list() - message = "结果如下:" - operate = "屏蔽" if block else "启用" - for plugin in plugins: - for values in plugins2name_dict.values(): - if plugin in values: - plugin = list(plugins2name_dict.keys())[list(plugins2name_dict.values()).index(values)] - # print(plugin) - break - message += "\n" - if plugin in plugin_list: - if ( - not group_id in plugin_list[plugin] - or plugin_list[plugin][group_id] == block - ): - plugin_list[plugin][group_id] = not block - message += f"插件{plugin}{operate}成功!" - print(plugin_list[plugin][group_id]) - else: - message += f"插件{plugin}已经{operate}!" - else: - message += f"插件{plugin}不存在!" - _dump_plugin_list(plugin_list) - return message - - -# 加载插件列表 -def _load_plugin_list() -> dict: - try: - return json.load(_DATA_PATH.open("r", encoding="utf-8")) - except FileNotFoundError: - return {} - - -# 保存插件列表 -def _dump_plugin_list(plugin_list: dict): - _DATA_PATH.parent.mkdir(parents=True, exist_ok=True) - json.dump( - plugin_list, - _DATA_PATH.open("w", encoding="utf-8"), - indent=4, - separators=(",", ": "), - ) diff --git a/plugins/nonebot_plugin_manager/handle.py b/plugins/nonebot_plugin_manager/handle.py deleted file mode 100644 index 1900ed2f..00000000 --- a/plugins/nonebot_plugin_manager/handle.py +++ /dev/null @@ -1,138 +0,0 @@ -from argparse import Namespace - -from .data import * - - -def handle_list( - args: Namespace, - group_id: str, - is_admin: bool, - is_superuser: bool, -) -> str: - message = "" - - if args.store: - if is_superuser: - return get_store_pulgin_list() - else: - return "获取商店插件列表需要超级用户权限!" - - if args.default: - if is_superuser: - group_id = "default" - message += "默认" - else: - return "获取默认插件列表需要超级用户权限!" - - if args.group: - if is_superuser: - group_id = args.group - message += f"群{args.group}" - else: - return "获取指定群插件列表需要超级用户权限!" - - message += "插件列表如下:\n" - message += "\n".join( - f"[{'o' if get_group_plugin_list(group_id)[plugin] else 'x'}] {plugin}" - for plugin in get_group_plugin_list(group_id) - ) - return message - - -def handle_block( - args: Namespace, - group_id: str, - is_admin: bool, - is_superuser: bool, -) -> str: - - if not is_admin and not is_superuser: - return "管理插件需要群管理员权限!" - - message = "" - - if args.default: - if is_superuser: - group_id = "default" - message += "默认" - else: - return "管理默认插件需要超级用户权限!" - - if args.group: - if is_superuser: - group_id = args.group - message += f"群{args.group}" - else: - return "管理指定群插件需要超级用户权限!" - - message += block_plugin(group_id, *args.plugins) - return message - - -def handle_unblock( - args: Namespace, - group_id: str, - is_admin: bool, - is_superuser: bool, -) -> str: - message = "" - - if not is_admin and not is_superuser: - return "管理插件需要群管理员权限!" - - if args.default: - if is_superuser: - group_id = "default" - message += "默认" - else: - return "管理默认插件需要超级用户权限!" - - if args.group: - if is_superuser: - group_id = args.group - message += f"群{args.group}" - else: - return "管理指定群插件需要超级用户权限!" - - message += unblock_plugin(group_id, *args.plugins) - return message - - -def handle_info( - args: Namespace, - group_id: str, - is_admin: bool, - is_superuser: bool, -) -> str: - - if not is_admin and not is_superuser: - return "管理插件需要超级权限!" - - return get_store_plugin_info(args.plugin) - - -def handle_install( - args: Namespace, - group_id: str, - is_admin: bool, - is_superuser: bool, -) -> str: - pass - - -def handle_update( - args: Namespace, - group_id: str, - is_admin: bool, - is_superuser: bool, -) -> str: - pass - - -def handle_uninstall( - args: Namespace, - group_id: str, - is_admin: bool, - is_superuser: bool, -) -> str: - pass diff --git a/plugins/nonebot_plugin_manager/parser.py b/plugins/nonebot_plugin_manager/parser.py deleted file mode 100644 index 71d2455d..00000000 --- a/plugins/nonebot_plugin_manager/parser.py +++ /dev/null @@ -1,60 +0,0 @@ -from nonebot.rule import ArgumentParser - -from .handle import * - -npm_parser = ArgumentParser("npm", add_help=False) -npm_parser.add_argument( - "-h", "--help", action="store_true", help="show this help message and exit" -) - -npm_subparsers = npm_parser.add_subparsers() - -list_parser = npm_subparsers.add_parser("list", help="show plugin list") -list_parser.add_argument( - "-s", "--store", action="store_true", help="show plugin store list" -) -list_parser.add_argument( - "-d", "--default", action="store_true", help="show default plugin list" -) -list_parser.add_argument("-g", "--group", action="store", help="show group plugin list") -list_parser.set_defaults(handle=handle_list) - -block_parser = npm_subparsers.add_parser("block", help="block plugin") -block_parser.add_argument("plugins", nargs="*", help="plugins you want to block") -block_parser.add_argument("-d", "--default", action="store_true", help="set default") -block_parser.add_argument("-a", "--all", action="store_true", help="select all plugin") -block_parser.add_argument("-g", "--group", action="store", help="set in group") -block_parser.set_defaults(handle=handle_block) - -unblock_parser = npm_subparsers.add_parser("unblock", help="unblock plugin") -unblock_parser.add_argument("plugins", nargs="*", help="plugins you want to unblock") -unblock_parser.add_argument("-d", "--default", action="store_true", help="set default") -unblock_parser.add_argument( - "-a", "--all", action="store_true", help="select all plugin" -) -unblock_parser.add_argument("-g", "--group", action="store", help="set in group") -unblock_parser.set_defaults(handle=handle_unblock) - -info_parser = npm_subparsers.add_parser("info", help="show plugin info") -info_parser.add_argument("plugin", help="plugins you want to know") -info_parser.set_defaults(handle=handle_info) - -install_parser = npm_subparsers.add_parser("install", help="install plugin") -install_parser.add_argument("plugins", nargs="*", help="plugins you want to install") -install_parser.add_argument("-i", "--index", action="store", help="point to a mirror") -install_parser.set_defaults(handle=handle_install) - -update_parser = npm_subparsers.add_parser("update", help="update plugin") -update_parser.add_argument("plugins", nargs="*", help="plugins you want to update") -update_parser.add_argument("-a", "--all", action="store_true", help="select all plugin") -update_parser.add_argument("-i", "--index", action="store", help="point to a mirror") -update_parser.set_defaults(handle=handle_update) - -uninstall_parser = npm_subparsers.add_parser("uninstall", help="uninstall plugin") -uninstall_parser.add_argument( - "plugins", nargs="*", help="plugins you want to uninstall" -) -uninstall_parser.add_argument( - "-a", "--all", action="store_true", help="select all plugin" -) -uninstall_parser.set_defaults(handle=handle_uninstall) diff --git a/plugins/nonebot_plugin_picsearcher/__init__.py b/plugins/nonebot_plugin_picsearcher/__init__.py deleted file mode 100644 index 4fb2ee55..00000000 --- a/plugins/nonebot_plugin_picsearcher/__init__.py +++ /dev/null @@ -1,149 +0,0 @@ -# -*- coding: utf-8 -*- -import traceback -from typing import Dict - -from aiohttp.client_exceptions import ClientError -from nonebot.plugin import on_command, on_message -from nonebot.adapters.cqhttp import Bot, MessageEvent, GroupMessageEvent -from nonebot.typing import T_State -from services.log import logger -from util.utils import get_message_text, get_message_imgs -from configs.config import MAX_FIND_IMG_COUNT - -from .ex import get_des as get_des_ex -from .iqdb import get_des as get_des_iqdb -from .saucenao import get_des as get_des_sau -from .ascii2d import get_des as get_des_asc -from .trace import get_des as get_des_trace -from .yandex import get_des as get_des_yandex - - -async def get_des(url: str, mode: str, user_id: int): - """ - :param url: 图片链接 - :param mode: 图源 - :return: - """ - if mode == "iqdb": - async for msg in get_des_iqdb(url): - yield msg - elif mode == "ex": - async for msg in get_des_ex(url): - yield msg - elif mode == "trace": - async for msg in get_des_trace(url): - yield msg - elif mode == "yandex": - async for msg in get_des_yandex(url): - yield msg - elif mode.startswith("asc"): - async for msg in get_des_asc(url, user_id): - yield msg - else: - async for msg in get_des_sau(url, user_id): - yield msg - - -setu = on_command("识图", aliases={"search"}, block=True, priority=5) - - -@setu.handle() -async def handle_first_receive(bot: Bot, event: MessageEvent, state: T_State): - msg = get_message_text(event.json()) - imgs = get_message_imgs(event.json()) - if msg in ['帮助']: - await setu.finish('示例:\n\t识图 (图片)\n\t识图asc (图片)') - if imgs: - state["setu"] = imgs[0] - if msg: - state["mod"] = msg - - -# ex/nao/trace/iqdb/ascii2d -# @setu.got("mod", prompt="从哪里查找呢? ex/nao/trace/iqdb/ascii2d") -# async def get_func(bot: Bot, event: MessageEvent, state: dict): -# pass - -@setu.args_parser -async def get_setu(bot: Bot, event: MessageEvent, state: T_State): - imgs = get_message_imgs(event.json()) - msg = get_message_text(event.json()) - if not imgs: - await setu.reject() - if msg: - state['mod'] = msg - state["setu"] = imgs[0] - - -@setu.got("setu", prompt="图呢?") -async def get_setu(bot: Bot, event: MessageEvent, state: T_State): - """ - 发现没有的时候要发问 - :return: - """ - url: str = state["setu"] - mod: str = state["mod"] if state.get("mod") else "nao" # 模式 - try: - await bot.send(event=event, message="正在处理图片") - idx = 1 - async for msg in get_des(url, mod, event.user_id): - await bot.send(event=event, message=msg) - if idx == MAX_FIND_IMG_COUNT: - break - idx += 1 - logger.info(f"(USER {event.user_id}, GROUP " - f"{event.group_id if event.message_type != 'private' else 'private'}) 识图:{url}") - # image_data: List[Tuple] = await get_pic_from_url(url) - # await setu.finish("hso") - except IndexError: - # await bot.send(event, traceback.format_exc()) - await setu.finish("参数错误") - except ClientError: - await setu.finish("连接失败") - - -pic_map: Dict[str, str] = {} # 保存这个群的其阿金一张色图 {"123456":http://xxx"} - - -async def check_pic(bot: Bot, event: MessageEvent, state: T_State) -> bool: - if isinstance(event, MessageEvent): - for msg in event.message: - if msg.type == "image": - url: str = msg.data["url"] - state["url"] = url - return True - return False - - -notice_pic = on_message(check_pic, block=False, priority=1) - - -@notice_pic.handle() -async def handle_pic(bot: Bot, event: GroupMessageEvent, state: T_State): - try: - group_id: str = str(event.group_id) - pic_map.update({group_id: state["url"]}) - except AttributeError: - pass - - -previous = on_command("上一张图是什么", aliases={"上一张", "这是什么"}) - - -@previous.handle() -async def handle_previous(bot: Bot, event: GroupMessageEvent, state: T_State): - await bot.send(event=event, message="processing...") - try: - url: str = pic_map[str(event.group_id)] - idx = 1 - async for msg in get_des(url, "nao", event.user_id): - await bot.send(event=event, message=msg) - if idx == MAX_FIND_IMG_COUNT: - break - idx += 1 - except IndexError: - await previous.finish("参数错误") - except ClientError: - await previous.finish("连接错误") - except KeyError: - await previous.finish("没有图啊QAQ") diff --git a/plugins/nonebot_plugin_picsearcher/__pycache__/__init__.cpython-39.pyc b/plugins/nonebot_plugin_picsearcher/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 44e61484..00000000 Binary files a/plugins/nonebot_plugin_picsearcher/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/nonebot_plugin_picsearcher/__pycache__/ascii2d.cpython-39.pyc b/plugins/nonebot_plugin_picsearcher/__pycache__/ascii2d.cpython-39.pyc deleted file mode 100644 index d4e82141..00000000 Binary files a/plugins/nonebot_plugin_picsearcher/__pycache__/ascii2d.cpython-39.pyc and /dev/null differ diff --git a/plugins/nonebot_plugin_picsearcher/__pycache__/ex.cpython-39.pyc b/plugins/nonebot_plugin_picsearcher/__pycache__/ex.cpython-39.pyc deleted file mode 100644 index 0fda775b..00000000 Binary files a/plugins/nonebot_plugin_picsearcher/__pycache__/ex.cpython-39.pyc and /dev/null differ diff --git a/plugins/nonebot_plugin_picsearcher/__pycache__/formdata.cpython-39.pyc b/plugins/nonebot_plugin_picsearcher/__pycache__/formdata.cpython-39.pyc deleted file mode 100644 index 42824c48..00000000 Binary files a/plugins/nonebot_plugin_picsearcher/__pycache__/formdata.cpython-39.pyc and /dev/null differ diff --git a/plugins/nonebot_plugin_picsearcher/__pycache__/iqdb.cpython-39.pyc b/plugins/nonebot_plugin_picsearcher/__pycache__/iqdb.cpython-39.pyc deleted file mode 100644 index 76b42d3e..00000000 Binary files a/plugins/nonebot_plugin_picsearcher/__pycache__/iqdb.cpython-39.pyc and /dev/null differ diff --git a/plugins/nonebot_plugin_picsearcher/__pycache__/saucenao.cpython-39.pyc b/plugins/nonebot_plugin_picsearcher/__pycache__/saucenao.cpython-39.pyc deleted file mode 100644 index 838941ff..00000000 Binary files a/plugins/nonebot_plugin_picsearcher/__pycache__/saucenao.cpython-39.pyc and /dev/null differ diff --git a/plugins/nonebot_plugin_picsearcher/__pycache__/trace.cpython-39.pyc b/plugins/nonebot_plugin_picsearcher/__pycache__/trace.cpython-39.pyc deleted file mode 100644 index 2b5c289a..00000000 Binary files a/plugins/nonebot_plugin_picsearcher/__pycache__/trace.cpython-39.pyc and /dev/null differ diff --git a/plugins/nonebot_plugin_picsearcher/__pycache__/yandex.cpython-39.pyc b/plugins/nonebot_plugin_picsearcher/__pycache__/yandex.cpython-39.pyc deleted file mode 100644 index f2797bf1..00000000 Binary files a/plugins/nonebot_plugin_picsearcher/__pycache__/yandex.cpython-39.pyc and /dev/null differ diff --git a/plugins/nonebot_plugin_picsearcher/ascii2d.py b/plugins/nonebot_plugin_picsearcher/ascii2d.py deleted file mode 100644 index 941e9d0e..00000000 --- a/plugins/nonebot_plugin_picsearcher/ascii2d.py +++ /dev/null @@ -1,63 +0,0 @@ -# -*- coding: utf-8 -*- -from typing import List, Tuple -from urllib.parse import urljoin -import aiofiles -from util.utils import get_local_proxy -from util.user_agent import get_user_agent -from configs.path_config import IMAGE_PATH -from asyncio.exceptions import TimeoutError -from util.init_result import image - -from lxml.html import fromstring -import aiohttp - - -def parse_html(html: str): - selector = fromstring(html) - for tag in selector.xpath('//div[@class="container"]/div[@class="row"]/div/div[@class="row item-box"]')[1:5]: - if pic_url := tag.xpath('./div/img[@loading="lazy"]/@src'): # 缩略图url - pic_url = urljoin("https://ascii2d.net/", pic_url[0]) - if description := tag.xpath('./div/div/h6/a[1]/text()'): # 名字 - description = description[0] - if author := tag.xpath('./div/div/h6/a[2]/text()'): # 作者 - author = author[0] - if origin_url := tag.xpath('./div/div/h6/a[1]/@href'): # 原图地址 - origin_url = origin_url[0] - if author_url := tag.xpath('./div/div/h6/a[2]/@href'): # 作者地址 - author_url = author_url[0] - yield pic_url, description, author, origin_url, author_url - - pass - - -async def get_pic_from_url(url: str): - real_url = "https://ascii2d.net/search/url/" + url - async with aiohttp.ClientSession() as session: - async with session.get(real_url) as resp: - html: str = await resp.text() - return [i for i in parse_html(html)] - - -async def get_des(url: str, user_id): - image_data: List[Tuple] = await get_pic_from_url(url) - if not image_data: - msg: str = "找不到高相似度的" - yield msg - return - for pic in image_data: - msg = await download_img(pic[0], user_id) + "\n" - for i in pic[1:]: - msg = msg + f"{i}\n" - yield msg - - -async def download_img(url, user_id): - try: - async with aiohttp.ClientSession(headers=get_user_agent()) as session: - async with session.get(url, proxy=get_local_proxy(), timeout=7) as response: - async with aiofiles.open(IMAGE_PATH + f'temp/{user_id}_pic_find.png', 'wb') as f: - await f.write(await response.read()) - return image(f'{user_id}_pic_find.png', 'temp') - except TimeoutError: - return image(url) - diff --git a/plugins/nonebot_plugin_picsearcher/ex.py b/plugins/nonebot_plugin_picsearcher/ex.py deleted file mode 100644 index 172ac391..00000000 --- a/plugins/nonebot_plugin_picsearcher/ex.py +++ /dev/null @@ -1,107 +0,0 @@ -# -*- coding: utf-8 -*- -from base64 import b64encode -from typing import List, Tuple -import io - -from lxml.html import fromstring -import aiohttp -import nonebot -from aiohttp.client_exceptions import InvalidURL -from nonebot.adapters.cqhttp import MessageSegment - -from .formdata import FormData - -driver = nonebot.get_driver() -cookie: str = driver.config.ex_cookie -proxy: str = driver.config.proxy -target: str = "https://exhentai.org/upload/image_lookup.php" - -headers = { - 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', - 'Accept-Encoding': 'gzip, deflate', - 'Accept-Language': 'zh-CN,zh;q=0.9', - 'Cache-Control': 'max-age=0', - 'Connection': 'keep-alive', - 'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundaryB0NrMSYMfjY5r0l1', - 'Host': 'exhentai.org', - 'Origin': 'https://exhentai.org', - 'Referer': 'https://exhentai.org/?filesearch=1', - 'Sec-Fetch-Dest': 'document', - 'Sec-Fetch-Mode': 'navigate', - 'Sec-Fetch-Site': 'same-origin', - 'Sec-Fetch-User': '?1', - 'Upgrade-Insecure-Requests': '1', - 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36'} - -if cookie: - headers['Cookie'] = cookie -else: - headers['Host'] = 'e-hentai.org' - headers['Origin'] = 'https://e-hentai.org' - headers['Referer'] = 'https://e-hentai.org/?filesearch=1' - target: str = "https://e-hentai.org/upload/image_lookup.php" - - -def parse_html(html: str): - """ - 解析exhentai返回的数据 - :param html: - :return: - """ - selector = fromstring(html) - hrefs = selector.xpath('//td[@class="gl3c glname"]/a/@href') - names = selector.xpath('//td[@class="gl3c glname"]/a/div[1]/text()') - pics = selector.xpath('//tr/td[@class="gl2c"]/div[@class="glthumb"]/div[1]/img/@src') # 缩略图 - for name, href, pic in zip(names, hrefs, pics): - yield name, href, pic - - -async def get_pic_from_url(url: str): - """ - 从接受到的picurl获取图片信息 - :param url: - :return: - """ - async with aiohttp.ClientSession() as session: - async with session.get(url) as resp: - content = io.BytesIO(await resp.read()) - # Content_Length = resp.content_length - data = FormData(boundary="----WebKitFormBoundaryB0NrMSYMfjY5r0l1") - data.add_field(name="sfile", value=content, content_type="image/jpeg", - filename="0.jpg") - data.add_field(name="f_sfile", value="search") - data.add_field(name="fs_similar", value="on") - async with session.post(target, data=data, headers=headers, proxy=proxy) as res: - html = await res.text() - return [i for i in parse_html(html)] - - -async def get_content_from_url(url: str): - """ - 从url 获得b64 encode - :param url: - :return: - """ - try: - async with aiohttp.ClientSession() as session: - async with session.get(url, headers=headers) as resp: - return "base64://" + b64encode(await resp.read()).decode() - except aiohttp.client_exceptions.InvalidURL: - return url - - -async def get_des(url: str): - """ - 迭代要发送的信息 - :param url: - :return: - """ - image_data: List[Tuple] = await get_pic_from_url(url) - if not image_data: - msg: str = "找不到高相似度的" - yield msg - return - for name, href, pic_url in image_data: - content = await get_content_from_url(pic_url) - msg = MessageSegment.image(file=content) + f"\n本子名称:{name}\n" + f"链接{href}\n" - yield msg diff --git a/plugins/nonebot_plugin_picsearcher/formdata.py b/plugins/nonebot_plugin_picsearcher/formdata.py deleted file mode 100644 index f70f040e..00000000 --- a/plugins/nonebot_plugin_picsearcher/formdata.py +++ /dev/null @@ -1,27 +0,0 @@ -# -*- coding: utf-8 -*- -from typing import Any, Iterable, List, Optional - -from aiohttp import FormData as _FormData -import aiohttp.multipart as multipart - - -class FormData(_FormData): - def __init__( - self, - fields: Iterable[Any] = (), - quote_fields: bool = True, - charset: Optional[str] = None, - boundary: Optional[str] = None - ) -> None: - self._writer = multipart.MultipartWriter("form-data", boundary=boundary) - self._fields = [] # type: List[Any] - self._is_multipart = False - self._is_processed = False - self._quote_fields = quote_fields - self._charset = charset - - if isinstance(fields, dict): - fields = list(fields.items()) - elif not isinstance(fields, (list, tuple)): - fields = (fields,) - self.add_fields(*fields) diff --git a/plugins/nonebot_plugin_picsearcher/iqdb.py b/plugins/nonebot_plugin_picsearcher/iqdb.py deleted file mode 100644 index 60b9f934..00000000 --- a/plugins/nonebot_plugin_picsearcher/iqdb.py +++ /dev/null @@ -1,79 +0,0 @@ -# -*- coding: utf-8 -*- -import asyncio -from typing import List, Tuple -import io - -from urllib.parse import urljoin -from lxml.html import fromstring -import aiohttp -from nonebot.adapters.cqhttp import MessageSegment - -from .formdata import FormData - -headers = { - 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', - 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'zh-CN,zh;q=0.9', 'Cache-Control': 'max-age=0', - 'Connection': 'keep-alive', - 'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundaryuwjSiBcpPag4k159', - 'Cookie': 'Hm_lvt_765ecde8c11b85f1ac5f168fa6e6821f=1602471368; Hm_lpvt_765ecde8c11b85f1ac5f168fa6e6821f=1602472300', - 'Host': 'iqdb.org', 'Origin': 'http://iqdb.org', 'Referer': 'http://iqdb.org/', 'Upgrade-Insecure-Requests': '1', - 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36'} - - -def parse_html(html: str): - selector = fromstring(html) - for tag in selector.xpath('//div[@id="pages"]/div[position()>1]/table'): - # 第一个是bestmatch - if pic_url := tag.xpath('./tr[2]/td/a/img/@src'): - pic_url = urljoin("http://iqdb.org/", pic_url[0]) # 缩略图 - else: - pic_url = "没有最相似的" - similarity = tag.xpath('./tr[last()]/td/text()')[0] # 相似度 - href: List[str] = tag.xpath('./tr/td/a/@href') # 第一个href - href.extend(tag.xpath('./tr/td/span/a/@href')) # 第二个 可能是空 - href = list(map(lambda x: "https:" + x if not x.startswith("https") else x, href)) - yield pic_url, similarity, href - - pass - - -async def get_pic_from_url(url: str): - """ - 返回信息元祖 - :param url: - :return: - """ - async with aiohttp.ClientSession() as session: - async with session.get(url) as resp: - content = io.BytesIO(await resp.read()) - data = FormData(boundary="----WebKitFormBoundaryuwjSiBcpPag4k159") - data.add_field(name="MAX_FILE_SIZE", value="") - for i in range(1, 7): - data.add_field(name="service[]", value=str(i)) - data.add_field(name="service[]", value="11") - data.add_field(name="service[]", value="13") - data.add_field(name="file", value=content, content_type="application/octet-stream", filename="0.jpg") - data.add_field(name="url", value="") - async with session.post("http://iqdb.org/", data=data, headers=headers) as res: - html = await res.text() - return [i for i in parse_html(html)] - pass - - -async def get_des(url: str): - """ - 返回详细简介 cq码转义 - :param url: - :return: - """ - image_data: List[Tuple] = await get_pic_from_url(url) - if not image_data: - msg: str = "找不到高相似度的" - yield msg - return - for pic in image_data: - msg = MessageSegment.image(file=pic[0]) + f"\n{pic[1]}\n" - for i in pic[2]: - msg = msg + f"{i}\n" - yield msg - diff --git a/plugins/nonebot_plugin_picsearcher/saucenao.py b/plugins/nonebot_plugin_picsearcher/saucenao.py deleted file mode 100644 index 14987b83..00000000 --- a/plugins/nonebot_plugin_picsearcher/saucenao.py +++ /dev/null @@ -1,116 +0,0 @@ -# -*- coding: utf-8 -*- -import io -from typing import List, Tuple, Union -import aiofiles -from util.utils import get_local_proxy -from util.user_agent import get_user_agent -from configs.path_config import IMAGE_PATH -from asyncio.exceptions import TimeoutError -from util.init_result import image - -import aiohttp -from lxml.html import fromstring -from nonebot.adapters.cqhttp import Message - -from .formdata import FormData - -header = { - 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', - 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'zh-CN,zh;q=0.9', - 'Cache-Control': 'max-age=0', - "Content-Type": "multipart/form-data; boundary=----WebKitFormBoundaryPpuR3EZ1Ap2pXv8W", - 'Connection': 'keep-alive', - 'Host': 'saucenao.com', 'Origin': 'https://saucenao.com', 'Referer': 'https://saucenao.com/index.php', - 'Sec-Fetch-Dest': 'document', 'Sec-Fetch-Mode': 'navigate', 'Sec-Fetch-Site': 'same-origin', 'Sec-Fetch-User': '?1', - 'Upgrade-Insecure-Requests': '1', - 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36'} - - -def parse_html(html: str): - """ - 解析nao返回的html - :param html: - :return: - """ - selector = fromstring(html) - for tag in selector.xpath('//div[@class="result"]/table'): - pic_url = tag.xpath('./tr/td/div/a/img/@src') - if pic_url: - pic_url = pic_url[0] - else: - pic_url = None # 相似度 - xsd: List[str] = tag.xpath( - './tr/td[@class="resulttablecontent"]/div[@class="resultmatchinfo"]/div[@class="resultsimilarityinfo"]/text()') - if xsd: - xsd = xsd[0] - else: - xsd = "没有写" # 相似度 - title: List[str] = tag.xpath( - './tr/td[@class="resulttablecontent"]/div[@class="resultcontent"]/div[@class="resulttitle"]/strong/text()') - if title: - title = title[0] - else: - title = "没有写" # 标题 - # pixiv id - pixiv_id: List[str] = tag.xpath( - './tr/td[@class="resulttablecontent"]/div[@class="resultcontent"]/div[@class="resultcontentcolumn"]/a[1]/@href') - if pixiv_id: - pixiv_id = pixiv_id[0] - else: - pixiv_id = "没有说" - member: List[str] = tag.xpath( - './tr/td[@class="resulttablecontent"]/div[@class="resultcontent"]/div[@class="resultcontentcolumn"]/a[2]/@href') - if member: - member = member[0] - else: - member = "没有说" - yield pic_url, xsd, title, pixiv_id, member - - -async def get_pic_from_url(url: str): - """ - 从url搜图 - :param url: - :return: - """ - async with aiohttp.ClientSession() as session: - async with session.get(url) as resp: - content = io.BytesIO(await resp.read()) - data = FormData(boundary="----WebKitFormBoundaryPpuR3EZ1Ap2pXv8W") - data.add_field(name="file", value=content, content_type="image/jpeg", - filename="blob") - async with session.post("https://saucenao.com/search.php", data=data, headers=header) as res: - html = await res.text() - image_data = [each for each in parse_html(html)] - return image_data - - -async def get_des(url: str, user_id: int): - image_data: List[Tuple] = await get_pic_from_url(url) - if not image_data: - msg: Union[str, Message] = "找不到高相似度的" - yield msg - return - for pic in image_data: - # print(pic) - msg = await download_img(pic[0], user_id) \ - + f"\n相似度:{pic[1]}" \ - f"\n标题:{pic[2] if (str(pic[2]).strip() != 'Creator:' and len(str(pic[2]).split('-')) < 3) else '未知'}" \ - f"\nPID:{pic[3]}" \ - f"\nmember:{pic[4]}\n" - yield msg - pass - - -async def download_img(url, user_id): - try: - async with aiohttp.ClientSession(headers=get_user_agent()) as session: - async with session.get(url, proxy=get_local_proxy(), timeout=7) as response: - async with aiofiles.open(IMAGE_PATH + f'temp/{user_id}_pic_find.png', 'wb') as f: - await f.write(await response.read()) - return image(f'{user_id}_pic_find.png', 'temp') - except TimeoutError: - return image(url) - - - diff --git a/plugins/nonebot_plugin_picsearcher/trace.py b/plugins/nonebot_plugin_picsearcher/trace.py deleted file mode 100644 index 0c28d2f2..00000000 --- a/plugins/nonebot_plugin_picsearcher/trace.py +++ /dev/null @@ -1,89 +0,0 @@ -# -*- coding: utf-8 -*- -import io -from copy import deepcopy - -from base64 import b64encode -from typing import List, Tuple - -import aiohttp -from nonebot.adapters.cqhttp import MessageSegment - -header = {':authority': 'api.trace.moe', - 'accept': '*/*', - 'accept-encoding': 'gzip, deflate, br', - 'accept-language': 'zh-CN,zh;q=0.9', - 'content-type': 'multipart/form-data; boundary=----WebKitFormBoundary9cyjY8YBBN8SGdG4', - 'origin': 'https://trace.moe', - 'sec-fetch-dest': 'empty', 'sec-fetch-mode': 'cors', 'sec-fetch-site': 'same-site', - 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) ' - 'Chrome/84.0.4147.105 Safari/537.36'} - - -async def parse_json(session: aiohttp.ClientSession, data: dict): - count = 0 - for i in data["result"]: - title: dict = i["anilist"]["title"] - similarity = i["similarity"] - from_ = i["from"] - to = i["to"] - file = i["filename"] # 名字 - is_adult = i["anilist"]["isAdult"] - episode = i["episode"] # 集 - header_new = deepcopy(header) - del header_new["content-type"] - header_new[":method"] = 'GET' - header_new["accept"] = "image/webp,image/apng,image/*,*/*;q=0.8" - header_new["sec-fetch-dest"] = "image" - header_new["sec-fetch-mode"] = "no-cors" - async with session.get(i["image"], headers=header_new) as resp: - pic = "base64://" + b64encode(await resp.read()).decode() - yield pic, similarity, file, is_adult, from_, to, title, episode - count += 1 - if count > 4: - break - - -# POST https://api.trace.moe/search?cutBorders=1&anilistID= -async def get_pic_from_url(url: str): - """ - 从url搜图 - :param url: - :return: - """ - async with aiohttp.ClientSession() as session: - async with session.get(url) as resp: - content = io.BytesIO(await resp.read()) - # with open("F:\elu.PNG", "rb") as f: - # content = io.BytesIO(f.read()) - data = aiohttp.FormData(boundary="----WebKitFormBoundary9cyjY8YBBN8SGdG4") - data.add_field(name="image", value=content, content_type="image/jpeg", - filename="blob") - # data.add_field(name="filter", value="") - # data.add_field(name="trial", value="0") - async with session.post("https://api.trace.moe/search?cutBorders=1&anilistID=", data=data, - headers=header) as res: - data: dict = await res.json() - image_data = [each async for each in parse_json(session, data)] - return image_data - - -async def get_des(url: str): - image_data: List[Tuple] = await get_pic_from_url(url) - if not image_data: - msg: str = "找不到高相似度的" - yield msg - return - for pic in image_data: - msg = MessageSegment.image( - file=pic[ - 0]) + f"\n相似度:{pic[1]}%\n标题:{pic[6]['native'] + ' ' + pic[6]['chinese']}\n第{pic[7]}集\nR18:{pic[3]}\n开始时间:{pic[4]}s\n结束时间{pic[5]}s" - yield msg - pass - - -if __name__ == "__main__": - import asyncio - - data = asyncio.run(get_pic_from_url( - "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1606681978562&di=6d6c90aef5ff1f9f8915bbc2e18e3c98&imgtype=0&src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fblog%2F202011%2F15%2F20201115190356_c5b95.thumb.1000_0.jpg")) - pass diff --git a/plugins/nonebot_plugin_picsearcher/yandex.py b/plugins/nonebot_plugin_picsearcher/yandex.py deleted file mode 100644 index 0632e442..00000000 --- a/plugins/nonebot_plugin_picsearcher/yandex.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -from typing import List, Tuple - -import nonebot -from nonebot.adapters.cqhttp import MessageSegment -from lxml.html import fromstring -import aiohttp - -""" -http://yandex.com/clck/jsredir?from=yandex.com%3Bimages%2Fsearch%3Bimages%3B%3B&text=&etext=9185.K4iyzsNBG9xrJrSJCUTF4i-XPMAfmBQYR_Igss1ESRc.65568e796f3375fae39da91273ae8a1a82410929&uuid=&state=iric5OQ0sS2054x1_o8yG9mmGMT8WeQxqpuwa4Ft4KVzd9aE_Y4Dfw,,&data=eEwyM2lDYU9Gd1VROE1ZMXhZYkJTYW5fZC1TWjIzaFh5TmR1Z09fQm5DdDB3bFJSSUpVdUxfZmUzcVhfaXhTN1BCU2dINGxmdkY4NFVNcHYyUmw0emFKT2pnOWJoVmlPVzAzX1FIbWh6aXVFV3F0YWFaMGdxeGFtY2dxTzFZZl9VY1huZmlLaGVGOFZleUthZXBlM1pxUGM2elVDLXdvZEo3OGJwdVFqYmVkTDJxWElHSzFZR2NVQUhVcTdzelJwSXlrTjhlS0txdHpYY1RMMHRLOU5HSTYtT0VDb0hpdll6YjVYRXNVcUhCRFJaeDExNTQwZlhMdjh4M2YtTVFUbVJ5ZzBxMTVJcG9DNW51UWhvRzE0WjlFS19uS0VUZWhNRGxOZWlPUkFlRUUs&sign=7ba9ee25d3716868ec8464fb766c9e25&keyno=IMGS_0&b64e=2&l10n=en -""" - -driver = nonebot.get_driver() -proxy: str = driver.config.proxy - - -def parse_html(html: str): - selector = fromstring(html) - for item in selector.xpath('//li[@class="other-sites__item"]'): - pic_url = item.xpath('./a[@class="other-sites__preview-link"]/img/@src')[0].lstrip("//") # 图床 - des = item.xpath( - './div[@class="other-sites__snippet"]/div[@class="other-sites__snippet-title"]/a/text()')[0] # 简介 - url = item.xpath( - './div[@class="other-sites__snippet"]/div[@class="other-sites__snippet-site"]/a/@href')[0] # 链接 - yield pic_url, des, url - - -async def get_pic_from_url(url: str): - real_url = f"https://yandex.com/images/search?rpt=imageview&url={url}" - async with aiohttp.ClientSession() as session: - async with session.get(real_url, proxy=proxy) as resp: - html: str = await resp.text() - return [i for i in parse_html(html)] - - -async def get_des(url: str): - image_data: List[Tuple] = await get_pic_from_url(url) - if not image_data: - msg: str = "找不到高相似度的" - yield msg - return - for pic in image_data: - msg = MessageSegment.image(file=pic[0]) + "\n" - for i in pic[1:]: - msg = msg + f"{i}\n" - yield msg - - -if __name__ == "__main__": - with open("yandex.html", "r", encoding="utf-8") as f: - data = f.read() - for item in parse_html(data): - print(item) diff --git a/plugins/one_friend/__init__.py b/plugins/one_friend/__init__.py deleted file mode 100644 index 9be83244..00000000 --- a/plugins/one_friend/__init__.py +++ /dev/null @@ -1,68 +0,0 @@ -import json -import os -import aiohttp -from util.user_agent import get_user_agent -from io import BytesIO -from random import choice -from PIL import Image, ImageDraw, ImageFont -from nonebot import on_regex -from nonebot.typing import T_State -from nonebot.adapters.cqhttp import Bot, GroupMessageEvent -from util.utils import get_message_text, get_local_proxy -from util.img_utils import pic2b64 -from configs.path_config import TTF_PATH -import re -from nonebot.adapters.cqhttp import MessageSegment - -one_friend = on_regex('^我.*?朋友.*?(想问问|说|让我问问|想问|让我问|想知道|让我帮他问问|让我' - '帮他问|让我帮忙问|让我帮忙问问|问).*', priority=5, block=True) - - -async def get_pic(qq): - url = f'http://q1.qlogo.cn/g?b=qq&nk={qq}&s=100' - async with aiohttp.ClientSession(headers=get_user_agent()) as session: - async with session.get(url, proxy=get_local_proxy(), timeout=5) as response: - return await response.read() - - -@one_friend.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - arr = [] - member_list = await bot.get_group_member_list(self_id=event.self_id, group_id=event.group_id) - for member in member_list: - arr.append(member['user_id']) - msg = get_message_text(event.json()) - msg = re.search(r'^我.*?朋友.*?' - r'(想问问|说|让我问问|想问|让我问|想知道|让我帮他问问|让我帮他问|让我帮忙问|让我帮忙问问|问)(.*)', - msg) - msg = msg.group(2) - if not msg: - msg = '都不知道问什么' - msg = msg.replace('他', '我').replace('她', '我') - image = Image.open(BytesIO(await get_pic(choice(arr)))) - img_origin = Image.new('RGBA', (100, 100), (255, 255, 255)) - scale = 3 - # 使用新的半径构建alpha层 - r = 100 * scale - alpha_layer = Image.new('L', (r, r), 0) - draw = ImageDraw.Draw(alpha_layer) - draw.ellipse((0, 0, r, r), fill=255) - # 使用ANTIALIAS采样器缩小图像 - alpha_layer = alpha_layer.resize((100, 100), Image.ANTIALIAS) - img_origin.paste(image, (0, 0), alpha_layer) - - # 创建Font对象: - font = ImageFont.truetype(os.path.join(os.path.dirname(__file__), TTF_PATH + 'yz.ttf'), 30) - font2 = ImageFont.truetype(os.path.join(os.path.dirname(__file__), TTF_PATH + 'yz.ttf'), 25) - - # 创建Draw对象: - image_text = Image.new('RGB', (450, 150), (255, 255, 255)) - draw = ImageDraw.Draw(image_text) - draw.text((0, 0), '朋友', fill=(0, 0, 0), font=font) - draw.text((0, 40), msg, fill=(125, 125, 125), font=font2) - - image_back = Image.new('RGB', (700, 150), (255, 255, 255)) - image_back.paste(img_origin, (25, 25)) - image_back.paste(image_text, (150, 40)) - - await one_friend.send(MessageSegment.image(pic2b64(image_back))) diff --git a/plugins/one_friend/__pycache__/__init__.cpython-38.pyc b/plugins/one_friend/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 4f995113..00000000 Binary files a/plugins/one_friend/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/one_friend/__pycache__/__init__.cpython-39.pyc b/plugins/one_friend/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index e8a92ca1..00000000 Binary files a/plugins/one_friend/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/open_cases/__init__.py b/plugins/open_cases/__init__.py deleted file mode 100644 index ed963e5a..00000000 --- a/plugins/open_cases/__init__.py +++ /dev/null @@ -1,181 +0,0 @@ -from nonebot import on_command -from util.utils import FreqLimiter, scheduler, get_message_text, is_number -from nonebot.adapters.cqhttp.permission import GROUP -from nonebot.typing import T_State -from nonebot.adapters.cqhttp import Bot, GroupMessageEvent, MessageEvent -from nonebot.permission import SUPERUSER -import random -from nonebot.plugin import MatcherGroup -import re -from .open_cases_c import open_case, total_open_statistics, group_statistics, my_knifes_name, open_shilian_case -from .utils import util_get_buff_price, util_get_buff_img, update_count_daily - -__plugin_name__ = '开箱' -__plugin_usage__ = ( - '用法:\n' - '看看你的人品罢了\n' - '目前只支持\n\t' - '1.狂牙大行动武器箱\n\t' - '2.突围大行动武器箱\n\t' - '3.命悬一线武器箱\n\t' - '4.裂空武器箱\n\t' - '5.光谱武器箱\n\t' - '示例:小真寻开箱 突围大行动(不输入指定武器箱则随机)\n' - '示例:我的开箱(开箱统计)\n' - '示例:群开箱统计\n' - '示例:我的金色' -) - -_flmt = FreqLimiter(3) - -cases_name = ['狂牙大行动', '突围大行动', '命悬一线', '裂空'] - -cases_matcher_group = MatcherGroup(priority=5, permission=GROUP, block=True) - - -k_open_case = cases_matcher_group.on_command("开箱") - - -@k_open_case.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - if str(event.get_message()).strip() in ['帮助']: - await k_open_case.finish(__plugin_usage__) - if not _flmt.check(event.user_id): - await k_open_case.finish('着什么急啊,慢慢来!', at_sender=True) - _flmt.start_cd(event.user_id) - case_name = get_message_text(event.json()) - if case_name: - result = await open_case(event.user_id, event.group_id, case_name) - else: - result = await open_case(event.user_id, event.group_id, random.choice(cases_name)) - await k_open_case.finish(result, at_sender=True) - - -total_case_data = cases_matcher_group.on_command("我的开箱", aliases={'开箱统计', '开箱查询', '查询开箱'}) - - -@total_case_data.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - await total_case_data.finish( - await total_open_statistics(event.user_id, event.group_id), - at_sender=True, - ) - - -group_open_case_statistics = cases_matcher_group.on_command("群开箱统计") - - -@group_open_case_statistics.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - await group_open_case_statistics.finish(await group_statistics(event.group_id)) - - -my_kinfes = on_command("我的金色", priority=1, permission=GROUP, block=True) - - -@my_kinfes.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - await my_kinfes.finish(await my_knifes_name(event.user_id, event.group_id), at_sender=True) - - -open_shilian = cases_matcher_group.on_regex(".*连开箱") - - -@open_shilian.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - # if not _flmt.check(event.user_id): - # await k_open_case.finish('着什么急啊,慢慢来!', at_sender=True) - _flmt.start_cd(event.user_id) - msg = get_message_text(event.json()) - rs = re.search(r'(.*)连开箱(.*)', msg) - if rs: - num = rs.group(1).strip() - if is_number(num) or num_dict.get(num): - try: - num = num_dict[num] - except KeyError: - num = int(num) - if num > 30: - await open_shilian.finish('开箱次数不要超过30啊笨蛋!', at_sender=True) - else: - await open_shilian.finish('必须要是数字切不要超过30啊笨蛋!中文也可!', at_sender=True) - case_name = rs.group(2).strip() - if case_name.find('武器箱') != -1: - case_name = case_name.replace('武器箱', '').strip() - if not case_name: - case_name = random.choice(cases_name) - elif case_name not in cases_name: - await open_shilian.finish('武器箱未收录!', at_sender=True) - await open_shilian.finish(await open_shilian_case(event.user_id, event.group_id, case_name, num), at_sender=True) - # await open_shilian.send("嘟嘟嘟...开箱中...") - # num = 10 - # if str(state["_prefix"]["raw_command"]).find('十') != -1: - # num = 10 - # elif str(state["_prefix"]["raw_command"]).find('五') != -1: - # num = 5 - # if case_name: - # await open_shilian.finish(await open_shilian_case(event.user_id, event.group_id, case_name, num), at_sender=True) - # else: - # await open_shilian.finish(await open_shilian_case(event.user_id, event.group_id, random.choice(cases_name), num), - # at_sender=True) - - -num_dict = { - '一': 1, - '二': 2, - '三': 3, - '四': 4, - '五': 5, - '六': 6, - '七': 7, - '八': 8, - '九': 9, - '十': 10, - '十一': 11, - '十二': 12, - '十三': 13, - '十四': 14, - '十五': 15, - '十六': 16, - '十七': 17, - '十八': 18, - '十九': 19, - '二十': 20, - '二十一': 21, - '二十二': 22, - '二十三': 23, - '二十四': 24, - '二十五': 25, - '二十六': 26, - '二十七': 27, - '二十八': 28, - '二十九': 29, - '三十': 30 -} - - -update_price = on_command("更新价格", priority=1, permission=SUPERUSER, block=True) - - -@update_price.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - await update_price.send(await util_get_buff_price(str(event.get_message()))) - - -update_img = on_command("更新图片", priority=1, permission=SUPERUSER, block=True) - - -@update_img.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - await update_img.send(await util_get_buff_img(str(event.get_message()))) - - -# 重置开箱 -@scheduler.scheduled_job( - 'cron', - hour=0, - minute=1, -) -async def _(): - await update_count_daily() - diff --git a/plugins/open_cases/__pycache__/__init__.cpython-38.pyc b/plugins/open_cases/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 39862d4d..00000000 Binary files a/plugins/open_cases/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/open_cases/__pycache__/__init__.cpython-39.pyc b/plugins/open_cases/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 88e0a41d..00000000 Binary files a/plugins/open_cases/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/open_cases/__pycache__/config.cpython-38.pyc b/plugins/open_cases/__pycache__/config.cpython-38.pyc deleted file mode 100644 index fe783ec3..00000000 Binary files a/plugins/open_cases/__pycache__/config.cpython-38.pyc and /dev/null differ diff --git a/plugins/open_cases/__pycache__/config.cpython-39.pyc b/plugins/open_cases/__pycache__/config.cpython-39.pyc deleted file mode 100644 index 2c42809d..00000000 Binary files a/plugins/open_cases/__pycache__/config.cpython-39.pyc and /dev/null differ diff --git a/plugins/open_cases/__pycache__/open_cases_c.cpython-38.pyc b/plugins/open_cases/__pycache__/open_cases_c.cpython-38.pyc deleted file mode 100644 index 801f85d5..00000000 Binary files a/plugins/open_cases/__pycache__/open_cases_c.cpython-38.pyc and /dev/null differ diff --git a/plugins/open_cases/__pycache__/open_cases_c.cpython-39.pyc b/plugins/open_cases/__pycache__/open_cases_c.cpython-39.pyc deleted file mode 100644 index f57de18c..00000000 Binary files a/plugins/open_cases/__pycache__/open_cases_c.cpython-39.pyc and /dev/null differ diff --git a/plugins/open_cases/__pycache__/utils.cpython-38.pyc b/plugins/open_cases/__pycache__/utils.cpython-38.pyc deleted file mode 100644 index ac76c69e..00000000 Binary files a/plugins/open_cases/__pycache__/utils.cpython-38.pyc and /dev/null differ diff --git a/plugins/open_cases/__pycache__/utils.cpython-39.pyc b/plugins/open_cases/__pycache__/utils.cpython-39.pyc deleted file mode 100644 index bf1fefef..00000000 Binary files a/plugins/open_cases/__pycache__/utils.cpython-39.pyc and /dev/null differ diff --git a/plugins/open_cases/config.py b/plugins/open_cases/config.py deleted file mode 100644 index fd118ff7..00000000 --- a/plugins/open_cases/config.py +++ /dev/null @@ -1,180 +0,0 @@ -import random -import pypinyin - -BLUE = 0.7981 -BLUE_ST = 0.0699 -PURPLE = 0.1626 -PURPLE_ST = 0.0164 -PINK = 0.0315 -PINK_ST = 0.0048 -RED = 0.0057 -RED_ST = 0.00021 -KNIFE = 0.0021 -KNIFE_ST = 0.000041 - -# 崭新 -FACTORY_NEW_S = 0 -FACTORY_NEW_E = 0.0699999 -# 略磨 -MINIMAL_WEAR_S = 0.07 -MINIMAL_WEAR_E = 0.14999 -# 久经 -FIELD_TESTED_S = 0.15 -FIELD_TESTED_E = 0.37999 -# 破损 -WELL_WORN_S = 0.38 -WELL_WORN_E = 0.44999 -# 战痕 -BATTLE_SCARED_S = 0.45 -BATTLE_SCARED_E = 0.99999 - -# 狂牙大行动 -KUANGYADAXINGDONG_CASE_KNIFE = ['摩托手套 | 第三特种兵连', '狂牙手套 | 翡翠', '驾驶手套 | 美洲豹女王', '运动手套 | 弹弓', '专业手套 | 老虎精英' - , '专业手套 | 渐变大理石', '运动手套 | 夜行衣', '驾驶手套 | 西装革履', '摩托手套 | 终点线', '摩托手套 | 血压', - '运动手套 | 猩红头巾', '驾驶手套 | 雪豹', '裹手 | 长颈鹿', '驾驶手套 | 绯红列赞', '裹手 | 沙漠头巾', - '专业手套 | 一线特工', '狂牙手套 | 黄色斑纹', '摩托手套 | 小心烟幕弹', '裹手 | 蟒蛇', '裹手 | 警告!', - '狂牙手套 | 精神错乱', '运动手套 | 大型猎物', '狂牙手套 | 针尖', '专业手套 | 陆军少尉长官'] -KUANGYADAXINGDONG_CASE_RED = ['M4A1 | 印花集', '格洛克 | 黑色魅影'] -KUANGYADAXINGDONG_CASE_PINK = ['FN57 | 童话城堡', 'M4A4 | 赛博', 'USP | 小绿怪'] -KUANGYADAXINGDONG_CASE_PURPLE = ['AWP | 亡灵之主', '双持贝瑞塔 | 灾难', '新星 | 一见青心', 'SSG 08 | 抖枪', 'UMP-45 | 金铋辉煌'] -KUANGYADAXINGDONG_CASE_BLUE = ['CZ75 | 世仇', 'P90 | 大怪兽RUSH', 'G3SG1 | 血腥迷彩', '加利尔 AR | 破坏者', 'P250 | 污染物', - 'M249 | 等高线', 'MP5-SD | 零点行动'] - -# 突围大行动 -TUWEIDAXINGDONG_CASE_KNIFE = ['蝴蝶刀 | 无涂装', '蝴蝶刀 | 蓝钢', '蝴蝶刀 | 屠夫', '蝴蝶刀 | 森林 DDPAT', '蝴蝶刀 | 北方森林', - '蝴蝶刀 | 狩猎网格', '蝴蝶刀 | 枯焦之色', '蝴蝶刀 | 人工染色', '蝴蝶刀 | 都市伪装', '蝴蝶刀 | 表面淬火', - '蝴蝶刀 | 深红之网', '蝴蝶刀 | 渐变之色', '蝴蝶刀 | 噩梦之夜'] -TUWEIDAXINGDONG_CASE_RED = ['P90 | 二西莫夫', 'M4A1 | 次时代'] -TUWEIDAXINGDONG_CASE_PINK = ['沙漠之鹰 | 阴谋者', 'FN57 | 狩猎利器', '格洛克 | 水灵'] -TUWEIDAXINGDONG_CASE_PURPLE = ['PP-野牛 | 死亡主宰者', 'CZ75 | 猛虎', '新星 | 锦鲤', 'P250 | 超新星'] -TUWEIDAXINGDONG_CASE_BLUE = ['MP7 | 都市危机', '内格夫 | 沙漠精英', 'P2000 | 乳白象牙', 'SSG 08 | 无尽深海', 'UMP-45 | 迷之宫'] - - -# 命悬一线 -MINGXUANYIXIAN_CASE_KNIFE = ['专业手套 | 大腕', '专业手套 | 深红之网', '专业手套 | 渐变之色', '专业手套 | 狩鹿', '九头蛇手套 | 响尾蛇', - '九头蛇手套 | 红树林', '九头蛇手套 | 翡翠色调', '九头蛇手套 | 表面淬火', '摩托手套 | 交运', '摩托手套 | 嘭!', - '摩托手套 | 多边形', '摩托手套 | 玳瑁', '裹手 | 套印', '裹手 | 森林色调', '裹手 | 钴蓝骷髅', '裹手 | 防水布胶带', - '运动手套 | 双栖', '运动手套 | 欧米伽', '运动手套 | 迈阿密风云', '运动手套 | 青铜形态', '驾驶手套 | 墨绿色调', - '驾驶手套 | 王蛇', '驾驶手套 | 蓝紫格子', '驾驶手套 | 超越'] -MINGXUANYIXIAN_CASE_RED = ['M4A4 | 黑色魅影', 'MP7 | 血腥运动'] -MINGXUANYIXIAN_CASE_PINK = ['AUG | 湖怪鸟', 'AWP | 死神', 'USP | 脑洞大开'] -MINGXUANYIXIAN_CASE_PURPLE = ['MAG-7 | SWAG-7', 'UMP-45 | 白狼', '内格夫 | 狮子鱼', '新星 | 狂野六号', '格洛克 | 城里的月光'] -MINGXUANYIXIAN_CASE_BLUE = ['FN57 | 焰色反应', 'MP9 | 黑砂', 'P2000 | 都市危机', 'PP-野牛 | 黑夜暴乱', 'R8 左轮手枪 | 稳', - 'SG 553 | 阿罗哈', 'XM1014 | 锈蚀烈焰'] - - -LIEKONG_CASE_KNIFE = ['求生匕首 | 无涂装', '求生匕首 | 人工染色', '求生匕首 | 北方森林', '求生匕首 | 夜色', '求生匕首 | 屠夫', - '求生匕首 | 枯焦之色', '求生匕首 | 森林 DDPAT', '求生匕首 | 深红之网', '求生匕首 | 渐变之色', '求生匕首 | 狩猎网格', - '求生匕首 | 蓝钢', '求生匕首 | 表面淬火', '求生匕首 | 都市伪装', '流浪者匕首 | 无涂装', '流浪者匕首 | 人工染色', - '流浪者匕首 | 北方森林', '流浪者匕首 | 夜色', '流浪者匕首 | 屠夫', '流浪者匕首 | 枯焦之色', '流浪者匕首 | 森林 DDPAT', - '流浪者匕首 | 深红之网', '流浪者匕首 | 渐变之色', '流浪者匕首 | 狩猎网格', '流浪者匕首 | 蓝钢', '流浪者匕首 | 表面淬火', - '流浪者匕首 | 都市伪装', '系绳匕首 | 无涂装', '系绳匕首 | 人工染色', '系绳匕首 | 北方森林', '系绳匕首 | 夜色', - '系绳匕首 | 屠夫', '系绳匕首 | 枯焦之色', '系绳匕首 | 森林 DDPAT', '系绳匕首 | 深红之网', '系绳匕首 | 渐变之色', - '系绳匕首 | 狩猎网格', '系绳匕首 | 蓝钢', '系绳匕首 | 表面淬火', '系绳匕首 | 都市伪装', '骷髅匕首 | 无涂装', - '骷髅匕首 | 人工染色', '骷髅匕首 | 北方森林', '骷髅匕首 | 夜色', '骷髅匕首 | 屠夫', '骷髅匕首 | 枯焦之色', - '骷髅匕首 | 森林 DDPAT', '骷髅匕首 | 深红之网', '骷髅匕首 | 渐变之色', '骷髅匕首 | 狩猎网格', '骷髅匕首 | 蓝钢', - '骷髅匕首 | 表面淬火', '骷髅匕首 | 都市伪装'] -LIEKONG_CASE_RED = ['AK-47 | 阿努比斯军团', '沙漠之鹰 | 印花集'] -LIEKONG_CASE_PINK = ['M4A4 | 齿仙', 'XM1014 | 埋葬之影', '格洛克 | 摩登时代'] -LIEKONG_CASE_PURPLE = ['加利尔 AR | 凤凰商号', 'Tec-9 | 兄弟连', 'MP5-SD | 猛烈冲锋', 'MAG-7 | 北冥有鱼', 'MAC-10 | 魅惑'] -LIEKONG_CASE_BLUE = ['内格夫 | 飞羽', 'SSG 08 | 主机001', 'SG 553 | 锈蚀之刃', 'PP-野牛 | 神秘碑文', 'P90 | 集装箱', 'P250 | 卡带', - 'P2000 | 盘根错节'] - - -GUANGPU_CASE_KNIFE = ['弯刀 | 外表生锈', '弯刀 | 多普勒', '弯刀 | 大马士革钢', '弯刀 | 渐变大理石', '弯刀 | 致命紫罗兰', '弯刀 | 虎牙', - '暗影双匕 | 外表生锈', '暗影双匕 | 多普勒', '暗影双匕 | 大马士革钢', '暗影双匕 | 渐变大理石', '暗影双匕 | 致命紫罗兰', - '暗影双匕 | 虎牙', '猎杀者匕首 | 外表生锈', '猎杀者匕首 | 多普勒', '猎杀者匕首 | 大马士革钢', '猎杀者匕首 | 渐变大理石', - '猎杀者匕首 | 致命紫罗兰', '猎杀者匕首 | 虎牙', '蝴蝶刀 | 外表生锈', '蝴蝶刀 | 多普勒', '蝴蝶刀 | 大马士革钢', - '蝴蝶刀 | 渐变大理石', '蝴蝶刀 | 致命紫罗兰', '蝴蝶刀 | 虎牙', '鲍伊猎刀 | 外表生锈', '鲍伊猎刀 | 多普勒', - '鲍伊猎刀 | 大马士革钢', '鲍伊猎刀 | 渐变大理石', '鲍伊猎刀 | 致命紫罗兰', '鲍伊猎刀 | 虎牙'] -GUANGPU_CASE_RED = ['USP | 黑色魅影', 'AK-47 | 血腥运动'] -GUANGPU_CASE_PINK = ['M4A1 | 毁灭者 2000', 'CZ75 | 相柳', 'AWP | 浮生如梦'] -GUANGPU_CASE_PURPLE = ['加利尔 AR | 深红海啸', 'XM1014 | 四季', 'UMP-45 | 支架', 'MAC-10 | 绝界之行', 'M249 | 翠绿箭毒蛙'] -GUANGPU_CASE_BLUE = ['沙漠之鹰 | 锈蚀烈焰', '截短霰弹枪 | 梭鲈', 'SCAR-20 | 蓝图', 'PP-野牛 | 丛林滑流', 'P250 | 涟漪', 'MP7 | 非洲部落', - 'FN57 | 毛细血管'] - - -NO_STA_KNIFE = ['求生匕首 | 北方森林', '求生匕首 | 夜色', '求生匕首 | 枯焦之色', '流浪者匕首 | 夜色', '流浪者匕首 | 枯焦之色', '流浪者匕首 | 森林 DDPAT', - '系绳匕首 | 夜色', '系绳匕首 | 狩猎网格', '骷髅匕首 | 夜色', '骷髅匕首 | 森林 DDPAT', '骷髅匕首 | 狩猎网格'] - - -def get_wear(num: float) -> str: - if num <= FACTORY_NEW_E: - return "崭新出厂" - if MINIMAL_WEAR_S <= num <= MINIMAL_WEAR_E: - return "略有磨损" - if FIELD_TESTED_S <= num <= FIELD_TESTED_E: - return "久经沙场" - if WELL_WORN_S <= num <= WELL_WORN_E: - return "破损不堪" - return "战痕累累" - - -def get_color_quality(rand: float, case_name: str): - case = "" - mosun = random.random()/2 + random.random()/2 - for i in pypinyin.pinyin(case_name, style=pypinyin.NORMAL): - case += ''.join(i) - case = case.upper() - CASE_KNIFE = eval(case + "_CASE_KNIFE") - CASE_RED = eval(case + "_CASE_RED") - CASE_PINK = eval(case + "_CASE_PINK") - CASE_PURPLE = eval(case + "_CASE_PURPLE") - CASE_BLUE = eval(case + "_CASE_BLUE") - if rand <= KNIFE: - skin = "罕见级(金色): " + random.choice(CASE_KNIFE) - if random.random() <= KNIFE_ST and (skin[2:4] != "手套" or skin[:2] != "裹手") and skin.split(':')[1] \ - not in NO_STA_KNIFE: - skin_sp = skin.split("|") - skin = skin_sp[0] + "(StatTrak™) | " + skin_sp[1] - elif KNIFE < rand <= RED: - skin = "隐秘级(红色): " + random.choice(CASE_RED) - if random.random() <= RED_ST: - skin_sp = skin.split("|") - skin = skin_sp[0] + "(StatTrak™) | " + skin_sp[1] - elif RED < rand <= PINK: - skin = "保密级(粉色): " + random.choice(CASE_PINK) - if random.random() <= PINK_ST: - skin_sp = skin.split("|") - skin = skin_sp[0] + "(StatTrak™) | " + skin_sp[1] - elif PINK < rand <= PURPLE: - skin = "受限级(紫色): " + random.choice(CASE_PURPLE) - if random.random() <= PURPLE_ST: - skin_sp = skin.split("|") - skin = skin_sp[0] + "(StatTrak™) | " + skin_sp[1] - else: - skin = "军规级(蓝色): " + random.choice(CASE_BLUE) - if random.random() <= BLUE_ST: - skin_sp = skin.split("|") - skin = skin_sp[0] + "(StatTrak™) | " + skin_sp[1] - if skin.find("(") != -1: - cpskin = skin.split(":")[1] - ybskin = cpskin.split("|") - temp_skin = ybskin[0].strip()[:-11] + " | " + ybskin[1].strip() - else: - temp_skin = skin.split(":")[1].strip() - # 崭新 -> 略磨 - if temp_skin in [] or temp_skin.find('渐变之色') != -1 or temp_skin.find('多普勒') != -1 or temp_skin.find('虎牙') != -1\ - or temp_skin.find('渐变大理石') != -1: - mosun = random.uniform(FACTORY_NEW_S, MINIMAL_WEAR_E) / 2 + random.uniform(FACTORY_NEW_S, MINIMAL_WEAR_E) / 2 - # 崭新 -> 久经 - if temp_skin in ['沙漠之鹰 | 阴谋者', '新星 | 锦鲤'] or temp_skin.find('屠夫') != -1: - mosun = random.uniform(FACTORY_NEW_S, FIELD_TESTED_E) / 2 + random.uniform(FACTORY_NEW_S, FIELD_TESTED_E) / 2 - # 崭新 -> 破损 - if temp_skin in ['UMP-45 | 迷之宫', 'P250 | 超新星', '系绳匕首 | 深红之网', 'M249 | 翠绿箭毒蛙', 'AK-47 | 血腥运动']: - mosun = random.uniform(FACTORY_NEW_S, WELL_WORN_E) / 2 + random.uniform(FACTORY_NEW_S, WELL_WORN_E) / 2 - # 破损 -> 战痕 - if temp_skin in [] or temp_skin.find('外表生锈') != -1: - mosun = random.uniform(WELL_WORN_S, BATTLE_SCARED_E) / 2 + random.uniform(WELL_WORN_S, BATTLE_SCARED_E) / 2 - if mosun > MINIMAL_WEAR_E: - for _ in range(2): - if random.random() < 5: - if random.random() < 0.2: - mosun /= 3 - else: - mosun /= 2 - break - skin += " (" + get_wear(mosun) + ")" - return skin, mosun - -# M249(StatTrak™) | 等高线 \ No newline at end of file diff --git a/plugins/open_cases/open_cases_c.py b/plugins/open_cases/open_cases_c.py deleted file mode 100644 index d2ba7688..00000000 --- a/plugins/open_cases/open_cases_c.py +++ /dev/null @@ -1,381 +0,0 @@ -from datetime import datetime, timedelta -from .config import * -from services.log import logger -from services.db_context import db -from models.open_cases_user import OpenCasesUser -from models.sigin_group_user import SignGroupUser -from util.init_result import image -import pypinyin -import random -from .utils import get_price -from models.buff_price import BuffPrice -from PIL import Image -from util.img_utils import alphabg2white_PIL, CreateImg -from configs.path_config import IMAGE_PATH -import asyncio -from util.utils import cn2py -from configs.config import INITIAL_OPEN_CASE_COUNT - - -MAX_COUNT = INITIAL_OPEN_CASE_COUNT - - -async def open_case(user_qq: int, group: int, case_name: str = "狂牙大行动") -> str: - if case_name not in ["狂牙大行动", "突围大行动", "命悬一线", '裂空', '光谱']: - return "武器箱未收录" - knifes_flag = False - # lan zi fen hong jin price - uplist = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0] - case = "" - for i in pypinyin.pinyin(case_name, style=pypinyin.NORMAL): - case += ''.join(i) - impression = (await SignGroupUser.ensure(user_qq, group)).impression - rand = random.random() - async with db.transaction(): - user = await OpenCasesUser.ensure(user_qq, group, for_update=True) - # 一天次数上限 - if user.today_open_total == int(MAX_COUNT + int(impression) / 3): - return _handle_is_MAX_COUNT() - skin, mosun = get_color_quality(rand, case_name) - # 调侃 - if skin[:2] == "军规": - if skin.find("StatTrak") == -1: - uplist[0] = 1 - else: - uplist[1] = 1 - ridicule_result = random.choice(['这样看着才舒服', - '是自己人,大伙把刀收好', - '非常舒适~']) - if skin[:2] == "受限": - if skin.find("StatTrak") == -1: - uplist[2] = 1 - else: - uplist[3] = 1 - ridicule_result = random.choice(['还行吧,勉强接受一下下', - '居然不是蓝色,太假了', - '运气-1-1-1-1-1...']) - if skin[:2] == "保密": - if skin.find("StatTrak") == -1: - uplist[4] = 1 - else: - uplist[5] = 1 - ridicule_result = random.choice(['开始不适....', - '你妈妈买菜必涨价!涨三倍!', - '你最近不适合出门,真的']) - if skin[:2] == "隐秘": - if skin.find("StatTrak") == -1: - uplist[6] = 1 - else: - uplist[7] = 1 - ridicule_result = random.choice(['已经非常不适', - '好兄弟你开的什么箱子啊,一般箱子不是只有蓝色的吗', - '开始拿阳寿开箱子了?']) - if skin[:2] == "罕见": - knifes_flag = True - if skin.find("StatTrak") == -1: - uplist[8] = 1 - else: - uplist[9] = 1 - ridicule_result = random.choice(['你的好运我收到了,你可以去喂鲨鱼了', - '最近该吃啥就迟点啥吧,哎,好好的一个人怎么就....哎', - '众所周知,欧皇寿命极短.']) - if skin.find("(") != -1: - cskin = skin.split("(") - skin = cskin[0].strip() + "(" + cskin[1].strip() - skin = skin.split("|")[0].strip() + " | " + skin.split("|")[1].strip() - # 价格 - if skin.find('无涂装') == -1: - dbprice = await BuffPrice.ensure(skin[9:]) - else: - dbprice = await BuffPrice.ensure(skin[9: skin.rfind('(')].strip()) - if dbprice.skin_price != 0: - price_result = dbprice.skin_price - print("数据库查询到价格: ", dbprice.skin_price) - uplist[10] = dbprice.skin_price - else: - price = -1 - price_result = "未查询到" - price_list, status = await get_price(skin[9:]) - if price_list not in ["访问超时! 请重试或稍后再试!", "访问失败!"]: - for price_l in price_list[1:]: - pcp = price_l.split(":") - if pcp[0] == skin[9:]: - price = float(pcp[1].strip()) - break - if price != -1: - print("存储入数据库---->", price) - uplist[10] = price - price_result = str(price) - await dbprice.update( - skin_price=price, - update_date=datetime.now(), - ).apply() - # sp = skin.split("|") - # cskin_word = sp[1][:sp[1].find("(") - 1].strip() - if knifes_flag: - await user.update( - knifes_name=user.knifes_name + f"{skin.split(':')[1].strip()} 磨损:{str(mosun)[:11]}, 价格:{uplist[10]}," - ).apply() - cskin_word = skin.split(':')[1].replace('|', '-').replace('(StatTrak™)', '') - cskin_word = cskin_word[: cskin_word.rfind('(')].strip() - skin_name = cn2py(cskin_word.replace('|', '-').replace('(StatTrak™)', '').strip()) - img = image(f'{skin_name}.png', "cases/" + case) - # if knifes_flag: - # await user.update( - # knifes_name=user.knifes_name + f"{skin} 磨损:{mosun}, 价格:{uplist[10]}" - # ).apply() - if await update_user_total(user, uplist): - logger.info(f"qq:{user_qq} 群:{group} 开启{case_name}武器箱 获得 {skin} 磨损:{mosun}, 价格:{uplist[10]}, 数据更新成功") - else: - logger.warning(f"qq:{user_qq} 群:{group} 开启{case_name}武器箱 获得 {skin} 磨损:{mosun}, 价格:{uplist[10]}, 数据更新失败") - user = await OpenCasesUser.ensure(user_qq, group, for_update=True) - over_count = int(MAX_COUNT + int(impression) / 3) - user.today_open_total - return f"开启{case_name}武器箱.\n剩余开箱次数:{over_count}.\n" \ - + img + "\n" + \ - f"皮肤:{skin}\n" \ - f"磨损:{mosun:.9f}\n" \ - f"价格:{price_result}\n" \ - f"{ridicule_result}" - - -async def open_shilian_case(user_qq: int, group: int, case_name: str, num: int = 10): - user = await OpenCasesUser.ensure(user_qq, group, for_update=True) - impression = (await SignGroupUser.ensure(user_qq, group)).impression - if user.today_open_total == int(MAX_COUNT + int(impression) / 3): - return _handle_is_MAX_COUNT() - if int(MAX_COUNT + int(impression) / 3) - user.today_open_total < num: - return f"今天开箱次数不足{num}次噢,请单抽试试看(也许单抽运气更好?)" \ - f"\n剩余开箱次数:{int(MAX_COUNT + int(impression) / 3) - user.today_open_total}" - if num < 5: - h = 270 - elif num % 5 == 0: - h = 270 * int(num / 5) - else: - h = 270 * int(num / 5) + 270 - case = cn2py(case_name) - # lan zi fen hong jin - # skin_list = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - # lan zi fen hong jin price - uplist = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0] - img_list = [] - name_list = ['蓝', '蓝(暗金)', '紫', '紫(暗金)', '粉', '粉(暗金)', '红', '红(暗金)', '金', '金(暗金)'] - async with db.transaction(): - for _ in range(num): - knifes_flag = False - rand = random.random() - skin, mosun = get_color_quality(rand, case_name) - if skin[:2] == "军规": - if skin.find("StatTrak") == -1: - uplist[0] += 1 - else: - uplist[1] += 1 - if skin[:2] == "受限": - if skin.find("StatTrak") == -1: - uplist[2] += 1 - else: - uplist[3] += 1 - if skin[:2] == "保密": - if skin.find("StatTrak") == -1: - uplist[4] += 1 - else: - uplist[5] += 1 - if skin[:2] == "隐秘": - if skin.find("StatTrak") == -1: - uplist[6] += 1 - else: - uplist[7] += 1 - if skin[:2] == "罕见": - knifes_flag = True - if skin.find("StatTrak") == -1: - uplist[8] += 1 - else: - uplist[9] += 1 - if skin.find("(") != -1: - cskin = skin.split("(") - skin = cskin[0].strip() + "(" + cskin[1].strip() - skin = skin.split("|")[0].strip() + " | " + skin.split("|")[1].strip() - # 价格 - if skin.find('无涂装') == -1: - dbprice = await BuffPrice.ensure(skin[9:]) - else: - dbprice = await BuffPrice.ensure(skin[9: skin.rfind('(')].strip()) - if dbprice.skin_price != 0: - price_result = dbprice.skin_price - uplist[10] += price_result - else: - price_result = '未查询到' - if knifes_flag: - await user.update( - knifes_name=user.knifes_name + f"{case}||{skin.split(':')[1].strip()} 磨损:{str(mosun)[:11]}, 价格:{dbprice.skin_price}," - ).apply() - cskin_word = skin.split(':')[1].replace('|', '-').replace('(StatTrak™)', '') - cskin_word = cskin_word[: cskin_word.rfind('(')].strip() - skin_name = "" - for i in pypinyin.pinyin(cskin_word.replace('|', '-').replace('(StatTrak™)', '').strip(), - style=pypinyin.NORMAL): - skin_name += ''.join(i) - # img = image(skin_name, "cases/" + case, "png") - wImg = CreateImg(200, 270, 200, 200) - wImg.paste(alphabg2white_PIL(Image.open(IMAGE_PATH + f'cases/{case}/{skin_name}.png').resize((200, 200), Image.ANTIALIAS)), (0, 0)) - wImg.text((5, 200), skin) - wImg.text((5, 220), f'磨损:{str(mosun)[:9]}') - wImg.text((5, 240), f'价格:{price_result}') - img_list.append(wImg) - logger.info(f"USER {user_qq} GROUP {group} 开启{case_name}武器箱 获得 {skin} 磨损:{mosun}, 价格:{uplist[10]}") - if await update_user_total(user, uplist, num): - logger.info(f"USER {user_qq} GROUP {group} 开启{case_name}武器箱 {num} 次, 数据更新成功") - else: - logger.warning(f"USER {user_qq} GROUP {group} 开启{case_name}武器箱 {num} 次, 价格:{uplist[10]}, 数据更新失败") - # markImg = CreateImg(1000, h, 200, 270) - # for img in img_list: - # markImg.paste(img) - markImg = await asyncio.get_event_loop().run_in_executor(None, paste_markImg, h, img_list) - over_count = int(MAX_COUNT + int(impression) / 3) - user.today_open_total - result = '' - for i in range(len(name_list)): - if uplist[i]: - result += f'[{name_list[i]}:{uplist[i]}] ' - return f"开启{case_name}武器箱\n剩余开箱次数:{over_count}\n" \ - + image(b64=markImg.pic2bs4()) + \ - '\n' + result[:-1] + f'\n总获取金额:{uplist[-1]:.2f}\n总花费:{17 * num}' - - -def paste_markImg(h: int, img_list: list): - markImg = CreateImg(1000, h, 200, 270) - for img in img_list: - markImg.paste(img) - return markImg - - -def _handle_is_MAX_COUNT() -> str: - return f"今天已达开箱上限了喔,明天再来吧\n(提升好感度可以增加每日开箱数 #疯狂暗示)" - - -async def update_user_total(user: OpenCasesUser, uplist: list, num: int = 1) -> bool: - try: - await user.update( - total_count=user.total_count + num, - blue_count=user.blue_count + uplist[0], - blue_st_count=user.blue_st_count + uplist[1], - purple_count=user.purple_count + uplist[2], - purple_st_count=user.purple_st_count + uplist[3], - pink_count=user.pink_count + uplist[4], - pink_st_count=user.pink_st_count + uplist[5], - red_count=user.red_count + uplist[6], - red_st_count=user.red_st_count + uplist[7], - knife_count=user.knife_count + uplist[8], - knife_st_count=user.knife_st_count + uplist[9], - spend_money=user.spend_money + 17 * num, - make_money=user.make_money + uplist[10], - today_open_total=user.today_open_total + num, - open_cases_time_last=datetime.now() - ).apply() - return True - except: - return False - - -async def total_open_statistics(user_qq: int, group: int) -> str: - async with db.transaction(): - user = await OpenCasesUser.ensure(user_qq, group, for_update=True) - return f"开箱总数:{user.total_count}\n" \ - f"今日开箱:{user.today_open_total}\n" \ - f"蓝色军规:{user.blue_count}\n" \ - f"蓝色暗金:{user.blue_st_count}\n" \ - f"紫色受限:{user.purple_count}\n" \ - f"紫色暗金:{user.purple_st_count}\n" \ - f"粉色保密:{user.pink_count}\n" \ - f"粉色暗金:{user.pink_st_count}\n" \ - f"红色隐秘:{user.red_count}\n" \ - f"红色暗金:{user.red_st_count}\n" \ - f"金色罕见:{user.knife_count}\n" \ - f"金色暗金:{user.knife_st_count}\n" \ - f"花费金额:{user.spend_money}\n" \ - f"获取金额:{user.make_money:.2f}\n" \ - f"最后开箱日期:{(user.open_cases_time_last + timedelta(hours=8)).date()}" - - -async def group_statistics(group: int): - user_list = await OpenCasesUser.get_user_all(group) - # lan zi fen hong jin pricei - uplist = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0, 0, 0] - for user in user_list: - uplist[0] += user.blue_count - uplist[1] += user.blue_st_count - uplist[2] += user.purple_count - uplist[3] += user.purple_st_count - uplist[4] += user.pink_count - uplist[5] += user.pink_st_count - uplist[6] += user.red_count - uplist[7] += user.red_st_count - uplist[8] += user.knife_count - uplist[9] += user.knife_st_count - uplist[10] += user.make_money - uplist[11] += user.total_count - uplist[12] += user.today_open_total - return f"群开箱总数:{uplist[11]}\n" \ - f"群今日开箱:{uplist[12]}\n" \ - f"蓝色军规:{uplist[0]}\n" \ - f"蓝色暗金:{uplist[1]}\n" \ - f"紫色受限:{uplist[2]}\n" \ - f"紫色暗金:{uplist[3]}\n" \ - f"粉色保密:{uplist[4]}\n" \ - f"粉色暗金:{uplist[5]}\n" \ - f"红色隐秘:{uplist[6]}\n" \ - f"红色暗金:{uplist[7]}\n" \ - f"金色罕见:{uplist[8]}\n" \ - f"金色暗金:{uplist[9]}\n" \ - f"花费金额:{uplist[11] * 17}\n" \ - f"获取金额:{uplist[10]:.2f}" - - -async def my_knifes_name(user_id: int, group: int): - knifes_name = (await OpenCasesUser.ensure(user_id, group)).knifes_name - if knifes_name: - knifes_list = knifes_name[:-1].split(",") - length = len(knifes_list) - if length < 5: - h = 600 - w = length * 540 - elif length % 5 == 0: - h = 600 * int(length / 5) - w = 540 * 5 - else: - h = 600 * int(length / 5) + 600 - w = 540 * 5 - A = await asyncio.get_event_loop().run_in_executor(None, _pst_my_knife, w, h, knifes_list) - return image(b64=A.pic2bs4()) - else: - return "您木有开出金色级别的皮肤喔" - - -def _pst_my_knife(w, h, knifes_list): - A = CreateImg(w, h, 540, 600) - for knife in knifes_list: - case = knife.split('||')[0] - knife = knife.split('||')[1] - name = knife[:knife.find('(')].strip() - itype = knife[knife.find('(')+1: knife.find(')')].strip() - mosun = knife[knife.find('磨损:')+3: knife.rfind('价格:')].strip() - if mosun[-1] == ',' or mosun[-1] == ',': - mosun = mosun[:-1] - price = knife[knife.find('价格:')+3:] - skin_name = "" - for i in pypinyin.pinyin(name.replace('|', '-').replace('(StatTrak™)', '').strip(), - style=pypinyin.NORMAL): - skin_name += ''.join(i) - knife_img = CreateImg(470, 600, 470, 470, font_size=20) - knife_img.paste(alphabg2white_PIL( - Image.open(IMAGE_PATH + f'cases/{case}/{skin_name}.png').resize((470, 470), Image.ANTIALIAS)), (0, 0)) - knife_img.text((5, 500), f'\t{name}({itype})') - knife_img.text((5, 530), f'\t磨损:{mosun}') - knife_img.text((5, 560), f'\t价格:{price}') - A.paste(knife_img) - return A - - - - -# G3SG1(StatTrak™) | 血腥迷彩 (战痕累累) -# G3SG1(StatTrak™) | 血腥迷彩 (战痕累累) -# G3SG1(StatTrak™) | 血腥迷彩 (战痕累累) diff --git a/plugins/open_cases/utils.py b/plugins/open_cases/utils.py deleted file mode 100644 index 8b28f162..00000000 --- a/plugins/open_cases/utils.py +++ /dev/null @@ -1,283 +0,0 @@ -from models.buff_price import BuffPrice -from services.db_context import db -from datetime import datetime, timedelta -from util.user_agent import get_user_agent -from configs.path_config import IMAGE_PATH -import aiohttp -import aiofiles -from models.open_cases_user import OpenCasesUser -import os -from services.log import logger -from util.utils import get_bot -from models.group_remind import GroupRemind -from util.utils import get_cookie_text -from asyncio.exceptions import TimeoutError -import pypinyin -from nonebot.adapters.cqhttp.exception import ActionFailed -from configs.config import buff_proxy - -url = "https://buff.163.com/api/market/goods" -# proxies = 'http://49.75.59.242:3128' - - -async def util_get_buff_price(case_name: str = "狂牙大行动") -> str: - cookie = {'session': get_cookie_text('buff')} - failed_list = [] - case = "" - for i in pypinyin.pinyin(case_name, style=pypinyin.NORMAL): - case += ''.join(i) - if case_name == "狂牙大行动": - case_id = 1 - elif case_name == "突围大行动": - case_id = 2 - elif case_name == "命悬一线": - case_id = 3 - elif case_name == '裂空': - case_id = 4 - elif case_name == '光谱': - case_id = 5 - else: - return "未查询到武器箱" - case = case.upper() - CASE_KNIFE = eval(case + "_CASE_KNIFE") - CASE_RED = eval(case + "_CASE_RED") - CASE_PINK = eval(case + "_CASE_PINK") - CASE_PURPLE = eval(case + "_CASE_PURPLE") - CASE_BLUE = eval(case + "_CASE_BLUE") - async with aiohttp.ClientSession(cookies=cookie, headers=get_user_agent()) as session: - for total_list in [CASE_KNIFE, CASE_RED, CASE_PINK, CASE_PURPLE, CASE_BLUE]: - print("----------------------------------") - for skin in total_list: - print(skin) - if skin in ["蝴蝶刀 | 无涂装", '求生匕首 | 无涂装', '流浪者匕首 | 无涂装', '系绳匕首 | 无涂装', '骷髅匕首 | 无涂装']: - skin = skin.split('|')[0].strip() - async with db.transaction(): - name_list = [] - price_list = [] - parameter = { - "game": "csgo", - "page_num": "1", - "search": skin - } - try: - async with session.get(url, proxy=buff_proxy, params=parameter, timeout=20) as response: - if response.status == 200: - data = (await response.json())["data"] - total_page = data["total_page"] - data = data["items"] - flag = False - if skin.find('|') == -1: # in ['蝴蝶刀', '求生匕首', '流浪者匕首', '系绳匕首', '骷髅匕首']: - for i in range(1, total_page + 1): - name_list = [] - price_list = [] - parameter = { - "game": "csgo", - "page_num": f"{i}", - "search": skin - } - async with session.get(url, params=parameter, timeout=20) as res: - data = (await response.json())["data"]["items"] - for j in range(len(data)): - if data[j]['name'] in [f'{skin}(★)']: - name = data[j]["name"] - price = data[j]["sell_reference_price"] - name_list.append(name.split('(')[0].strip() + ' | 无涂装') - price_list.append(price) - print(name_list[-1]) - print(price_list[-1]) - flag = True - break - if flag: - break - else: - try: - for _ in range(total_page): - for i in range(len(data)): - name = data[i]["name"] - price = data[i]["sell_reference_price"] - name_list.append(name) - price_list.append(price) - except Exception as e: - failed_list.append(skin) - print(f"{skin}更新失败") - else: - failed_list.append(skin) - print(f"{skin}更新失败") - except Exception: - failed_list.append(skin) - print(f"{skin}更新失败") - continue - for i in range(len(name_list)): - name = name_list[i].strip() - price = float(price_list[i]) - if name.find("(★)") != -1: - name = name[: name.find("(")] + name[name.find(")") + 1:] - if name.find("消音") != -1 and name.find("(S") != -1: - name = name.split("(")[0][:-4] + "(" + name.split("(")[1] - name = name.split("|")[0].strip() + " | " + name.split("|")[1].strip() - elif name.find("消音") != -1: - name = name.split("|")[0][:-5].strip() + " | " + name.split("|")[1].strip() - if name.find(" 18 ") != -1 and name.find("(S") != -1: - name = name.split("(")[0][:-5] + "(" + name.split("(")[1] - name = name.split("|")[0].strip() + " | " + name.split("|")[1].strip() - elif name.find(" 18 ") != -1: - name = name.split("|")[0][:-6].strip() + " | " + name.split("|")[1].strip() - dbskin = await BuffPrice.ensure(name, True) - if (dbskin.update_date + timedelta(8)).date() == datetime.now().date(): - continue - await dbskin.update( - case_id=case_id, - skin_price=price, - update_date=datetime.now(), - ).apply() - print(f"{name_list[i]}---------->成功更新") - result = None - if failed_list: - result = "" - for fail_skin in failed_list: - result += fail_skin + "\n" - return result[:-1] if result else "更新价格成功" - - -async def util_get_buff_img(case_name: str = "狂牙大行动") -> str: - cookie = {'session': get_cookie_text('buff')} - error_list = [] - case = "" - for i in pypinyin.pinyin(case_name, style=pypinyin.NORMAL): - case += ''.join(i) - path = "cases/" + case + "/" - if not os.path.exists(IMAGE_PATH + path): - os.mkdir(IMAGE_PATH + path) - case = case.upper() - CASE_KNIFE = eval(case + "_CASE_KNIFE") - CASE_RED = eval(case + "_CASE_RED") - CASE_PINK = eval(case + "_CASE_PINK") - CASE_PURPLE = eval(case + "_CASE_PURPLE") - CASE_BLUE = eval(case + "_CASE_BLUE") - async with aiohttp.ClientSession(cookies=cookie, headers=get_user_agent()) as session: - for total_list in [CASE_KNIFE, CASE_RED, CASE_PINK, CASE_PURPLE, CASE_BLUE]: - for skin in total_list: - parameter = { - "game": "csgo", - "page_num": "1", - "search": skin - } - if skin in ["蝴蝶刀 | 无涂装", '求生匕首 | 无涂装', '流浪者匕首 | 无涂装', '系绳匕首 | 无涂装', '骷髅匕首 | 无涂装']: - skin = skin.split('|')[0].strip() - print("开始更新----->", skin) - print(skin) - skin_name = '' - # try: - async with session.get(url, proxy=buff_proxy, params=parameter, timeout=20) as response: - if response.status == 200: - data = (await response.json())["data"] - total_page = data["total_page"] - flag = False - if skin.find('|') == -1: # in ['蝴蝶刀', '求生匕首', '流浪者匕首', '系绳匕首', '骷髅匕首']: - for i in range(1, total_page + 1): - async with session.get(url, params=parameter, timeout=20) as res: - data = (await response.json())["data"]["items"] - for j in range(len(data)): - if data[j]['name'] in [f'{skin}(★)']: - img_url = data[j]['goods_info']['icon_url'] - for k in pypinyin.pinyin(skin + '无涂装', style=pypinyin.NORMAL): - skin_name += ''.join(k) - async with aiofiles.open(IMAGE_PATH + path + skin_name + ".png", 'wb') as f: - print("------->开始写入 ", skin) - async with session.get(img_url, timeout=7) as res: - await f.write(await res.read()) - flag = True - break - if flag: - break - else: - img_url = (await response.json())["data"]['items'][0]['goods_info']['icon_url'] - for i in pypinyin.pinyin(skin.replace('|', '-').strip(), style=pypinyin.NORMAL): - skin_name += ''.join(i) - async with aiofiles.open(IMAGE_PATH + path + skin_name + ".png", 'wb') as f: - print("------->开始写入 ", skin) - async with session.get(img_url, timeout=7) as res: - await f.write(await res.read()) - # async with session.get(url, params=parameter, timeout=7) as response: - # if response.status == 200: - # img_url = (await response.json())["data"]['items'][0]['goods_info']['icon_url'] - # skin_name = '' - # for i in pypinyin.pinyin(skin.split("|")[1].strip(), style=pypinyin.NORMAL): - # skin_name += ''.join(i) - # async with aiofiles.open(IMAGE_PATH + path + skin_name + ".png", 'wb') as f: - # print("------->开始写入 ", skin) - # async with session.get(img_url, timeout=7) as res: - # await f.write(await res.read()) - # except Exception: - # print("图片更新失败 ---->", skin) - # error_list.append(skin) - result = None - if error_list: - result = "" - for errskin in error_list: - result += errskin + "\n" - return result[:-1] if result else "更新图片成功" - - -async def get_price(dname): - cookie = {'session': get_cookie_text('buff')} - name_list = [] - price_list = [] - parameter = { - "game": "csgo", - "page_num": "1", - "search": dname - } - try: - async with aiohttp.ClientSession(cookies=cookie, headers=get_user_agent()) as session: - async with session.get(url, params=parameter, timeout=7) as response: - if response.status == 200: - try: - data = (await response.json())["data"] - total_page = data["total_page"] - data = data["items"] - for _ in range(total_page): - for i in range(len(data)): - name = data[i]["name"] - price = data[i]["sell_reference_price"] - name_list.append(name) - price_list.append(price) - except Exception as e: - return "没有查询到...", 998 - else: - return "访问失败!", response.status - except TimeoutError as e: - return "访问超时! 请重试或稍后再试!", 997 - result = f"皮肤: {dname}({len(name_list)})\n" - # result = "皮肤: " + dname + "\n" - for i in range(len(name_list)): - result += name_list[i] + ": " + price_list[i] + "\n" - return result[:-1], 999 - - -async def update_count_daily(): - try: - users = await OpenCasesUser.get_user_all() - if users: - for user in users: - await user.update( - today_open_total=0, - ).apply() - bot = get_bot() - gl = await bot.get_group_list(self_id=bot.self_id) - gl = [g['group_id'] for g in gl] - for g in gl: - if await GroupRemind.get_status(g, 'kxcz'): - try: - await bot.send_group_msg(group_id=g, message="今日开箱次数重置成功") - except ActionFailed: - logger.warning(f'{g} 群被禁言,无法发送 开箱重置提醒') - logger.info("今日开箱次数重置成功") - except Exception as e: - logger.error(f'开箱重置错误 e:{e}') - - - -# 蝴蝶刀(★) | 噩梦之夜 (久经沙场) -if __name__ == '__main__': - print(util_get_buff_img("xxxx/")) diff --git a/plugins/parse_bilibili_json.py b/plugins/parse_bilibili_json.py deleted file mode 100644 index 4ba0cde3..00000000 --- a/plugins/parse_bilibili_json.py +++ /dev/null @@ -1,75 +0,0 @@ -from nonebot import on_message -from services.log import logger -from nonebot.adapters.cqhttp import Bot, GroupMessageEvent -from nonebot.typing import T_State -from util.utils import get_message_json, get_local_proxy -import json -from util.user_agent import get_user_agent -from nonebot.adapters.cqhttp.permission import GROUP -from bilibili_api import video -from util.init_result import image -from models.group_remind import GroupRemind -from nonebot.adapters.cqhttp.exception import ActionFailed -import time -import aiohttp -import bilibili_api -if get_local_proxy(): - proxy_ip_port = get_local_proxy().split("//", maxsplit=1)[1] - bilibili_api.request_settings["proxies"] = {'http': f'http://{proxy_ip_port}', 'https': f'https://{proxy_ip_port}'} - - -parse_bilibili_json = on_message(priority=1, permission=GROUP, block=False) - - -@parse_bilibili_json.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - if await GroupRemind.get_status(event.group_id, 'blpar') and get_message_json(event.json()): - data = json.loads(get_message_json(event.json())['data']) - if data: - if data.get('desc') == '哔哩哔哩': - async with aiohttp.ClientSession(headers=get_user_agent()) as session: - async with session.get(data['meta']['detail_1']['qqdocurl'], proxy=get_local_proxy(), timeout=7) as response: - url = str(response.url).split("?")[0] - print(url) - bvid = url.split('/')[-1] - vd_info = video.get_video_info(bvid=bvid) - aid = vd_info['aid'] - title = vd_info['title'] - author = vd_info['owner']['name'] - reply = vd_info['stat']['reply'] # 回复 - favorite = vd_info['stat']['favorite'] # 收藏 - coin = vd_info['stat']['coin'] # 投币 - # like = vd_info['stat']['like'] # 点赞 - # danmu = vd_info['stat']['danmaku'] # 弹幕 - date = time.strftime("%Y-%m-%d", time.localtime(vd_info['ctime'])) - try: - await parse_bilibili_json.send( - image(vd_info["pic"]) + - f'\nav{aid}\n标题:{title}\n' - f'UP:{author}\n' - f'上传日期:{date}\n' - f'回复:{reply},收藏:{favorite},投币:{coin}\n' - f'{url}' - ) - except ActionFailed: - logger.warning(f'{event.group_id} 发送bilibili解析失败') - logger.info(f'USER {event.user_id} GROUP {event.group_id} 解析bilibili转发 {url}') - else: - return - else: - return - - - - - - - - - - - - - - - diff --git a/plugins/pixiv/__init__.py b/plugins/pixiv/__init__.py deleted file mode 100644 index 4e2dba29..00000000 --- a/plugins/pixiv/__init__.py +++ /dev/null @@ -1,194 +0,0 @@ -from nonebot.typing import T_State -from nonebot.adapters.cqhttp import Bot, MessageEvent -from nonebot import on_command -from util.utils import get_message_text, UserExistLimiter, is_number -from .data_source import get_pixiv_urls, download_pixiv_imgs, search_pixiv_urls -import time -from services.log import logger -from nonebot.adapters.cqhttp.exception import NetworkError - -__plugin_usage__1 = '''P站排行榜帮助: -可选参数: -类型: - 1. 日排行 - 2. 周排行 - 3. 月排行 - 4. 原创排行 - 5. 新人排行 - 6. R18日排行 - 7. R18周排行 - 8. R18受男性欢迎排行 - 9. R18重口排行【慎重!】 -【使用时选择参数序号即可,R18仅可私聊】 -p站排行榜 类型 数量(可选) 日期(可选) -示例: - p站排行榜 (无参数默认为日榜) - p站排行榜 1 - p站排行榜 1 5 - p站排行榜 1 5 2018-4-25 -【注意空格!!】【在线搜索会较慢】 -''' - -__plugin_usage__2 = '''P站搜图帮助: -可选参数: - 1.热度排序 - 2.时间排序 -【使用时选择参数序号即可,R18仅可私聊】 -搜图 关键词 数量(可选) 排序方式(可选) r18(可选) -示例: - 搜图 樱岛麻衣 - 搜图 樱岛麻衣 5 1 - 搜图 樱岛麻衣 5 2 r18 -【默认为 热度排序】 -【注意空格!!】【在线搜索会较慢】【数量可能不符】 -''' - -rank_dict = { - '1': 'day', - '2': 'week', - '3': 'month', - '4': 'week_original', - '5': 'week_rookie', - '6': 'day_r18', - '7': 'week_r18', - '8': 'day_male_r18', - '9': 'week_r18g' -} - -_ulmt = UserExistLimiter() - -pixiv_rank = on_command('p站排行', aliases={'P站排行榜', 'p站排行榜', 'P站排行榜'}, priority=5, block=True) -pixiv_keyword = on_command('搜图', priority=5, block=True) - - -@pixiv_rank.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - msg = get_message_text(event.json()).strip() - if msg in ['帮助']: - await pixiv_rank.finish(__plugin_usage__1) - msg = msg.split(' ') - msg = [m for m in msg if m] - if not msg: - msg = ['1'] - if msg[0] in ['6', '7', '8', '9']: - if event.message_type == 'group': - await pixiv_rank.finish('羞羞脸!私聊里自己看!', at_sender=True) - # print(msg) - if _ulmt.check(event.user_id): - await pixiv_rank.finish("P站排行榜正在搜索噢,不要重复触发命令呀") - _ulmt.set_True(event.user_id) - if len(msg) == 0 or msg[0] == '': - text_list, urls, code = await get_pixiv_urls(rank_dict.get('1')) - elif len(msg) == 1: - if msg[0] not in ['1', '2', '3', '4', '5', '6', '7', '8', '9']: - await pixiv_rank.finish("要好好输入要看什么类型的排行榜呀!", at_sender=True) - text_list, urls, code = await get_pixiv_urls(rank_dict.get(msg[0])) - elif len(msg) == 2: - text_list, urls, code = await get_pixiv_urls(rank_dict.get(msg[0]), int(msg[1])) - elif len(msg) == 3: - if not check_date(msg[2]): - await pixiv_rank.finish('日期格式错误了', at_sender=True) - text_list, urls, code = await get_pixiv_urls(rank_dict.get(msg[0]), int(msg[1]), msg[2]) - else: - _ulmt.set_False(event.user_id) - await pixiv_rank.finish('格式错了噢,看看帮助?', at_sender=True) - if code != 200: - await pixiv_keyword.finish(text_list[0]) - else: - if not text_list or not urls: - await pixiv_rank.finish('没有找到啊,等等再试试吧~V', at_sender=True) - for i in range(len(text_list)): - try: - await pixiv_rank.send(text_list[i] + await download_pixiv_imgs(urls[i], event.user_id)) - except NetworkError: - await pixiv_keyword.send('这张图网络炸了!', at_sender=True) - logger.info( - f"(USER {event.user_id}, GROUP {event.group_id if event.message_type != 'private' else 'private'})" - f" 查看了P站排行榜 code:{msg[0]}") - _ulmt.set_False(event.user_id) - - -@pixiv_keyword.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - msg = get_message_text(event.json()).strip() - if msg in ['帮助'] or not msg: - await pixiv_keyword.finish(__plugin_usage__2) - if event.message_type == 'group': - if msg.find('r18') != -1: - await pixiv_keyword.finish('(脸红#) 你不会害羞的 八嘎!', at_sender=True) - if msg.find('r18') == -1: - r18 = 1 - else: - r18 = 2 - msg = msg.replace('r18', '').strip() - if _ulmt.check(event.user_id): - await pixiv_rank.finish("P站关键词正在搜索噢,不要重复触发命令呀") - _ulmt.set_True(event.user_id) - msg = msg.split(' ') - msg = [m for m in msg if m] - if len(msg) == 1: - keyword = msg[0].strip() - num = 5 - order = 'popular' - elif len(msg) == 2: - keyword = msg[0].strip() - if not is_number(msg[1].strip()): - _ulmt.set_False(event.user_id) - await pixiv_keyword.finish('图片数量必须是数字!', at_sender=True) - num = int(msg[1].strip()) - order = 'popular' - elif len(msg) == 3: - keyword = msg[0].strip() - if not is_number(msg[1].strip()): - _ulmt.set_False(event.user_id) - await pixiv_keyword.finish('图片数量必须是数字!', at_sender=True) - num = int(msg[1].strip()) - if not is_number(msg[2].strip()): - _ulmt.set_False(event.user_id) - await pixiv_keyword.finish('排序方式必须是数字!', at_sender=True) - if msg[2].strip() == '1': - order = 'popular' - else: - order = 'xxx' - else: - _ulmt.set_False(event.user_id) - await pixiv_keyword.finish('参数不正确,一定要好好看看帮助啊!', at_sender=True) - text_list, urls, code = await search_pixiv_urls(keyword, num, order, r18) - if code != 200: - _ulmt.set_False(event.user_id) - await pixiv_keyword.finish(text_list[0]) - else: - for i in range(len(text_list)): - try: - await pixiv_keyword.send(text_list[i] + await download_pixiv_imgs(urls[i], event.user_id)) - except NetworkError: - await pixiv_keyword.send('这张图网络炸了!', at_sender=True) - logger.info( - f"(USER {event.user_id}, GROUP {event.group_id if event.message_type != 'private' else 'private'})" - f" 查看了搜索 {keyword} R18:{r18}") - _ulmt.set_False(event.user_id) - - -def check_date(date): - try: - time.strptime(date, "%Y-%m-%d") - return True - except: - return False - - - - - - - - - - - - - - - - - diff --git a/plugins/pixiv/__pycache__/__init__.cpython-38.pyc b/plugins/pixiv/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 7cbf7fe4..00000000 Binary files a/plugins/pixiv/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/pixiv/__pycache__/__init__.cpython-39.pyc b/plugins/pixiv/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 061d6060..00000000 Binary files a/plugins/pixiv/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/pixiv/__pycache__/data_source.cpython-38.pyc b/plugins/pixiv/__pycache__/data_source.cpython-38.pyc deleted file mode 100644 index ab89cbec..00000000 Binary files a/plugins/pixiv/__pycache__/data_source.cpython-38.pyc and /dev/null differ diff --git a/plugins/pixiv/__pycache__/data_source.cpython-39.pyc b/plugins/pixiv/__pycache__/data_source.cpython-39.pyc deleted file mode 100644 index 48f809bb..00000000 Binary files a/plugins/pixiv/__pycache__/data_source.cpython-39.pyc and /dev/null differ diff --git a/plugins/pixiv/data_source.py b/plugins/pixiv/data_source.py deleted file mode 100644 index 71839a8d..00000000 --- a/plugins/pixiv/data_source.py +++ /dev/null @@ -1,84 +0,0 @@ -import aiohttp -import aiofiles -from configs.path_config import IMAGE_PATH -from util.utils import get_local_proxy -from util.user_agent import get_user_agent -from bs4 import BeautifulSoup -import feedparser -from util.init_result import image -from asyncio.exceptions import TimeoutError -import platform -if platform.system() == 'Windows': - import asyncio - asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) - - -async def get_pixiv_urls(mode: str, num: int = 5, date: str = '') -> 'list, list, int': - url = 'https://rsshub.app/pixiv/ranking/{}' - iurl = url.format(mode) - if date: - iurl += f'/{date}' - return await parser_data(iurl, num) - - -async def download_pixiv_imgs(urls: list, user_id: int) -> str: - result = '' - index = 0 - for img in urls: - async with aiohttp.ClientSession(headers=get_user_agent()) as session: - for _ in range(3): - async with session.get(img, proxy=get_local_proxy(), timeout=3) as response: - async with aiofiles.open(IMAGE_PATH + f'temp/{user_id}_{index}_pixiv.jpg', 'wb') as f: - try: - await f.write(await response.read()) - result += image(f'{user_id}_{index}_pixiv.jpg', 'temp') - index += 1 - break - except TimeoutError: - # result += '\n这张图下载失败了..\n' - pass - else: - result += '\n这张图下载失败了..\n' - return result - - -async def search_pixiv_urls(keyword: str, num: int, order: str, r18: int) -> 'list, list': - url = 'https://rsshub.app/pixiv/search/{}/{}/{}'.format(keyword, order, r18) - return await parser_data(url, num) - - -async def parser_data(url: str, num: int) -> 'list, list, int': - text_list = [] - urls = [] - async with aiohttp.ClientSession() as session: - for _ in range(3): - try: - async with session.get(url, proxy=get_local_proxy(), timeout=4) as response: - data = feedparser.parse(await response.text())['entries'] - break - except TimeoutError: - pass - else: - return ['网络不太好,也许过一会就好了'], [], 998 - try: - if len(data) == 0: - return ['没有搜索到喔'], [], 997 - if num > len(data): - num = len(data) - data = data[:num] - for data in data: - soup = BeautifulSoup(data['summary'], 'lxml') - title = "标题:" + data['title'] - pl = soup.find_all('p') - author = pl[0].text.split('-')[0].strip() - imgs = [] - text_list.append(f'{title}\n{author}\n') - for p in pl[1:]: - imgs.append(p.find('img').get('src')) - urls.append(imgs) - except ValueError: - return ['是网站坏了啊,也许过一会就好了'], [], 999 - return text_list, urls, 200 - - -# asyncio.get_event_loop().run_until_complete(get_pixiv_urls('day')) diff --git a/plugins/poke/__init__.py b/plugins/poke/__init__.py deleted file mode 100644 index 727788e2..00000000 --- a/plugins/poke/__init__.py +++ /dev/null @@ -1,52 +0,0 @@ -from nonebot import on_notice -from nonebot.adapters.cqhttp import Bot, PokeNotifyEvent -from nonebot.typing import T_State -from configs.path_config import VOICE_PATH, IMAGE_PATH -import os -from util.init_result import record, image, poke -from services.log import logger -import random -from util.utils import CountLimiter -from models.ban_user import BanUser - -# 戳 一 戳 - -poke__reply = [ - "lsp你再戳?", "连个可爱美少女都要戳的肥宅真恶心啊。", - "你再戳!", "?再戳试试?", "别戳了别戳了再戳就坏了555", "我爪巴爪巴,球球别再戳了", "你戳你🐎呢?!", - "那...那里...那里不能戳...绝对...", "(。´・ω・)ん?", "有事恁叫我,别天天一个劲戳戳戳!", "欸很烦欸!你戳🔨呢", - "?", "再戳一下试试?", "???", "正在关闭对您的所有服务...关闭成功", "啊呜,太舒服刚刚竟然睡着了。什么事?", "正在定位您的真实地址。。。\r\n定位成功。轰炸机已起飞" -] - - -_clmt = CountLimiter(3) - -poke_ = on_notice(priority=5) - - -@poke_.handle() -async def _poke_(bot: Bot, event: PokeNotifyEvent, state: T_State) -> None: - if event.notice_type == 'notify' and event.sub_type == 'poke' and event.self_id == event.target_id: - _clmt.add(event.user_id) - if _clmt.check(event.user_id) or random.random() < 0.3: - rst = '' - if random.random() < 0.15: - await BanUser.ban(event.user_id, 1, 60) - rst = '气死我了!' - await poke_.finish(rst + random.choice(poke__reply), at_sender=True) - rand = random.random() - if rand <= 0.3: - path = random.choice(['loli/', 'meitu/']) - index = random.randint(0, len(os.listdir(IMAGE_PATH + path))) - result = f'id:{index}' + image(f'{index}.jpg', path) - await poke_.send(result) - logger.info(f'USER {event.user_id} 戳了戳我 回复: {result} \n {result}') - elif 0.3 < rand < 0.6: - voice = random.choice(os.listdir(VOICE_PATH + 'dinggong/')) - result = record(voice, "dinggong") - await poke_.send(result) - await poke_.send(voice.split('_')[1]) - logger.info(f'USER {event.user_id} 戳了戳我 回复: {result} \n {voice.split("_")[1]}') - else: - await poke_.send(poke(event.user_id)) - diff --git a/plugins/poke/__pycache__/__init__.cpython-38.pyc b/plugins/poke/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 75ef2c42..00000000 Binary files a/plugins/poke/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/poke/__pycache__/__init__.cpython-39.pyc b/plugins/poke/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 8890b3dc..00000000 Binary files a/plugins/poke/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/quotations.py b/plugins/quotations.py deleted file mode 100644 index 3ae02463..00000000 --- a/plugins/quotations.py +++ /dev/null @@ -1,29 +0,0 @@ -from nonebot import on_command -import random -from util.utils import get_lines -from configs.path_config import TXT_PATH -from services.log import logger -from nonebot.adapters.cqhttp import Bot, MessageEvent -from nonebot.typing import T_State - - -__plugin_name__ = '语录' -__plugin_usage__ = '用法: 二次元语录给你力量' - - -lines = get_lines(TXT_PATH + "yulu.txt") - - -quotations = on_command("语录", aliases={'二次元', '二次元语录'}, priority=5, block=True) - - -@quotations.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - if str(event.get_message()) in ['帮助']: - await quotations.finish(__plugin_usage__) - result = random.choice(lines) - logger.info( - f"(USER {event.user_id}, GROUP {event.group_id if event.message_type != 'private' else 'private'}) 发送语录:" - + result[:-1]) - await quotations.finish(result[:-1]) - diff --git a/plugins/reimu/__init__.py b/plugins/reimu/__init__.py deleted file mode 100644 index 031da058..00000000 --- a/plugins/reimu/__init__.py +++ /dev/null @@ -1,96 +0,0 @@ -from nonebot import on_command -from nonebot.adapters.cqhttp.permission import PRIVATE -from .data_source import from_reimu_get_info -from services.log import logger -from nonebot.adapters.cqhttp import Bot, Event -from nonebot.typing import T_State -from util.utils import is_number, get_message_text, UserExistLimiter, scheduler -from models.count_user import UserCount -from configs.config import COUNT_PER_DAY_REIMU - -__plugin_name__ = '上车' -__plugin_usage__ = r""" -* 请各位使用后不要转发 * -* 大部分解压密码是⑨ * -/ 每人每天仅提供 5 次上车机会(只能私聊)更多次数请向管理员申请(用爱发电)限制小色批乱搜 / -/ 并不推荐小色批使用此功能(主要是不够色,目的不够明确) / -上车 [目的地] -上车 5 [目的地] 该目的地第5页停车场 -ps: 请尽量提供具体的目的地名称 -""".strip() - - -_ulmt = UserExistLimiter() - -reimu = on_command('上车', permission=PRIVATE, block=True, priority=1) - - -@reimu.args_parser -async def _(bot: Bot, event: Event, state: T_State): - if get_message_text(event.json()) in ['取消', '算了']: - await reimu.finish("已取消操作..", at_sender=True) - if not get_message_text(event.json()): - await reimu.reject('没时间等了!快说你要去哪里?', at_sender=True) - state['keyword'] = get_message_text(event.json()) - state['page'] = 1 - - -@reimu.handle() -async def _(bot: Bot, event: Event, state: T_State): - if str(event.get_message()) in ['帮助']: - await reimu.finish(__plugin_usage__) - if await UserCount.check_count(event.user_id, 'reimu', COUNT_PER_DAY_REIMU): - await reimu.finish('今天已经没车了,请明天再来...', at_sender=True) - if _ulmt.check(event.user_id): - await reimu.finish('您还没下车呢,请稍等...', at_sender=True) - _ulmt.set_True(event.user_id) - msg = get_message_text(event.json()) - args = msg.split(" ") - if msg in ['!', '!', '?', '?', ',', ',', '.', '。']: - await reimu.finish(__plugin_usage__) - if msg: - if len(args) > 1 and is_number(args[0]): - state['keyword'] = args[1] - state['page'] = args[0] - else: - state['keyword'] = msg - state['page'] = 1 - - -@reimu.got('keyword', '你的目的地是哪?') -async def _(bot: Bot, event: Event, state: T_State): - try: - keyword = state['keyword'] - page = state['page'] - print(keyword, page) - await UserCount.add_count(event.user_id, 'reimu') - await reimu.send('已经帮你关好车门了', at_sender=True) - reimu_report = await from_reimu_get_info(keyword, page) - if reimu_report: - await reimu.send(reimu_report) - else: - logger.error("Not found reimuInfo") - await reimu.send("没找着") - _ulmt.set_False(event.user_id) - except: - _ulmt.set_False(event.user_id) - - -@scheduler.scheduled_job( - 'cron', - # year=None, - # month=None, - # day=None, - # week=None, - # day_of_week="mon,tue,wed,thu,fri", - hour=0, - minute=1, - # second=None, - # start_date=None, - # end_date=None, - # timezone=None, -) -async def _(): - await UserCount.reset_count() - - diff --git a/plugins/reimu/__pycache__/__init__.cpython-38.pyc b/plugins/reimu/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index e151d6f6..00000000 Binary files a/plugins/reimu/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/reimu/__pycache__/__init__.cpython-39.pyc b/plugins/reimu/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 550ca6b3..00000000 Binary files a/plugins/reimu/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/reimu/__pycache__/data_source.cpython-38.pyc b/plugins/reimu/__pycache__/data_source.cpython-38.pyc deleted file mode 100644 index 20057281..00000000 Binary files a/plugins/reimu/__pycache__/data_source.cpython-38.pyc and /dev/null differ diff --git a/plugins/reimu/__pycache__/data_source.cpython-39.pyc b/plugins/reimu/__pycache__/data_source.cpython-39.pyc deleted file mode 100644 index 984b9878..00000000 Binary files a/plugins/reimu/__pycache__/data_source.cpython-39.pyc and /dev/null differ diff --git a/plugins/reimu/data_source.py b/plugins/reimu/data_source.py deleted file mode 100644 index 266d1045..00000000 --- a/plugins/reimu/data_source.py +++ /dev/null @@ -1,116 +0,0 @@ -from lxml import etree -import time -import aiohttp -from services.log import logger -from configs.config import MAXINFO_REIMU -from util.user_agent import get_user_agent -from util.utils import get_local_proxy -from asyncio.exceptions import TimeoutError - - -async def from_reimu_get_info(key_word: str, page: int) -> str: - if "miku" in key_word.lower(): - logger.warning("Taboo words are being triggered") - return None - repass = "" - url = 'https://blog.reimu.net/search/' + key_word + '/page/' + str(page) - url_s = 'https://blog.reimu.net/' - try: - if key_word == "最近的存档": - logger.debug("Now starting get the {}".format(url_s)) - repass = await get_repass(url_s) - else: - logger.debug("Now starting get the {}".format(url)) - repass = await get_repass(url) - except TimeoutError as e: - logger.error("Timeout! {}".format(e)) - - return repass - - -async def get_repass(url: str) -> str: - repass = "" - info = "[Note]注意大部分资源解压密码为⑨\n" - fund = None - print(url) - async with aiohttp.ClientSession(headers=get_user_agent()) as session: - async with session.get(url, proxy=get_local_proxy(), timeout=15) as response: - html = etree.HTML(await response.text()) - - fund_l = html.xpath('//h1[@class="page-title"]/text()') - if fund_l: - fund = fund_l[0] - if fund == "未找到": - return "老司机也找不到路了……" - else: - pass - - headers = html.xpath('//article/header/h2/a/text()') - urls = html.xpath('//article/header/h2/a/@href') - logger.debug("Now get {} post from search page".format(len(headers))) - - headers_d = [] - urls_d = [] - for i, header in enumerate(headers): - if check_need_list(header): - headers_d.append(headers[i]) - urls_d.append(urls[i]) - else: - logger.debug("This title {} does not meet the requirements".format(header)) - - header_len = len(headers_d) - logger.debug("Get {} post after processing".format(header_len)) - if header_len > MAXINFO_REIMU: - headers_d = headers_d[:MAXINFO_REIMU] - urls_d = urls_d[:MAXINFO_REIMU] - - for h_s, url_s in zip(headers_d, urls_d): - if h_s != "审核结果存档": - time.sleep(1.5) - putline = await get_son_html_info(h_s, url_s) - if putline: - if repass: - repass = "\n\n- - - - - - - - \n".join([repass, putline]) - else: - repass = putline - else: - logger.info("审核归档页面已跳过") - - if repass: - repass = info + repass - return repass - - -async def get_son_html_info(h_s, url_s) -> str: - repass = "" - logger.debug("Now starting get the {}".format(url_s)) - async with aiohttp.ClientSession(headers=get_user_agent()) as session: - async with session.get(url_s, proxy=get_local_proxy(), timeout=15) as response: - html = etree.HTML(await response.text()) - pres = html.xpath('//div[@class="entry-content"]/pre/text()') - a_texts = html.xpath('//div[@class="entry-content"]/pre//a/text()') - a_hrefs = html.xpath('//div[@class="entry-content"]/pre//a/@href') - - if pres and a_texts and a_hrefs: - while "" in pres: - pres.remove("") - - repass = "【资源名称】 {}\n\n{}".format(h_s, pres[0].strip()) - for i, (a_t_s, a_h_s) in enumerate(zip(a_texts, a_hrefs)): - a = "\n {} {} {} ".format(a_t_s, a_h_s, pres[i + 1].strip()) - repass += a - else: - logger.warning("Not get putline from {}".format(url_s)) - - return repass - - -def check_need_list(header: str) -> bool: - not_need = ['音乐', '御所动态'] - for nd in not_need: - if nd in header: - return False - return True - - -# print(asyncio.get_event_loop().run_until_complete(from_reimu_get_info('萝莉'))) \ No newline at end of file diff --git a/plugins/remind/__init__.py b/plugins/remind/__init__.py deleted file mode 100644 index 8aa57f32..00000000 --- a/plugins/remind/__init__.py +++ /dev/null @@ -1,194 +0,0 @@ -from util.init_result import image -from util.utils import scheduler, get_bot -from services.log import logger -from models.group_remind import GroupRemind -from models.group_info import GroupInfo -from models.friend_user import FriendUser -from nonebot.adapters.cqhttp.exception import ActionFailed - -__name__ = "早晚安 [Hidden]" - - -# 早上好 -@scheduler.scheduled_job( - 'cron', - # year=None, - # month=None, - # day=None, - # week=None, - # day_of_week="mon,tue,wed,thu,fri", - hour=6, - minute=1, - # second=None, - # start_date=None, - # end_date=None, - # timezone=None, -) -async def _(): - try: - bot = get_bot() - gl = await bot.get_group_list(self_id=bot.self_id) - gl = [g['group_id'] for g in gl] - for g in gl: - if await GroupRemind.get_status(g, 'zwa'): - result = image("zao.jpg", "zhenxun") - try: - await bot.send_group_msg(group_id=g, - message="早上好" + result) - except ActionFailed: - logger.warning(f'{g} 群被禁言中,无法发送早安') - except Exception as e: - logger.error(f'早晚安错误 e:{e}') - - -# 睡觉了 -@scheduler.scheduled_job( - 'cron', - hour=23, - minute=59, -) -async def _(): - try: - bot = get_bot() - gl = await bot.get_group_list(self_id=bot.self_id) - gl = [g['group_id'] for g in gl] - for g in gl: - if await GroupRemind.get_status(g, 'zwa'): - result = image("sleep.jpg", "zhenxun") - try: - await bot.send_group_msg(group_id=g, - message="小真寻要睡觉了,你们也要早点睡呀" + result) - except ActionFailed: - logger.warning(f'{g} 群被禁言中,无法发送晚安') - except Exception as e: - logger.error(f'早晚安错误 e:{e}') - - -# 自动更新群组信息 -@scheduler.scheduled_job( - 'cron', - hour=3, - minute=1, -) -async def _(): - try: - bot = get_bot() - gl = await bot.get_group_list(self_id=bot.self_id) - gl = [g['group_id'] for g in gl] - for g in gl: - group_info = await bot.get_group_info(group_id=g) - await GroupInfo.add_group_info(group_info['group_id'], group_info['group_name'], - group_info['max_member_count'], group_info['member_count']) - logger.info(f'自动更新群组 {g} 信息成功') - except Exception as e: - logger.error(f'自动更新群组信息错误 e:{e}') - - -# 自动更新好友信息 -@scheduler.scheduled_job( - 'cron', - hour=3, - minute=1, -) -async def _(): - try: - bot = get_bot() - fl = await bot.get_friend_list(self_id=bot.self_id) - for f in fl: - if await FriendUser.add_friend_info(f['user_id'], f['nickname']): - logger.info(f'自动更新好友 {f["user_id"]} 信息成功') - else: - logger.warning(f'自动更新好友 {f["user_id"]} 信息失败') - except Exception as e: - logger.error(f'自动更新群组信息错误 e:{e}') - -# 一次性任务 -# 固定时间触发,仅触发一次: -# -# from datetime import datetime -# -# @nonebot.scheduler.scheduled_job( -# 'date', -# run_date=datetime(2021, 1, 1, 0, 0), -# # timezone=None, -# ) -# async def _(): -# await bot.send_group_msg(group_id=123456, -# message="2021,新年快乐!") - -# 定期任务 -# 从 start_date 开始到 end_date 结束,根据类似 Cron -# -# 的规则触发任务: -# -# @nonebot.scheduler.scheduled_job( -# 'cron', -# # year=None, -# # month=None, -# # day=None, -# # week=None, -# day_of_week="mon,tue,wed,thu,fri", -# hour=7, -# # minute=None, -# # second=None, -# # start_date=None, -# # end_date=None, -# # timezone=None, -# ) -# async def _(): -# await bot.send_group_msg(group_id=123456, -# message="起床啦!") - -# 间隔任务 -# -# interval 触发器 -# -# 从 start_date 开始,每间隔一段时间触发,到 end_date 结束: -# -# @nonebot.scheduler.scheduled_job( -# 'interval', -# # weeks=0, -# # days=0, -# # hours=0, -# minutes=5, -# # seconds=0, -# # start_date=time.now(), -# # end_date=None, -# ) -# async def _(): -# has_new_item = check_new_item() -# if has_new_item: -# await bot.send_group_msg(group_id=123456, -# message="XX有更新啦!") - - -# 动态的计划任务 -# import datetime -# -# from apscheduler.triggers.date import DateTrigger # 一次性触发器 -# # from apscheduler.triggers.cron import CronTrigger # 定期触发器 -# # from apscheduler.triggers.interval import IntervalTrigger # 间隔触发器 -# from nonebot import on_command, scheduler -# -# @on_command('赖床') -# async def _(session: CommandSession): -# await session.send('我会在5分钟后再喊你') -# -# # 制作一个“5分钟后”触发器 -# delta = datetime.timedelta(minutes=5) -# trigger = DateTrigger( -# run_date=datetime.datetime.now() + delta -# ) -# -# # 添加任务 -# scheduler.add_job( -# func=session.send, # 要添加任务的函数,不要带参数 -# trigger=trigger, # 触发器 -# args=('不要再赖床啦!',), # 函数的参数列表,注意:只有一个值时,不能省略末尾的逗号 -# # kwargs=None, -# misfire_grace_time=60, # 允许的误差时间,建议不要省略 -# # jobstore='default', # 任务储存库,在下一小节中说明 -# ) - - - diff --git a/plugins/remind/__pycache__/__init__.cpython-38.pyc b/plugins/remind/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 66b01987..00000000 Binary files a/plugins/remind/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/remind/__pycache__/__init__.cpython-39.pyc b/plugins/remind/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 0bdff1fb..00000000 Binary files a/plugins/remind/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/search_anime/__init__.py b/plugins/search_anime/__init__.py deleted file mode 100644 index 5935cb11..00000000 --- a/plugins/search_anime/__init__.py +++ /dev/null @@ -1,56 +0,0 @@ -from nonebot import on_command -from .data_source import from_anime_get_info -from services.log import logger -from nonebot.adapters.cqhttp import Bot, Event -from nonebot.typing import T_State -from configs.config import MAXINFO_GROUP_ANIME, MAXINFO_PRIVATE_ANIME -from util.utils import get_message_text, get_message_type, UserExistLimiter - - -__plugin_name__ = '搜番' -__plugin_usage__ = r""" -在群内使用此功能只返还5个结果,私聊返还 20 个结果(绝不能打扰老色批们看色图!) -搜索动漫资源 -搜番 [番剧名称或者关键词] -搜番 Aria -""".strip() -_ulmt = UserExistLimiter() - -search_anime = on_command('搜番', aliases={'搜动漫'}, priority=5, block=True) - - -@search_anime.args_parser -async def _(bot: Bot, event: Event, state: T_State): - msg = get_message_text(event.json()) - if not msg: - await search_anime.reject('番名番名番名呢?', at_sender=True) - state['anime'] = msg - - -@search_anime.handle() -async def _(bot: Bot, event: Event, state: T_State): - if get_message_text(event.json()) in ['帮助'] or get_message_text(event.json()) == '': - await search_anime.finish(__plugin_usage__) - if _ulmt.check(event.user_id): - await search_anime.finish('您有动漫正在搜索,请稍等...', at_sender=True) - _ulmt.set_True(event.user_id) - if get_message_text(event.json()): - state['anime'] = get_message_text(event.json()) - - -@search_anime.got('anime', prompt='是不是少了番名?') -async def _(bot: Bot, event: Event, state: T_State): - key_word = state['anime'] - await search_anime.send(f'开始搜番 {key_word}', at_sender=True) - anime_report = await from_anime_get_info(key_word, MAXINFO_GROUP_ANIME if get_message_type(event.json()) in ['group', 'discuss'] else MAXINFO_PRIVATE_ANIME) - if anime_report: - await search_anime.send(anime_report) - logger.info(f"USER {event.user_id} GROUP" - f" {event.group_id if event.message_type != 'private' else 'private'} 搜索番剧 {key_word} 成功") - else: - logger.warning(f"未找到番剧 {key_word}") - await search_anime.send(f"未找到番剧 {key_word}(也有可能是超时,再尝试一下?)") - _ulmt.set_False(event.user_id) - - - diff --git a/plugins/search_anime/__pycache__/__init__.cpython-38.pyc b/plugins/search_anime/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index d76b6f08..00000000 Binary files a/plugins/search_anime/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/search_anime/__pycache__/__init__.cpython-39.pyc b/plugins/search_anime/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index fe2b4e6d..00000000 Binary files a/plugins/search_anime/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/search_anime/__pycache__/data_source.cpython-38.pyc b/plugins/search_anime/__pycache__/data_source.cpython-38.pyc deleted file mode 100644 index d8695b62..00000000 Binary files a/plugins/search_anime/__pycache__/data_source.cpython-38.pyc and /dev/null differ diff --git a/plugins/search_anime/__pycache__/data_source.cpython-39.pyc b/plugins/search_anime/__pycache__/data_source.cpython-39.pyc deleted file mode 100644 index 523f3a71..00000000 Binary files a/plugins/search_anime/__pycache__/data_source.cpython-39.pyc and /dev/null differ diff --git a/plugins/search_anime/data_source.py b/plugins/search_anime/data_source.py deleted file mode 100644 index d0cd330a..00000000 --- a/plugins/search_anime/data_source.py +++ /dev/null @@ -1,47 +0,0 @@ -from lxml import etree -import feedparser -from urllib import parse -from services.log import logger -import aiohttp -import time -from util.utils import get_local_proxy - - -async def from_anime_get_info(key_word: str, max: int) -> str: - s_time = time.time() - repass = "" - url = 'https://share.dmhy.org/topics/rss/rss.xml?keyword=' + parse.quote(key_word) - try: - logger.debug("Now starting get the {}".format(url)) - repass = await get_repass(url, max) - except Exception as e: - logger.error("Timeout! {}".format(e)) - - return f"搜索 {key_word} 结果(耗时 {int(time.time() - s_time)} 秒):\n" + repass - - -async def get_repass(url: str, max: int) -> str: - putline = [] - async with aiohttp.ClientSession() as session: - async with session.get(url, proxy=get_local_proxy(), timeout=20) as response: - d = feedparser.parse(await response.text()) - url_list = [e.link for e in d.entries][:max] - for u in url_list: - print(u) - try: - async with session.get(u, proxy=get_local_proxy(), timeout=20) as res: - html = etree.HTML(await res.text()) - magent = html.xpath('.//a[@id="a_magnet"]/text()')[0] - title = html.xpath('.//h3/text()')[0] - item = html.xpath('//div[@class="info resource-info right"]/ul/li') - class_a = item[0].xpath('string(.)')[5:].strip().replace("\xa0", "").replace("\t", "") - size = item[3].xpath('string(.)')[5:].strip() - - putline.append("【{}】| {}\n【{}】| {}".format(class_a, title, size, magent)) - except Exception as e: - logger.warning(f'搜番超时 e:{e}') - - repass = '\n\n'.join(putline) - - return repass -# print(asyncio.get_event_loop().run_until_complete(from_anime_get_info('进击的巨人', 1234556))) \ No newline at end of file diff --git a/plugins/search_buff_skin_price/__init__.py b/plugins/search_buff_skin_price/__init__.py deleted file mode 100644 index bbb2d276..00000000 --- a/plugins/search_buff_skin_price/__init__.py +++ /dev/null @@ -1,75 +0,0 @@ -from nonebot import on_command -from .data_source import get_price, update_buff_cookie -from services.log import logger -from nonebot.typing import T_State -from nonebot.adapters import Bot, Event -from nonebot.rule import to_me -from nonebot.permission import SUPERUSER -from util.utils import UserExistLimiter, get_message_text - - -__plugin_name__ = '查询皮肤' -__plugin_usage__ = '查询皮肤帮助:\n\t' \ - '对我说 "查询皮肤 xxx yyyy",我会回复xxx的底价哦\n\t' \ - '示例: 查询皮肤 awp 二西莫夫' - - -_ulmt = UserExistLimiter() - - -search_skin = on_command('查询皮肤', aliases={'皮肤查询'}, priority=5, block=True) - - -@search_skin.args_parser -async def parse(bot: Bot, event: Event, state: T_State): - if get_message_text(event.json()) in ['取消', '算了']: - await search_skin.finish("已取消操作..", at_sender=True) - state[state["_current_key"]] = str(event.get_message()) - - -@search_skin.handle() -async def _(bot: Bot, event: Event, state: T_State): - if str(event.get_message()) in ['帮助']: - await search_skin.finish(__plugin_usage__) - raw_arg = get_message_text(event.json()) - if _ulmt.check(event.user_id): - await search_skin.finish('您有皮肤正在搜索,请稍等...', at_sender=True) - if raw_arg: - args = raw_arg.split(" ") - if len(args) >= 2: - state['name'] = args[0] - state['skin'] = args[1] - - -@search_skin.got('name', prompt="要查询什么武器呢?") -@search_skin.got('skin', prompt="要查询该武器的什么皮肤呢?") -async def arg_handle(bot: Bot, event: Event, state: T_State): - _ulmt.set_True(event.user_id) - if state['name'] in ['ak', 'ak47']: - state['name'] = 'ak-47' - name = state['name'] + " | " + state['skin'] - try: - result, status_code = await get_price(name) - except FileNotFoundError: - await search_skin.finish('请先对真寻说"设置cookie"来设置cookie!') - if status_code in [996, 997, 998]: - _ulmt.set_False(event.user_id) - await search_skin.finish(result) - if result: - logger.info( - f"(USER {event.user_id}, GROUP {event.group_id if event.message_type != 'private' else 'private'}) 查询皮肤:" + name) - _ulmt.set_False(event.user_id) - await search_skin.finish(result) - else: - logger.info(f"USER {event.user_id}, GROUP {event.group_id if event.message_type != 'private' else 'private'}" - f" 查询皮肤:{name} 没有查询到") - _ulmt.set_False(event.user_id) - await search_skin.finish("没有查询到哦,请检查格式吧") - - -update_buff_session = on_command("更新cookie", rule=to_me(), permission=SUPERUSER, priority=1) - - -@update_buff_session.handle() -async def _(bot: Bot, event: Event, state: T_State): - await update_buff_session.finish(update_buff_cookie(str(event.get_message())), at_sender=True) diff --git a/plugins/search_buff_skin_price/__pycache__/__init__.cpython-38.pyc b/plugins/search_buff_skin_price/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index ed820bdf..00000000 Binary files a/plugins/search_buff_skin_price/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/search_buff_skin_price/__pycache__/__init__.cpython-39.pyc b/plugins/search_buff_skin_price/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index dd938c3f..00000000 Binary files a/plugins/search_buff_skin_price/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/search_buff_skin_price/__pycache__/data_source.cpython-38.pyc b/plugins/search_buff_skin_price/__pycache__/data_source.cpython-38.pyc deleted file mode 100644 index 98aff86a..00000000 Binary files a/plugins/search_buff_skin_price/__pycache__/data_source.cpython-38.pyc and /dev/null differ diff --git a/plugins/search_buff_skin_price/__pycache__/data_source.cpython-39.pyc b/plugins/search_buff_skin_price/__pycache__/data_source.cpython-39.pyc deleted file mode 100644 index ad827da6..00000000 Binary files a/plugins/search_buff_skin_price/__pycache__/data_source.cpython-39.pyc and /dev/null differ diff --git a/plugins/search_buff_skin_price/data_source.py b/plugins/search_buff_skin_price/data_source.py deleted file mode 100644 index 192925d0..00000000 --- a/plugins/search_buff_skin_price/data_source.py +++ /dev/null @@ -1,66 +0,0 @@ -from util.user_agent import get_user_agent -import aiohttp -from util.utils import get_cookie_text -from configs.path_config import TXT_PATH -from asyncio.exceptions import TimeoutError -from configs.config import buff_proxy -from pathlib import Path -from services.log import logger - - -url = "https://buff.163.com/api/market/goods" - - -async def get_price(dname): - cookie = {'session': get_cookie_text('buff')} - name_list = [] - price_list = [] - parameter = { - "game": "csgo", - "page_num": "1", - "search": dname - } - try: - async with aiohttp.ClientSession(cookies=cookie, headers=get_user_agent()) as session: - async with session.get(url, proxy=buff_proxy, params=parameter, timeout=5) as response: - if response.status == 200: - try: - if str(await response.text()).find("Login Required") != -1: - return "BUFF登录被重置,请联系管理员重新登入", 996 - data = (await response.json())["data"] - total_page = data["total_page"] - data = data["items"] - for _ in range(total_page): - for i in range(len(data)): - name = data[i]["name"] - price = data[i]["sell_reference_price"] - name_list.append(name) - price_list.append(price) - except Exception as e: - return "没有查询到...", 998 - else: - return "访问失败!", response.status - except TimeoutError as e: - return "访问超时! 请重试或稍后再试!", 997 - result = f"皮肤: {dname}({len(name_list)})\n" - # result = "皮肤: " + dname + "\n" - for i in range(len(name_list)): - result += name_list[i] + ": " + price_list[i] + "\n" - return result[:-1], 999 - - -def update_buff_cookie(cookie: str): - _cookie = Path(TXT_PATH + "cookie/buff.txt") - try: - _cookie.parent.mkdir(parents=True, exist_ok=True) - with open(_cookie, 'w') as f: - f.write(cookie) - return "更新cookie成功" - except Exception as e: - logger.error(f'更新cookie失败 e:{e}') - return "更新cookie失败" - - -if __name__ == '__main__': - print(get_price("awp 二西莫夫")) - diff --git a/plugins/send_dinggong_voice/__init__.py b/plugins/send_dinggong_voice/__init__.py deleted file mode 100644 index 04c7ea09..00000000 --- a/plugins/send_dinggong_voice/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -from nonebot import on_keyword -from util.init_result import record -from configs.path_config import VOICE_PATH -import random -from services.log import logger -from util.utils import FreqLimiter -from nonebot.typing import T_State -from nonebot.adapters.cqhttp import Bot, MessageEvent -from nonebot.rule import to_me -import os - -__plugin_name__ = '骂我' -__plugin_usage__ = '对我说 "骂我",我真的会骂你哦' - -_flmt = FreqLimiter(3) - - -dg_voice = on_keyword({'骂'}, rule=to_me(), priority=5, block=True) - - -@dg_voice.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - if len(str((event.get_message()))) == 1: - return - if not _flmt.check(event.user_id): - await dg_voice.finish('就...就算求我骂你也得慢慢来...', at_sender=True) - _flmt.start_cd(event.user_id) - voice = random.choice(os.listdir(VOICE_PATH + 'dinggong/')) - result = record(voice, "dinggong") - await dg_voice.send(result) - await dg_voice.send(voice.split('_')[1]) - logger.info( - f"(USER {event.user_id}, GROUP {event.group_id if event.message_type != 'private' else 'private'}) 发送钉宫骂人:" + result) \ No newline at end of file diff --git a/plugins/send_dinggong_voice/__pycache__/__init__.cpython-38.pyc b/plugins/send_dinggong_voice/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 23a3bd0f..00000000 Binary files a/plugins/send_dinggong_voice/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/send_dinggong_voice/__pycache__/__init__.cpython-39.pyc b/plugins/send_dinggong_voice/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index a68a0c8e..00000000 Binary files a/plugins/send_dinggong_voice/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/send_img/__init__.py b/plugins/send_img/__init__.py deleted file mode 100644 index bee83a16..00000000 --- a/plugins/send_img/__init__.py +++ /dev/null @@ -1,68 +0,0 @@ -from nonebot import on_command, on_keyword -from configs.path_config import IMAGE_PATH -from util.init_result import image -import os -import random -from util.utils import is_number -from services.log import logger -from nonebot.typing import T_State -from nonebot.adapters import Bot, Event -from util.utils import FreqLimiter, cn2py -from models.group_remind import GroupRemind -from configs.config import IMAGE_DIR_LIST - - -__plugin_name__ = '壁纸/萝莉/美图' -__plugin_usage__ = '用法: 发送"壁纸/萝莉/美图", 回复图片,后添加id获得指定图片' - -_flmt = FreqLimiter(1) - -IMAGE_DIR_LIST.remove('色图') -cmd = set(IMAGE_DIR_LIST) - -# print(cmd) - -send_img = on_command("img", aliases=cmd, priority=5, block=True) - - -@send_img.handle() -async def _(bot: Bot, event: Event, state: T_State): - img_id = str(event.get_message()) - if img_id in ['帮助']: - await send_img.finish(__plugin_usage__) - path = cn2py(state["_prefix"]["raw_command"]) + '/' - if not os.path.exists(IMAGE_PATH + path): - logger.warning(f'未找到 {path} 文件夹,调用取消!') - return - length = len(os.listdir(IMAGE_PATH + path)) - 1 - index = img_id if img_id else str(random.randint(0, length)) - if not is_number(index): - await send_img.finish("id错误!") - if int(index) > length or int(index) < 0: - await send_img.finish(f"超过当前上下限!({length - 1})") - result = image(f'{index}.jpg', path) - if result: - logger.info( - f"(USER {event.user_id}, GROUP {event.group_id if event.message_type != 'private' else 'private'}) 发送{path}:" + result) - await send_img.finish(f"id:{index}" + result) - else: - logger.info( - f"(USER {event.user_id}, GROUP {event.group_id if event.message_type != 'private' else 'private'}) 发送 {path} 失败") - await send_img.finish(f"不想给你看Ov|") - - -pa = on_keyword({"爬"}, priority=1, block=True) - - -@pa.handle() -async def _(bot: Bot, event: Event, state: T_State): - if await GroupRemind.get_status(event.group_id, 'pa'): - try: - if str(event.get_message()[:2]) in ['开启', '关闭']: - return - except: - return - if not _flmt.check(event.user_id): - return - _flmt.start_cd(event.user_id) - await pa.finish(image(random.choice(os.listdir(IMAGE_PATH + "pa")), 'pa')) diff --git a/plugins/send_img/__pycache__/__init__.cpython-38.pyc b/plugins/send_img/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 3b704098..00000000 Binary files a/plugins/send_img/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/send_img/__pycache__/__init__.cpython-39.pyc b/plugins/send_img/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index b273a113..00000000 Binary files a/plugins/send_img/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/send_setu/__init__.py b/plugins/send_setu/__init__.py deleted file mode 100644 index 53c47585..00000000 --- a/plugins/send_setu/__init__.py +++ /dev/null @@ -1,276 +0,0 @@ -import random -from nonebot import on_command, on_regex -from services.log import logger -from models.sigin_group_user import SignGroupUser -from util.utils import FreqLimiter, UserExistLimiter, is_number, get_message_text, get_message_imgs -from nonebot.typing import T_State -from nonebot.adapters.cqhttp import Bot, MessageEvent, GroupMessageEvent, PrivateMessageEvent -from .data_source import get_setu, get_luoxiang, search_online_setu, get_setu_urls, \ - check_r18_and_keyword, find_img_index -from nonebot.adapters.cqhttp.exception import ActionFailed -import re -from models.count_user import UserCount -from aiohttp.client_exceptions import ClientConnectorError -from configs.config import LOCAL_SETU - -__plugin_name__ = '色图' -__plugin_usage__ = '''示例: - 1. 色图 (随机本地色图) - 2. 色图r (随机在线十张r18涩图) - 3. 色图 666 (本地色图id) - 4. 色图 xx (在线搜索xx色图) - 5. 色图r xx (搜索十张xx的r18涩图,注意空格)(仅私聊) - 6. 来n张涩图 (本地涩图连发)(1<=n<=9) - 7. 来n张xx的涩图 (在线搜索xx涩图)(较慢,看网速) -注:【色图r每日提供5次 - 本地涩图没有r18! - 联网搜索会较慢! - 如果图片数量与数字不符, - 原因1:网络不好,网线被拔QAQ - 原因2:搜索到的总数小于数字 - 原因3:图太色或者小错误了】''' - -url = "https://api.lolicon.app/setu/" -_flmt = FreqLimiter(5) -_ulmt = UserExistLimiter() -path = "setu/" -MAX_COUNT = 5 - - -setu = on_command("色图", aliases={"涩图", "不够色", "来一发", "再来点"}, priority=5, block=True) -setu_reg = on_regex('(.*)[份|发|张|个|次|点](.*)[瑟|色|涩]图', priority=5, block=True) -find_setu = on_command("查色图", priority=5, block=True) - - -@setu.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - img_id = get_message_text(event.json()) - if img_id in ['帮助']: - await setu.finish(__plugin_usage__) - impression = (await SignGroupUser.ensure(event.user_id, event.group_id)).impression - luox = get_luoxiang(impression) - if luox: - await setu.finish(luox) - if not _flmt.check(event.user_id): - await setu.finish('您冲得太快了,请稍候再冲', at_sender=True) - _flmt.start_cd(event.user_id) - if _ulmt.check(event.user_id): - await setu.finish(f"您有色图正在处理,请稍等") - _ulmt.set_True(event.user_id) - setu_img, index = get_setu(img_id) - if setu_img and LOCAL_SETU: - try: - await setu.send(setu_img) - except: - _ulmt.set_False(event.user_id) - await setu.finish('这张图色过头了,我自己看看就行了!', at_sender=True) - logger.info( - f"USER {event.user_id} GROUP {event.group_id} 发送色图 {index}.jpg 成功") - else: - msg = img_id - if msg.find(list(bot.config.nickname)[0]) != -1: - _ulmt.set_False(event.user_id) - await setu.finish('咳咳咳,虽然我很可爱,但是我木有自己的色图~~~有的话记得发我一份呀') - keyword, r18, num = await check_r18_and_keyword(msg, event.user_id) - if r18 == 1: - _ulmt.set_False(event.user_id) - await setu.finish(random.choice([ - "这种不好意思的东西怎么可能给这么多人看啦", - "羞羞脸!给我滚出克私聊!", - "变态变态变态变态大变态!" - ])) - try: - urls, text_list, code = await get_setu_urls(keyword, num, r18=r18) - except ClientConnectorError: - await setu.finish('网络失败了..别担心!正在靠运气上网!', at_sender=True) - else: - if code == 200: - for i in range(num): - try: - setu_img, index = await search_online_setu(urls[i]) - await setu.send(text_list[i] + setu_img) - logger.info( - f"USER {event.user_id} GROUP {event.group_id}" - f" 发送在线色图 {keyword}.jpg 成功") - except Exception as e: - logger.error(f'色图发送错误 e:{e}') - await setu.send('图片下载惜败!', at_sender=True) - else: - await setu.send(urls) - _ulmt.set_False(event.user_id) - - -@setu.handle() -async def _(bot: Bot, event: PrivateMessageEvent, state: T_State): - img_id = get_message_text(event.json()) - if img_id in ['帮助']: - await setu.finish(__plugin_usage__) - if not _flmt.check(event.user_id): - await setu.finish('您冲得太快了,请稍候再冲', at_sender=True) - _flmt.start_cd(event.user_id) - if _ulmt.check(event.user_id): - await setu.finish(f"您有色图正在处理,请稍等") - _ulmt.set_True(event.user_id) - setu_img, index = get_setu(img_id) - if setu_img: - await setu.send(setu_img) - logger.info( - f"USER {event.user_id} GROUP private 发送色图 {index}.jpg 成功") - else: - msg = img_id - if msg.find(list(bot.config.nickname)[0]) != -1: - _ulmt.set_False(event.user_id) - await setu.finish('咳咳咳,虽然我很可爱,但是我木有自己的色图~~~有的话记得发我一份呀') - keyword, r18, num = await check_r18_and_keyword(msg, event.user_id) - if r18 == 1: - if await UserCount.check_count(event.user_id, 'setu_r18', MAX_COUNT): - _ulmt.set_False(event.user_id) - await setu.finish('要节制啊,请明天再来...\n【每日提供5次】', at_sender=True) - try: - urls, text_list, code = await get_setu_urls(keyword, num, r18=r18) - except ClientConnectorError: - await UserCount.add_count(event.user_id, 'setu_r18', count=-1) - await setu.finish('网络失败了..别担心!这次搜索不算数喔', at_sender=True) - else: - count = 0 - if code == 200: - for i in range(num): - try: - setu_img, index = await search_online_setu(urls[i]) - await setu.send(text_list[i] + setu_img) - logger.info( - f"USER {event.user_id} GROUP private" - f" 发送{'r18' if img_id == 'r' else ''}色图 {index}.jpg 成功") - except Exception as e: - logger.error(f'色图发送错误 e:{e}') - await setu.send('图片下载惜败!', at_sender=True) - count += 1 - if count > 6: - await setu.send('检测到下载惜败的图片过多,这次就不算数了,果咩..', at_sender=True) - await UserCount.add_count(event.user_id, 'setu_r18', count=-1) - else: - if code == 401: - if r18 == 1: - await UserCount.add_count(event.user_id, 'setu_r18', count=-1) - await setu.send(urls + ' 色图r次数返还!') - else: - await setu.send(urls, at_sender=True) - else: - if r18 == 1: - await setu.send('这次不是小真寻的戳!色图r次数返还!', at_sender=True) - await UserCount.add_count(event.user_id, 'setu_r18', count=-1) - else: - await setu.send(urls, at_sender=True) - _ulmt.set_False(event.user_id) - - -num_key = { - '一': 1, - '二': 2, - '两': 2, - '双': 2, - '三': 3, - '四': 4, - '五': 5, - '六': 6, - '七': 7, - '八': 8, - '九': 9 -} - - -@setu_reg.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - if event.message_type == "group": - impression = (await SignGroupUser.ensure(event.user_id, event.group_id)).impression - luox = get_luoxiang(impression) - if luox: - await setu.finish(luox, at_sender=True) - if _ulmt.check(event.user_id): - await setu.finish(f"您有色图正在处理,请稍等") - _ulmt.set_True(event.user_id) - if not _flmt.check(event.user_id): - _ulmt.set_False(event.user_id) - await setu.finish('您冲得太快了,请稍候再冲', at_sender=True) - _flmt.start_cd(event.user_id) - msg = get_message_text(event.json()) - num = 1 - msg = re.search(r'(.*)[份|发|张|个|次|点](.*)[瑟|涩|色]图', msg) - if msg: - num = msg.group(1) - keyword = msg.group(2) - if keyword: - if keyword[-1] == '的': - keyword = keyword[:-1] - if num: - num = num[-1] - if num_key.get(num): - num = num_key[num] - elif is_number(num): - try: - num = int(num) - except ValueError: - num = 1 - else: - num = 1 - else: - return - # try: - if not keyword: - for _ in range(num): - try: - img, index = get_setu('') - await setu_reg.send(img) - except Exception as e: - await setu_reg.send('有图太色了发不出来...') - else: - logger.info( - f"USER {event.user_id} GROUP {event.group_id if event.message_type != 'private' else 'private'}" - f" 发送 {index} 色图成功") - else: - urls, text_list, code = await get_setu_urls(keyword, num) - if code == 200: - for i in range(len(urls)): - try: - setu_img, index = await search_online_setu(urls[i]) - await setu_reg.send(text_list[i] + '\n' + setu_img) - except ActionFailed as e: - await setu_reg.send('这图太色了,会教坏小孩子的,不给看..') - else: - logger.info( - f"USER {event.user_id} GROUP {event.group_id if event.message_type != 'private' else 'private'}" - f" 发送 {keyword} {num}连 色图成功") - else: - _ulmt.set_False(event.user_id) - await setu_reg.finish(urls, at_sender=True) - _ulmt.set_False(event.user_id) - - -@find_setu.args_parser -async def _(bot: Bot, event: MessageEvent, state: T_State): - if str(event.message) == '取消': - await find_setu.finish('取消了操作', at_sender=True) - imgs = get_message_imgs(event.json()) - if not imgs: - await find_setu.reject("不搞错了,俺要图!") - state['img'] = imgs[0] - - -@find_setu.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - if get_message_text(event.json()) in ['帮助']: - await find_setu.finish('通过图片获取本地色图id\n\t示例:查色图(图片)') - imgs = get_message_imgs(event.json()) - if imgs: - state['img'] = imgs[0] - - -@find_setu.got('img', prompt="速速来图!") -async def _(bot: Bot, event: MessageEvent, state: T_State): - img = state['img'] - await find_setu.send(await find_img_index(img, event.user_id), at_sender=True) - - - - - diff --git a/plugins/send_setu/__pycache__/__init__.cpython-38.pyc b/plugins/send_setu/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 5be3bf33..00000000 Binary files a/plugins/send_setu/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/send_setu/__pycache__/__init__.cpython-39.pyc b/plugins/send_setu/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index e338e02f..00000000 Binary files a/plugins/send_setu/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/send_setu/__pycache__/data_source.cpython-38.pyc b/plugins/send_setu/__pycache__/data_source.cpython-38.pyc deleted file mode 100644 index a8fdc4be..00000000 Binary files a/plugins/send_setu/__pycache__/data_source.cpython-38.pyc and /dev/null differ diff --git a/plugins/send_setu/__pycache__/data_source.cpython-39.pyc b/plugins/send_setu/__pycache__/data_source.cpython-39.pyc deleted file mode 100644 index 579aaa8a..00000000 Binary files a/plugins/send_setu/__pycache__/data_source.cpython-39.pyc and /dev/null differ diff --git a/plugins/send_setu/check_setu_hash.py b/plugins/send_setu/check_setu_hash.py deleted file mode 100644 index efbd9e6d..00000000 --- a/plugins/send_setu/check_setu_hash.py +++ /dev/null @@ -1,62 +0,0 @@ -import os -import imagehash -from PIL import Image -try: - import ujson as json -except ModuleNotFoundError: - import json - -IMAGE_PATH = r"/home/hibiki/hibikibot/resources/img/" -TXT_PATH = r"/home/hibiki/hibikibot/resources/txt/" - - -def get_img_hash(image_file): - with open(image_file, 'rb') as fp: - hash_value = imagehash.average_hash(Image.open(fp)) - return hash_value - - -def check_file_index(): - for dir_name in ['setu/', 'r18/']: - lens = len(os.listdir(IMAGE_PATH + dir_name)) - for i in range(lens): - if i > lens: - return - if not os.path.exists(f"{IMAGE_PATH}{dir_name}{i}.jpg"): - os.rename(f"{IMAGE_PATH}{dir_name}{lens}.jpg", f"{IMAGE_PATH}{dir_name}{i}.jpg") - print(f'{lens}.jpg --> {i}.jpg') - lens -= 1 - if not i % 100: - print(f'已检测 {i} 份数据') - print(f'{dir_name} 检测完毕') - - -def check_setu_hash(): - check_file_index() - for dir_name in ['setu/', 'r18/']: - img_data = {} - if dir_name == 'setu/': - fn = 'setu_img_hash.json' - else: - fn = 'r18_setu_img_hash.json' - file_list_len = len(os.listdir(IMAGE_PATH + dir_name)) - 1 - print(file_list_len) - for i in range(file_list_len): - file = f"{i}.jpg" - index = file.split(".")[0] - img_hash = str(get_img_hash(IMAGE_PATH + dir_name + file)) - print(f'{index}.jpg --> {img_hash}') - if img_hash in img_data.values(): - k = [k for k, v in img_data.items() if v == img_hash] - print(f'文件 {index}.jpg 与 {k}.jpg 重复,使用 {file_list_len}.jpg 进行替换') - os.remove(IMAGE_PATH + dir_name + file) - os.rename(IMAGE_PATH + f'{dir_name}{file_list_len}.jpg', IMAGE_PATH + dir_name + file) - file_list_len -= 1 - continue - img_data[index] = img_hash - # print(f'{index}.jpg --> {img_data}') - with open(TXT_PATH + fn, 'w') as f: - json.dump(img_data, f, indent=4) - - -check_setu_hash() \ No newline at end of file diff --git a/plugins/send_setu/data_source.py b/plugins/send_setu/data_source.py deleted file mode 100644 index 43af3045..00000000 --- a/plugins/send_setu/data_source.py +++ /dev/null @@ -1,168 +0,0 @@ -from configs.path_config import IMAGE_PATH, TXT_PATH -import os -import random -from util.init_result import image -from configs.config import LOLICON_KEY -import aiohttp -import aiofiles -from services.log import logger -from util.img_utils import get_img_hash -from util.utils import get_local_proxy, is_number -from asyncio.exceptions import TimeoutError -from models.count_user import UserCount -from configs.config import DOWNLOAD_SETU -try: - import ujson as json -except ModuleNotFoundError: - import json - - -url = "https://api.lolicon.app/setu/" -path = 'setu/' - - -async def get_setu_urls(keyword: str, num: int = 1, r18: int = 0): - # print(keyword) - if r18 == 1: - file_name = 'setu_r18_url.txt' - else: - file_name = 'setu_url.txt' - try: - with open(TXT_PATH + file_name, 'r') as f: - txt_data = f.read() - except FileNotFoundError: - txt_data = '' - params = { - "apikey": LOLICON_KEY, # 添加apikey - 'r18': r18, # 添加r18参数 0为否,1为是,2为混合 - 'keyword': keyword, # 若指定关键字,将会返回从插画标题、作者、标签中模糊搜索的结果 - 'num': num, # 一次返回的结果数量,范围为1到10,不提供 APIKEY 时固定为1 - 'size1200': 1, # 是否使用 master_1200 缩略图,以节省流量或提升加载速度 - } - urls = [] - text_list = [] - for count in range(3): - print(f'get_setu_url: count --> {count}') - async with aiohttp.ClientSession() as session: - try: - async with session.get(url, proxy=get_local_proxy(), timeout=5, params=params) as response: - if response.status == 429: - return '调用达到上限,明日赶早呀~', '', 429 - if response.status == 404: - return "网站裂开了...", '', 998 - if response.status == 200: - data = await response.json() - if data['code'] == 0: - # print(len(data['data'])) - for i in range(len(data['data'])): - img_url = data['data'][i]['url'] - title = data['data'][i]['title'] - author = data['data'][i]['author'] - pid = data['data'][i]['pid'] - urls.append(img_url) - text_list.append(f'title:{title}\nauthor:{author}\nPID:{pid}') - img_url = str(img_url).replace('img-master', 'img-original').replace('_master1200', '') - txt_data += img_url + ',' - if DOWNLOAD_SETU: - with open(TXT_PATH + file_name, 'w') as f: - f.write(txt_data) - return urls, text_list, 200 - else: - return "没找到符合条件的色图...", '', 401 - except TimeoutError: - pass - return '我网线被人拔了..QAQ', '', 999 - - -async def search_online_setu(url: str): - async with aiohttp.ClientSession() as session: - for i in range(3): - print(f'search_online_setu --> {i}') - try: - async with session.get(url, proxy=get_local_proxy(), timeout=7) as res: - if res.status == 200: - index = str(random.randint(1, 100000)) - async with aiofiles.open(IMAGE_PATH + 'temp/' + index + "_temp_setu.jpg", 'wb') as f: - try: - await f.write(await res.read()) - except TimeoutError: - # return '\n这图没下载过来~(网太差?)', -1, False - continue - logger.info(f"下载 lolicon图片 {url} 成功, id:{index}") - return image(f'{index}_temp_setu.jpg', 'temp'), index - else: - logger.warning(f"访问 lolicon图片 {url} 失败 status:{res.status}") - # return '\n这图好难下载啊!QAQ', -1, False - except TimeoutError: - pass - return '\n图片被小怪兽恰掉啦..!QAQ', -1 - - -def get_setu(index: str): - length = len(os.listdir(IMAGE_PATH + path)) - if not index: - index = random.randint(0, length - 1) - if is_number(index): - if int(index) > length or int(index) < 0: - return f"超过当前上下限!({length - 1})", 999 - else: - return f'id:{index}' + image(f'{index}.jpg', 'setu'), index - return None, None - - -def get_luoxiang(impression): - probability = impression + 70 - if probability < random.randint(1, 101): - return "我为什么要给你发这个?" + image(random.choice(os.listdir(IMAGE_PATH + "luoxiang/")), 'luoxiang') + \ - "\n(快向小真寻签到提升好感度吧!)" - return None - - -async def check_r18_and_keyword(msg: str, user_id) -> 'str, int, int': - msg_list = msg.split(' ') - num = 1 - r18 = 0 - keyword = '' - if len(msg_list) == 1: - if msg_list[0].strip().lower() in ['r', 'r18']: - r18 = 1 - num = 10 - else: - keyword = msg_list[0] - elif len(msg_list) == 2: - keyword = msg_list[1].strip() - if msg_list[0].strip().lower() in ['r', 'r18']: - r18 = 1 - num = 10 - else: - keyword = msg[0] - if r18 == 1: - await UserCount.add_user(user_id) - return keyword, r18, num - - -# def delete_img(index): -# if os.path.exists(IMAGE_PATH + path + f"{index}.jpg"): -# img_hash = str(get_img_hash(IMAGE_PATH + f"setu/{index}.jpg")) -# tp = list(setu_hash_dict.keys())[list(setu_hash_dict.values()).index(img_hash)] -# logger.info(f"色图 {index}.jpg 与 {tp}.jpg 相似, 删除....") -# os.remove(IMAGE_PATH + path + f"{index}.jpg") - - -async def find_img_index(img_url, user_id): - try: - setu_hash_dict = json.load(open(TXT_PATH + 'setu_img_hash.json')) - except (FileNotFoundError, ValueError): - setu_hash_dict = {} - async with aiohttp.ClientSession() as session: - async with session.get(img_url, proxy=get_local_proxy(), timeout=5) as res: - async with aiofiles.open(IMAGE_PATH + f"temp/{user_id}_find_setu_index.jpg", 'wb') as f: - await f.write(await res.read()) - img_hash = str(get_img_hash(IMAGE_PATH + f"temp/{user_id}_find_setu_index.jpg")) - try: - tp = list(setu_hash_dict.keys())[list(setu_hash_dict.values()).index(img_hash)] - return "id --> " + str(tp) - except ValueError: - return "该图不在色图库中!" - - diff --git a/plugins/server_ip.py b/plugins/server_ip.py deleted file mode 100644 index 4305a684..00000000 --- a/plugins/server_ip.py +++ /dev/null @@ -1,36 +0,0 @@ -from nonebot import on_command -from nonebot.adapters.cqhttp import Bot, PrivateMessageEvent, GroupMessageEvent -from nonebot.typing import T_State -from nonebot.rule import to_me - -__plugin_name__ = '服务器' -__plugin_usage__ = '用法: 无' - - -server_ip = on_command("服务器", aliases={'ip'}, rule=to_me(), priority=5, block=True) - - -@server_ip.handle() -async def _(bot: Bot, event: PrivateMessageEvent, state: T_State): - await server_ip.finish("|* 请不要发给其他人! *|\n" - "\t121.40.195.22\n" - "|* 请不要发给其他人! *|\n" - "csgo ~号键控制台输入 connect 121.40.195.22 进入服务器\n" - "然后再公屏输入 !diy 来使用皮肤(英文感叹号,注意)\n" - "【说不定可以凑到内战噢,欢迎~{娱乐为主,别骂人球球了}】", at_sender=True) - - -@server_ip.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - if event.group_id == 698279647: - await server_ip.finish("嗨呀!当前服务器地址是:" - "\ncsgo:\n\tay: 121.40.195.22\n\twzt: 101.200.199.143\n我的世界:\n\t47.111.1.220:25565") - elif event.group_id == 1046451860: - await server_ip.finish("嗨呀!当前服务器地址是:\n121.40.195.22\n !diy") - else: - await server_ip.finish("不好意思呀,小真寻不能为你使用此功能,因为服务器IP是真寻的小秘密呀!", at_sender=True) - - - - - diff --git a/plugins/shop/__init__.py b/plugins/shop/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/plugins/shop/__pycache__/__init__.cpython-38.pyc b/plugins/shop/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 3cf9d4e4..00000000 Binary files a/plugins/shop/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/shop/__pycache__/__init__.cpython-39.pyc b/plugins/shop/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index bc7edeb0..00000000 Binary files a/plugins/shop/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/shop/__pycache__/buy.cpython-38.pyc b/plugins/shop/__pycache__/buy.cpython-38.pyc deleted file mode 100644 index 5e1525e8..00000000 Binary files a/plugins/shop/__pycache__/buy.cpython-38.pyc and /dev/null differ diff --git a/plugins/shop/__pycache__/buy.cpython-39.pyc b/plugins/shop/__pycache__/buy.cpython-39.pyc deleted file mode 100644 index de8a0300..00000000 Binary files a/plugins/shop/__pycache__/buy.cpython-39.pyc and /dev/null differ diff --git a/plugins/shop/__pycache__/my_gold.cpython-38.pyc b/plugins/shop/__pycache__/my_gold.cpython-38.pyc deleted file mode 100644 index 995594e6..00000000 Binary files a/plugins/shop/__pycache__/my_gold.cpython-38.pyc and /dev/null differ diff --git a/plugins/shop/__pycache__/my_gold.cpython-39.pyc b/plugins/shop/__pycache__/my_gold.cpython-39.pyc deleted file mode 100644 index 209a70a7..00000000 Binary files a/plugins/shop/__pycache__/my_gold.cpython-39.pyc and /dev/null differ diff --git a/plugins/shop/__pycache__/my_props.cpython-38.pyc b/plugins/shop/__pycache__/my_props.cpython-38.pyc deleted file mode 100644 index 252321fe..00000000 Binary files a/plugins/shop/__pycache__/my_props.cpython-38.pyc and /dev/null differ diff --git a/plugins/shop/__pycache__/my_props.cpython-39.pyc b/plugins/shop/__pycache__/my_props.cpython-39.pyc deleted file mode 100644 index eb865329..00000000 Binary files a/plugins/shop/__pycache__/my_props.cpython-39.pyc and /dev/null differ diff --git a/plugins/shop/__pycache__/reset_today_gold.cpython-38.pyc b/plugins/shop/__pycache__/reset_today_gold.cpython-38.pyc deleted file mode 100644 index 6f89e622..00000000 Binary files a/plugins/shop/__pycache__/reset_today_gold.cpython-38.pyc and /dev/null differ diff --git a/plugins/shop/__pycache__/reset_today_gold.cpython-39.pyc b/plugins/shop/__pycache__/reset_today_gold.cpython-39.pyc deleted file mode 100644 index b463febb..00000000 Binary files a/plugins/shop/__pycache__/reset_today_gold.cpython-39.pyc and /dev/null differ diff --git a/plugins/shop/__pycache__/shop_help.cpython-38.pyc b/plugins/shop/__pycache__/shop_help.cpython-38.pyc deleted file mode 100644 index ceb8081a..00000000 Binary files a/plugins/shop/__pycache__/shop_help.cpython-38.pyc and /dev/null differ diff --git a/plugins/shop/__pycache__/shop_help.cpython-39.pyc b/plugins/shop/__pycache__/shop_help.cpython-39.pyc deleted file mode 100644 index f0727ef6..00000000 Binary files a/plugins/shop/__pycache__/shop_help.cpython-39.pyc and /dev/null differ diff --git a/plugins/shop/buy.py b/plugins/shop/buy.py deleted file mode 100644 index 6b4379c0..00000000 --- a/plugins/shop/buy.py +++ /dev/null @@ -1,78 +0,0 @@ -from nonebot import on_command -from services.log import logger -from nonebot.adapters.cqhttp import Bot, GroupMessageEvent -from nonebot.typing import T_State -from util.utils import get_message_text, is_number -from models.bag_user import UserBag -from services.db_context import db -from nonebot.adapters.cqhttp.permission import GROUP - - -__plugin_name__ = '商店购买' -__plugin_usage__ = '格式:购买 名称或序号 数量(选填,默认为1)\n\t示例:购买 好感双倍加持卡Ⅰ\n\t示例:购买 1 4' - - -buy = on_command("购买", aliases={'购买道具'}, priority=5, block=True, permission=GROUP) - -goods = [ - '好感双倍加持卡Ⅰ\t\t售价:30金币\n\t\t今日双倍好感度的概率 + 10%(谁才是真命天子?)(同类道具将覆盖)', - '好感双倍加持卡Ⅱ\t\t售价:140金币\n\t\t今日双倍好感度的概率 + 20%(平平庸庸~)(同类道具将覆盖)', - '好感双倍加持卡Ⅲ\t\t售价:250金币\n\t\t今日双倍好感度的概率 + 30%(金币才是真命天子!)(同类道具将覆盖)' -] -glist = [] -plist = [] -for i in range(len(goods)): - glist.append(goods[i].split('\t\t')[0]) - plist.append(int(goods[i].split('\t\t')[1].split(':')[1].split('金币')[0])) - - -@buy.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - if get_message_text(event.json()) in ['', '帮助']: - await buy.finish(__plugin_usage__) - if get_message_text(event.json()) in ['神秘药水']: - await buy.finish("你们看看就好啦,这是不可能卖给你们的~", at_sender=True) - msg = get_message_text(event.json()).strip().split(' ') - index = -1 - num = 1 - if len(msg) > 1: - if is_number(msg[1]): - num = int(msg[1]) - print(msg, num) - if is_number(msg[0]): - msg = int(msg[0]) - if msg > len(goods) or msg < 1: - await buy.finish('请输入正确的商品id!', at_sender=True) - index = msg - 1 - else: - if msg[0] in glist: - for i in range(len(glist)): - if msg == glist[i]: - index = i - break - else: - await buy.finish('请输入正确的商品名称!', at_sender=True) - async with db.transaction(): - if index != -1: - if (await UserBag.get_gold(event.user_id, event.group_id)) < plist[index] * num: - await buy.finish('您的金币好像不太够哦', at_sender=True) - if await UserBag.spend_glod(event.user_id, event.group_id, plist[index] * num): - for _ in range(num): - await UserBag.add_props(event.user_id, event.group_id, glist[index]) - await buy.send(f'花费 {plist[index]*num} 金币购买 {glist[index]} ×{num} 成功!', at_sender=True) - logger.info(f'USER {event.user_id} GROUP {event.group_id} ' - f'花费 {plist[index]*num} 金币购买 {glist[index]} ×{num} 成功!') - else: - await buy.send(f'{glist[index]} 购买失败!', at_sender=True) - logger.info(f'USER {event.user_id} GROUP {event.group_id} ' - f'花费 {plist[index]*num} 金币购买 {glist[index]} ×{num} 失败!') - - - - - - - - - - diff --git a/plugins/shop/my_gold.py b/plugins/shop/my_gold.py deleted file mode 100644 index 8228f2a0..00000000 --- a/plugins/shop/my_gold.py +++ /dev/null @@ -1,26 +0,0 @@ -from nonebot import on_command -from nonebot.adapters.cqhttp import Bot, GroupMessageEvent -from nonebot.typing import T_State -from models.bag_user import UserBag -from nonebot.adapters.cqhttp.permission import GROUP - - -__plugin_name__ = '我的金币' - - -my_gold = on_command("我的金币", priority=5, block=True, permission=GROUP) - - -@my_gold.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - await my_gold.finish(await UserBag.get_my_total_gold(event.user_id, event.group_id)) - - - - - - - - - - diff --git a/plugins/shop/my_props.py b/plugins/shop/my_props.py deleted file mode 100644 index f9e147f7..00000000 --- a/plugins/shop/my_props.py +++ /dev/null @@ -1,46 +0,0 @@ -from nonebot import on_command -from services.log import logger -from nonebot.adapters.cqhttp import Bot, GroupMessageEvent -from nonebot.typing import T_State -from models.bag_user import UserBag -from nonebot.adapters.cqhttp.permission import GROUP - - -__plugin_name__ = '商店基础显示' - - -my_props = on_command("我的道具", priority=5, block=True, permission=GROUP) - - -@my_props.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - props = await UserBag.get_props(event.user_id, event.group_id) - if props: - pname_list = [] - pnum_list = [] - rst = '' - props = props[:-1].split(',') - for p in props: - if p != '': - if p in pname_list: - pnum_list[pname_list.index(p)] += 1 - else: - pname_list.append(p) - pnum_list.append(1) - for i in range(len(pname_list)): - rst += f'{i+1}.{pname_list[i]}\t×{pnum_list[i]}\n' - await my_props.send('\n' + rst[:-1], at_sender=True) - logger.info(f'USER {event.user_id} GROUP {event.group_id} 查看我的道具') - else: - await my_props.finish('您的背包里没有任何的道具噢~', at_sender=True) - - - - - - - - - - - diff --git a/plugins/shop/reset_today_gold.py b/plugins/shop/reset_today_gold.py deleted file mode 100644 index 7e0cfb05..00000000 --- a/plugins/shop/reset_today_gold.py +++ /dev/null @@ -1,41 +0,0 @@ -from util.utils import scheduler -from models.bag_user import UserBag -from services.log import logger - - -# 重置每日金币 -@scheduler.scheduled_job( - 'cron', - # year=None, - # month=None, - # day=None, - # week=None, - # day_of_week="mon,tue,wed,thu,fri", - hour=0, - minute=1, - # second=None, - # start_date=None, - # end_date=None, - # timezone=None, -) -async def _(): - try: - user_list = await UserBag.get_user_all() - if user_list: - for user in user_list: - await user.update( - get_today_gold=0, - spend_today_gold=0, - ).apply() - except Exception as e: - logger.error(f'重置每日金币错误 e:{e}') - - - - - - - - - - diff --git a/plugins/shop/shop_help.py b/plugins/shop/shop_help.py deleted file mode 100644 index 85c8aa0f..00000000 --- a/plugins/shop/shop_help.py +++ /dev/null @@ -1,41 +0,0 @@ -from nonebot import on_command -from nonebot.adapters.cqhttp import Bot, GroupMessageEvent -from nonebot.typing import T_State -from util.img_utils import CreateImg -from configs.path_config import IMAGE_PATH -from util.init_result import image - - -__plugin_name__ = '商店' - - -shop_help = on_command("商店", priority=5, block=True) - -goods = [ - '好感双倍加持卡Ⅰ\t\t售价:30金币\n\t\t下次签到双倍好感度的概率 + 10%(谁才是真命天子?)(同类商品将覆盖)', - '好感双倍加持卡Ⅱ\t\t售价:150金币\n\t\t下次签到双倍好感度的概率 + 20%(平平庸庸~)(同类商品将覆盖)', - '好感双倍加持卡Ⅲ\t\t售价:250金币\n\t\t下次签到双倍好感度的概率 + 30%(金币才是真命天子!)(同类商品将覆盖)' -] - -result = '' -for i in range(len(goods)): - result += f'{i + 1}.{goods[i]}\n' -shop = CreateImg(1000, 1000, background=IMAGE_PATH + 'other/shop.png', font_size=20) -shop.text((100, 170), '注【通过 数字 或者 商品名称 购买】') -shop.text((20, 230), result) -shop.text((20, 900), '神秘药水\t\t售价:9999999金币\n\t\t鬼知道会有什么效果~') -shop.save(IMAGE_PATH + 'shop.png') - - -@shop_help.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - await shop_help.send(image('shop.png')) - - - - - - - - - diff --git a/plugins/shop/use/__init__.py b/plugins/shop/use/__init__.py deleted file mode 100644 index b6bb532c..00000000 --- a/plugins/shop/use/__init__.py +++ /dev/null @@ -1,61 +0,0 @@ -from nonebot import on_command -from services.log import logger -from nonebot.adapters.cqhttp import Bot, GroupMessageEvent -from nonebot.typing import T_State -from util.utils import is_number, get_message_text -from models.bag_user import UserBag -from nonebot.adapters.cqhttp.permission import GROUP -from services.db_context import db -from .data_source import effect - - -__plugin_name__ = '使用道具' -__plugin_usage__ = '输入 “使用道具 xxx(序号 或 道具名称)“ 即可使用道具\n【注】序号以我的道具序号为准,更推荐使用道具名称使用道具(怕出错)' - - -use_props = on_command("使用道具", priority=5, block=True, permission=GROUP) - - -@use_props.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - msg = get_message_text(event.json()) - if msg in ['', '帮助']: - await use_props.finish(__plugin_usage__) - props = await UserBag.get_props(event.user_id, event.group_id) - if props: - async with db.transaction(): - pname_list = [] - props = props[:-1].split(',') - for p in props: - if p != '': - if p not in pname_list: - pname_list.append(p) - if is_number(msg): - if 0 < int(msg) <= len(pname_list): - name = pname_list[int(msg) - 1] - else: - await use_props.finish('仔细看看自己的道具仓库有没有这个道具?', at_sender=True) - else: - if msg not in pname_list: - await use_props.finish('道具名称错误!', at_sender=True) - name = msg - if await UserBag.del_props(event.user_id, event.group_id, name) and\ - await effect(event.user_id, event.group_id, name): - await use_props.send(f'使用道具 {name} 成功!', at_sender=True) - logger.info(f'USER {event.user_id} GROUP {event.group_id} 使用道具 {name} 成功') - else: - await use_props.send(f'使用道具 {name} 失败!', at_sender=True) - logger.info(f'USER {event.user_id} GROUP {event.group_id} 使用道具 {name} 失败') - else: - await use_props.send('您的背包里没有任何的道具噢~', at_sender=True) - - - - - - - - - - - diff --git a/plugins/shop/use/__pycache__/__init__.cpython-38.pyc b/plugins/shop/use/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index e07bac44..00000000 Binary files a/plugins/shop/use/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/shop/use/__pycache__/__init__.cpython-39.pyc b/plugins/shop/use/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 20c5b6d7..00000000 Binary files a/plugins/shop/use/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/shop/use/__pycache__/data_source.cpython-38.pyc b/plugins/shop/use/__pycache__/data_source.cpython-38.pyc deleted file mode 100644 index 4409ecf9..00000000 Binary files a/plugins/shop/use/__pycache__/data_source.cpython-38.pyc and /dev/null differ diff --git a/plugins/shop/use/__pycache__/data_source.cpython-39.pyc b/plugins/shop/use/__pycache__/data_source.cpython-39.pyc deleted file mode 100644 index c134c79a..00000000 Binary files a/plugins/shop/use/__pycache__/data_source.cpython-39.pyc and /dev/null differ diff --git a/plugins/shop/use/data_source.py b/plugins/shop/use/data_source.py deleted file mode 100644 index b0f79be6..00000000 --- a/plugins/shop/use/data_source.py +++ /dev/null @@ -1,40 +0,0 @@ -from models.sigin_group_user import SignGroupUser - - -async def effect(user_id: int, group_id: int, name: str) -> bool: - print(name) - # try: - if name == '好感双倍加持卡Ⅰ': - user = await SignGroupUser.ensure(user_id, group_id) - await user.update( - add_probability=0.1 - ).apply() - if name == '好感双倍加持卡Ⅱ': - user = await SignGroupUser.ensure(user_id, group_id) - await user.update( - add_probability=0.2 - ).apply() - if name == '好感双倍加持卡Ⅲ': - user = await SignGroupUser.ensure(user_id, group_id) - print(user.user_qq) - await user.update( - add_probability=0.3 - ).apply() - return True - # except Exception: - # return False - - - - - - - - - - - - - - - diff --git a/plugins/sign_in/__init__.py b/plugins/sign_in/__init__.py deleted file mode 100644 index 65193ee3..00000000 --- a/plugins/sign_in/__init__.py +++ /dev/null @@ -1,53 +0,0 @@ -from .group_user_checkin import group_user_check_in, group_user_check, group_impression_rank -from nonebot.typing import T_State -from nonebot.adapters.cqhttp import Bot, Event, GroupMessageEvent -from nonebot.adapters.cqhttp.permission import GROUP -from util.utils import get_message_text -from nonebot.plugin import MatcherGroup - - -__plugin_name__ = '签到' -__plugin_usage__ = ( - '用法:\n' - '对我说 “签到” 来签到\n' - '“我的签到” 来获取历史签到信息\n' - '“好感度排行” 来查看当前好感度前十的伙伴\n' - '/ 签到时有 3% 概率 * 2 /' - -) - - -sign_match_group = MatcherGroup(priority=5, permission=GROUP, block=True) - -sign = sign_match_group.on_command("签到") - - -@sign.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - if get_message_text(event.json()) in ['帮助']: - await sign.finish(__plugin_usage__) - await sign.send( - await group_user_check_in(event.user_id, event.group_id), - at_sender=True, - ) - - -my_sign = sign_match_group.on_command(cmd="我的签到", aliases={'好感度'}) - - -@my_sign.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - await my_sign.send( - await group_user_check(event.user_id, event.group_id), - at_sender=True, - ) - -sign_ranking = sign_match_group.on_command(cmd="积分排行", aliases={'好感度排行', '签到排行', '积分排行', '好感排行', - '好感度排名,签到排名,积分排名'}) - - -@sign_ranking.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - await sign_ranking.send( - await group_impression_rank(event.group_id) - ) \ No newline at end of file diff --git a/plugins/sign_in/__pycache__/__init__.cpython-38.pyc b/plugins/sign_in/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index bc5c2af5..00000000 Binary files a/plugins/sign_in/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/sign_in/__pycache__/__init__.cpython-39.pyc b/plugins/sign_in/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index a78968c1..00000000 Binary files a/plugins/sign_in/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/sign_in/__pycache__/group_user_checkin.cpython-38.pyc b/plugins/sign_in/__pycache__/group_user_checkin.cpython-38.pyc deleted file mode 100644 index 84bce2f2..00000000 Binary files a/plugins/sign_in/__pycache__/group_user_checkin.cpython-38.pyc and /dev/null differ diff --git a/plugins/sign_in/__pycache__/group_user_checkin.cpython-39.pyc b/plugins/sign_in/__pycache__/group_user_checkin.cpython-39.pyc deleted file mode 100644 index 63a19b98..00000000 Binary files a/plugins/sign_in/__pycache__/group_user_checkin.cpython-39.pyc and /dev/null differ diff --git a/plugins/sign_in/group_user_checkin.py b/plugins/sign_in/group_user_checkin.py deleted file mode 100644 index b695aede..00000000 --- a/plugins/sign_in/group_user_checkin.py +++ /dev/null @@ -1,119 +0,0 @@ -import random -from datetime import datetime, timedelta - -from services.log import logger -from services.db_context import db -from models.sigin_group_user import SignGroupUser -from models.group_member_info import GroupInfoUser -from models.bag_user import UserBag -from configs.config import MAX_SIGN_GOLD - - -async def group_user_check_in(user_qq: int, group: int) -> str: - 'Returns string describing the result of checking in' - present = datetime.now() - async with db.transaction(): - # 取得相应用户 - user = await SignGroupUser.ensure(user_qq, group, for_update=True) - # 如果同一天签到过,特殊处理 - if user.checkin_time_last.date() == present.date(): - return _handle_already_checked_in(user) - return await _handle_check_in(user_qq, group, present) # ok - - -def _handle_already_checked_in(user: SignGroupUser) -> str: - return f'已经签到过啦~ 好感度:{user.impression:.2f}' - - -async def _handle_check_in(user_qq: int, group: int, present: datetime) -> str: - user = await SignGroupUser.ensure(user_qq, group, for_update=True) - impression_added = random.random() - present = present + timedelta(hours=8) - critx2 = random.random() - add_probability = user.add_probability - specify_probability = user.specify_probability - if critx2 + add_probability > 0.97: - impression_added *= 2 - elif critx2 < specify_probability: - impression_added *= 2 - new_impression = user.impression + impression_added - message = random.choice(( - '谢谢,你是个好人!', - '对了,来喝杯茶吗?', - )) - await user.update( - checkin_count=user.checkin_count + 1, - checkin_time_last=present, - impression=new_impression, - add_probability=0, - specify_probability=0, - ).apply() - # glod = await random_glod(user_qq, group, specify_probability) - if user.impression < 1: - impression = 1 - else: - impression = user.impression - gold = random.randint(1, 100) - imgold = random.randint(1, int(impression)) - if imgold > MAX_SIGN_GOLD: - imgold = MAX_SIGN_GOLD - await UserBag.add_glod(user_qq, group, gold + imgold) - if critx2 + add_probability > 0.97 or critx2 < specify_probability: - logger.info(f'(USER {user.user_qq}, GROUP {user.belonging_group})' - f' CHECKED IN successfully. score: {new_impression:.2f} (+{impression_added * 2:.2f}).获取金币:{gold+imgold}') - return f'{message} 好感度:{new_impression:.2f} (+{impression_added/2:.2f}×2)!!!\n获取金币:{gold} \n好感度额外获得金币:{imgold}' - else: - logger.info(f'(USER {user.user_qq}, GROUP {user.belonging_group})' - f' CHECKED IN successfully. score: {new_impression:.2f} (+{impression_added:.2f}).获取金币:{gold+imgold}') - return f'{message} 好感度:{new_impression:.2f} (+{impression_added:.2f})\n获取金币:{gold} \n好感度额外获得金币:{imgold}' - - -async def group_user_check(user_qq: int, group: int) -> str: - # heuristic: if users find they have never checked in they are probable to check in - user = await SignGroupUser.ensure(user_qq, group) - glod = await UserBag.get_gold(user_qq, group) - return '好感度:{:.2f}\n金币:{}\n历史签到数:{}\n上次签到日期:{}'.format( - user.impression, - glod, - user.checkin_count, - user.checkin_time_last.date() if user.checkin_time_last != datetime.min else '从未', - ) - - -async def group_impression_rank(group: int) -> str: - result = "\t好感度排行榜\t\n" - user_qq_list, impression_list = await SignGroupUser.query_impression_all(group) - _count = 11 - if user_qq_list and impression_list: - for i in range(1, 100): - if len(user_qq_list) == 0 or len(impression_list) == 0 or i == _count: - break - impression = max(impression_list) - index = impression_list.index(impression) - user_qq = user_qq_list[index] - print(user_qq, group) - try: - user_name = (await GroupInfoUser.select_member_info(user_qq, group)).user_name - except Exception as e: - logger.info(f"USER {user_qq}, GROUP {group} 不在群内") - _count += 1 - impression_list.remove(impression) - user_qq_list.remove(user_qq) - continue - result += f"{i - _count + 11}. {user_name}: {impression:.2f}\n" - impression_list.remove(impression) - user_qq_list.remove(user_qq) - return result[:-1] - - -async def random_glod(user_id, group_id, impression): - if impression < 1: - impression = 1 - glod = random.randint(1, 100) + random.randint(1, int(impression)) - if await UserBag.add_glod(user_id, group_id, glod): - return glod - else: - return 0 - - - diff --git a/plugins/songpicker2/__init__.py b/plugins/songpicker2/__init__.py deleted file mode 100644 index 31e271ee..00000000 --- a/plugins/songpicker2/__init__.py +++ /dev/null @@ -1,81 +0,0 @@ -from .data_source import dataGet, dataProcess -from nonebot.adapters import Bot, Event -from nonebot.typing import T_State -from nonebot import on_command - - -dataget = dataGet() - -songpicker = on_command("点歌", priority=5, block=True) - - -@songpicker.handle() -async def handle_first_receive(bot: Bot, event: Event, state: T_State): - args = str(event.get_message()).strip() - # if args.isdigit(): - # if "songName" in state: - # state["songNum"] = int(args) - if args: - state["songName"] = args - - -@songpicker.got("songName", prompt="歌名是?") -async def handle_songName(bot: Bot, event: Event, state: T_State): - songName = state["songName"] - songIdList = await dataget.songIds(songName=songName) - if not songIdList: - await songpicker.reject("没有找到这首歌,请发送其它歌名!") - songInfoList = list() - for songId in songIdList: - songInfoDict = await dataget.songInfo(songId) - songInfoList.append(songInfoDict) - # songInfoMessage = await dataProcess.mergeSongInfo(songInfoList) - # await songpicker.send(songInfoMessage) - state["songIdList"] = songIdList - - -@songpicker.got("songName") -async def handle_songNum(bot: Bot, event: Event, state: T_State): - songIdList = state["songIdList"] - # songNum = state["songNum"] - songNum = 0 - # 处理重选 - # if not songNum.isdigit(): - # await songpicker.finish() - # else: - # songNum = int(songNum) - # - # if songNum >= len(songIdList) or songNum < 0: - # await songpicker.reject("数字序号错误") - - selectedSongId = songIdList[int(songNum)] - - songContent = [ - { - "type": "music", - "data": { - "type": 163, - "id": selectedSongId - } - } - ] - await songpicker.send(songContent) - - # songCommentsDict = await dataget.songComments(songId=selectedSongId) - # songCommentsMessage = await dataProcess.mergeSongComments(songCommentsDict) - # commentContent = [ - # { - # "type": "text", - # "data": { - # "text": "下面为您播送热评:\n" - # } - # }, - # { - # "type": "text", - # "data": { - # "text": songCommentsMessage - # } - # } - # ] - # - # await songpicker.send(commentContent) \ No newline at end of file diff --git a/plugins/songpicker2/__pycache__/__init__.cpython-38.pyc b/plugins/songpicker2/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 5d305878..00000000 Binary files a/plugins/songpicker2/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/songpicker2/__pycache__/__init__.cpython-39.pyc b/plugins/songpicker2/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index ccf46987..00000000 Binary files a/plugins/songpicker2/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/songpicker2/__pycache__/data_source.cpython-38.pyc b/plugins/songpicker2/__pycache__/data_source.cpython-38.pyc deleted file mode 100644 index 7a3c32ab..00000000 Binary files a/plugins/songpicker2/__pycache__/data_source.cpython-38.pyc and /dev/null differ diff --git a/plugins/songpicker2/__pycache__/data_source.cpython-39.pyc b/plugins/songpicker2/__pycache__/data_source.cpython-39.pyc deleted file mode 100644 index 5b07d814..00000000 Binary files a/plugins/songpicker2/__pycache__/data_source.cpython-39.pyc and /dev/null differ diff --git a/plugins/songpicker2/data_source.py b/plugins/songpicker2/data_source.py deleted file mode 100644 index d2786d87..00000000 --- a/plugins/songpicker2/data_source.py +++ /dev/null @@ -1,156 +0,0 @@ -import aiohttp -import json - - -class dataApi(): - ''' - 从网易云音乐接口直接获取数据(实验性) - ''' - headers = {"referer": "http://music.163.com"} - cookies = {"appver": "2.0.2"} - - async def search(self, songName: str): - ''' - 搜索接口,用于由歌曲名查找id - ''' - async with aiohttp.ClientSession(headers=self.headers, cookies=self.cookies) as session: - async with session.post(f"http://music.163.com/api/search/get/", data={"s": songName, "limit": 5, "type": 1, "offset": 0},) as r: - if r.status != 200: - return None - r = await r.text() - return json.loads(r) - - # async def getHotComments(self, songId: int): - # ''' - # 获取热评 - # ''' - # async with httpx.AsyncClient() as client: - # async with aiohttp.ClientSession(headers=self.headers, cookies=self.cookies) as session: - # async with session.post( - # f"https://music.163.com/weapi/v1/resource/hotcomments/R_SO_4_{songId}?csrf_token=", - # data={ - # "params": 'D33zyir4L/58v1qGPcIPjSee79KCzxBIBy507IYDB8EL7jEnp41aDIqpHBhowfQ6iT1Xoka8jD+0p - # 44nRKNKUA0dv+n5RWPOO57dZLVrd+T1J/sNrTdzUhdHhoKRIgegVcXYjYu+CshdtCBe6WEJozBRlaHyLeJtGrA - # BfMOEb4PqgI3h/uELC82S05NtewlbLZ3TOR/TIIhNV6hVTtqHDVHjkekrvEmJzT5pk1UY6r0=', - # "encSecKey": '45c8bcb07e69c6b545d3045559bd300db897509b8720ee2b45a72bf2d3b216ddc77fb10dae - # c4ca54b466f2da1ffac1e67e245fea9d842589dc402b92b262d3495b12165a721aed880bf09a0a99ff94c959d - # 04e49085dc21c78bbbe8e3331827c0ef0035519e89f097511065643120cbc478f9c0af96400ba4649265781fc9079' - # }, - # ) as r: - # if r.status != 200: - # return None - # r = await r.json() - # return r - - async def getSongInfo(self, songId: int): - ''' - 获取歌曲信息 - ''' - async with aiohttp.ClientSession(headers=self.headers, cookies=self.cookies) as session: - async with session.post(f"http://music.163.com/api/song/detail/?id={songId}&ids=%5B{songId}%5D",) as r: - if r.status != 200: - return None - r = await r.text() - return json.loads(r) - - -class dataGet(dataApi): - ''' - 从dataApi获取数据,并做简单处理 - ''' - - api = dataApi() - - async def songIds(self, songName: str, amount=5) -> list: - ''' - 根据用户输入的songName 获取候选songId列表 [默认songId数量:5] - ''' - songIds = list() - r = await self.api.search(songName=songName) - if r is None: - raise WrongDataError - idRange = amount if amount < len( - r["result"]["songs"]) else len(r["result"]["songs"]) - for i in range(idRange): - songIds.append(r["result"]["songs"][i]["id"]) - return songIds - - # async def songComments(self, songId: int, amount=3) -> dict: - # ''' - # 根据传递的单一songId,获取songComments dict [默认评论数量上限:3] - # ''' - # songComments = dict() - # r = await self.api.getHotComments(songId) - # if r is None: - # raise WrongDataError - # commentsRange = amount if amount < len( - # r['hotComments']) else len(r['hotComments']) - # for i in range(commentsRange): - # songComments[r['hotComments'][i]['user'] - # ['nickname']] = r['hotComments'][i]['content'] - # return songComments - - async def songInfo(self, songId: int) -> dict: - ''' - 根据传递的songId,获取歌曲名、歌手、专辑等信息,作为dict返回 - ''' - songInfo = dict() - r = await self.api.getSongInfo(songId) - if r is None: - raise WrongDataError - songInfo["songName"] = r["songs"][0]["name"] - - songArtists = list() - for ars in r["songs"][0]["artists"]: - songArtists.append(ars["name"]) - songArtistsStr = "、".join(songArtists) - songInfo["songArtists"] = songArtistsStr - - songInfo["songAlbum"] = r["songs"][0]["album"]["name"] - - return songInfo - - -class dataProcess(): - ''' - 将获取的数据处理为用户能看懂的形式 - ''' - - @staticmethod - async def mergeSongInfo(songInfos: list) -> str: - ''' - 将歌曲信息list处理为字符串,供用户点歌 - 传递进的歌曲信息list含有多个歌曲信息dict - ''' - songInfoMessage = "请输入欲点播歌曲的序号:\n" - numId = 0 - for songInfo in songInfos: - songInfoMessage += f"{numId}:" - songInfoMessage += songInfo["songName"] - songInfoMessage += "-" - songInfoMessage += songInfo["songArtists"] - songInfoMessage += " 专辑:" - songInfoMessage += songInfo["songAlbum"] - songInfoMessage += "\n" - numId += 1 - return songInfoMessage - - @staticmethod - async def mergeSongComments(songComments: dict) -> str: - songCommentsMessage = '\n'.join( - ['%s: %s' % (key, value) for (key, value) in songComments.items()]) - return songCommentsMessage - - -class Error(Exception): - ''' - 谁知道网易的接口会出什么幺蛾子 - ''' - pass - - -class WrongDataError(Error): - def __init__(self, expression, message): - self.expression = expression - self.message = message - self.message += "\n未从网易接口获取到有效的数据!" \ No newline at end of file diff --git a/plugins/statistics_hook.py b/plugins/statistics_hook.py deleted file mode 100644 index 0abfe2c2..00000000 --- a/plugins/statistics_hook.py +++ /dev/null @@ -1,143 +0,0 @@ -from configs.path_config import DATA_PATH -from nonebot.matcher import Matcher -from nonebot.message import run_postprocessor -from nonebot.typing import T_State -from nonebot.adapters.cqhttp import Bot, GroupMessageEvent -from datetime import datetime -from configs.config import plugins2name_dict -from util.utils import scheduler -from nonebot.typing import Optional -try: - import ujson as json -except ModuleNotFoundError: - import json - - -try: - with open(DATA_PATH + '_prefix_count.json', 'r', encoding='utf8') as f: - _prefix_count_dict = json.load(f) -except (FileNotFoundError, ValueError): - _prefix_count_dict = { - 'total_statistics': { - 'total': {}, - }, - 'day_statistics': { - 'total': {}, - }, - 'week_statistics': { - 'total': {}, - }, - 'month_statistics': { - 'total': {}, - }, - 'start_time': str(datetime.now().date()) - } - - -# 添加命令次数 -@run_postprocessor -async def _(matcher: Matcher, exception: Optional[Exception], bot: Bot, event: GroupMessageEvent, state: T_State): - if matcher.type == 'message' and matcher.priority not in [1, 9]: - model = matcher.module - # print(f'model --> {model}') - for plugin in plugins2name_dict: - if plugin == model: - # print(f'plugin --> {plugin}') - try: - group_id = str(event.group_id) - except AttributeError: - group_id = 'total' - plugin_name = plugins2name_dict[plugin][0] - check_exists_key(group_id, plugin_name) - _prefix_count_dict['total_statistics']['total'][plugin_name] += 1 - _prefix_count_dict['day_statistics']['total'][plugin_name] += 1 - _prefix_count_dict['week_statistics']['total'][plugin_name] += 1 - _prefix_count_dict['month_statistics']['total'][plugin_name] += 1 - if group_id != 'total': - _prefix_count_dict['total_statistics'][group_id][plugin_name] += 1 - _prefix_count_dict['day_statistics'][group_id][plugin_name] += 1 - _prefix_count_dict['week_statistics'][group_id][plugin_name] += 1 - _prefix_count_dict['month_statistics'][group_id][plugin_name] += 1 - with open(DATA_PATH + '_prefix_count.json', 'w', encoding='utf8') as f: - json.dump(_prefix_count_dict, f, indent=4, ensure_ascii=False) - break - - -def check_exists_key(group_id, plugin_name): - if not _prefix_count_dict['total_statistics']['total'].get(plugin_name): - _prefix_count_dict['total_statistics']['total'][plugin_name] = 0 - if not _prefix_count_dict['day_statistics']['total'].get(plugin_name): - _prefix_count_dict['day_statistics']['total'][plugin_name] = 0 - if not _prefix_count_dict['week_statistics']['total'].get(plugin_name): - _prefix_count_dict['week_statistics']['total'][plugin_name] = 0 - if not _prefix_count_dict['month_statistics']['total'].get(plugin_name): - _prefix_count_dict['month_statistics']['total'][plugin_name] = 0 - if not _prefix_count_dict['total_statistics'].get(group_id): - _prefix_count_dict['total_statistics'][group_id] = { - plugin_name: 0, - } - elif not _prefix_count_dict['total_statistics'][group_id].get(plugin_name): - _prefix_count_dict['total_statistics'][group_id][plugin_name] = 0 - if not _prefix_count_dict['day_statistics'].get(group_id): - _prefix_count_dict['day_statistics'][group_id] = { - plugin_name: 0, - } - elif not _prefix_count_dict['day_statistics'][group_id].get(plugin_name): - _prefix_count_dict['day_statistics'][group_id][plugin_name] = 0 - if not _prefix_count_dict['week_statistics'].get(group_id): - _prefix_count_dict['week_statistics'][group_id] = { - plugin_name: 0, - } - elif not _prefix_count_dict['week_statistics'][group_id].get(plugin_name): - _prefix_count_dict['week_statistics'][group_id][plugin_name] = 0 - if not _prefix_count_dict['month_statistics'].get(group_id): - _prefix_count_dict['month_statistics'][group_id] = { - plugin_name: 0, - } - elif not _prefix_count_dict['month_statistics'][group_id].get(plugin_name): - _prefix_count_dict['month_statistics'][group_id][plugin_name] = 0 - - -# 天 -@scheduler.scheduled_job( - 'cron', - hour=0, - minute=1, -) -async def _(): - for group_id in _prefix_count_dict['day_statistics'].keys(): - for key in _prefix_count_dict['day_statistics'][group_id].keys(): - _prefix_count_dict['day_statistics'][group_id][key] = 0 - with open(DATA_PATH + '_prefix_count.json', 'w', encoding='utf8') as f: - json.dump(_prefix_count_dict, f, indent=4, ensure_ascii=False) - - -# 早上好 -@scheduler.scheduled_job( - 'cron', - day_of_week="mon", - hour=0, - minute=1, -) -async def _(): - for group_id in _prefix_count_dict['week_statistics'].keys(): - for key in _prefix_count_dict['week_statistics'][group_id].keys(): - _prefix_count_dict['week_statistics'][group_id][key] = 0 - with open(DATA_PATH + '_prefix_count.json', 'w', encoding='utf8') as f: - json.dump(_prefix_count_dict, f, indent=4, ensure_ascii=False) - - -# 早上好 -@scheduler.scheduled_job( - 'cron', - day=1, - hour=0, - minute=1, -) -async def _(): - for group_id in _prefix_count_dict['month_statistics'].keys(): - for key in _prefix_count_dict['month_statistics'][group_id].keys(): - _prefix_count_dict['month_statistics'][group_id][key] = 0 - with open(DATA_PATH + '_prefix_count.json', 'w', encoding='utf8') as f: - json.dump(_prefix_count_dict, f, indent=4, ensure_ascii=False) - diff --git a/plugins/super_cmd/__init__.py b/plugins/super_cmd/__init__.py deleted file mode 100644 index 522f78f5..00000000 --- a/plugins/super_cmd/__init__.py +++ /dev/null @@ -1,158 +0,0 @@ -from nonebot import on_command -from nonebot.permission import SUPERUSER -from models.level_user import LevelUser -from nonebot.typing import T_State -from nonebot.adapters import Bot, Event -from nonebot.rule import to_me -from util.utils import get_message_at, get_message_text, is_number, get_bot -from services.log import logger -from .data_source import open_remind, close_remind -from models.group_info import GroupInfo -from models.friend_user import FriendUser - - -__plugin_name__ = '超级用户指令 [Hidden]' -__plugin_usage__ = '用法' - - -super_cmd = on_command("添加管理", aliases={'删除管理', '添加权限', '删除权限'}, rule=to_me(), priority=1, permission=SUPERUSER, block=True) -oc_gb = on_command('开启广播通知', aliases={'关闭广播通知'}, rule=to_me(), permission=SUPERUSER, priority=1, block=True) -cls_group = on_command("所有群组", rule=to_me(), permission=SUPERUSER, priority=1, block=True) -cls_friend = on_command("所有好友", rule=to_me(), permission=SUPERUSER, priority=1, block=True) -del_group = on_command('退群', rule=to_me(), permission=SUPERUSER, priority=1, block=True) -update_group_info = on_command('更新群信息', rule=to_me(), permission=SUPERUSER, priority=1, block=True) -update_friend_info = on_command('更新好友信息', rule=to_me(), permission=SUPERUSER, priority=1, block=True) -# update_cmd = on_command('更新命令开关', rule=to_me(), permission=SUPERUSER, priority=1, block=True) - - -@super_cmd.handle() -async def _(bot: Bot, event: Event, state: T_State): - try: - args = get_message_text(event.json()).strip().split(" ") - qq = int(get_message_at(event.json())[0]) - if state["_prefix"]["raw_command"][:2] == "添加": - level = int(args[0]) - if await LevelUser.set_level(qq, event.group_id, level, 1): - result = "添加管理成功, 权限: " + str(level) - else: - result = "管理已存在, 更新权限: " + str(level) - else: - if await LevelUser.delete_level(qq, event.group_id, True): - result = "删除管理成功!" - else: - result = "该账号无管理权限!" - await super_cmd.send(result) - except Exception as e: - await super_cmd.send("执行指令失败!") - logger.error(f'执行指令失败 e{e}') - - -@oc_gb.handle() -async def _(bot: Bot, event: Event, state: T_State): - group = get_message_text(event.json()) - if group: - if is_number(group): - group = int(group) - for g in await bot.get_group_list(): - if g['group_id'] == group: - break - else: - await oc_gb.finish('没有加入这个群...', at_sender=True) - # try: - if state["_prefix"]["raw_command"] == '开启广播通知': - logger.info(f'USER {event.user_id} 开启了 GROUP {group} 的广播') - await oc_gb.finish(await open_remind(group, 'gb'), at_sender=True) - else: - logger.info(f'USER {event.user_id} 关闭了 GROUP {group} 的广播') - await oc_gb.finish(await close_remind(group, 'gb'), at_sender=True) - # except Exception as e: - # await oc_gb.finish(f'关闭 {group} 的广播失败', at_sender=True) - else: - await oc_gb.finish('请输入正确的群号', at_sender=True) - else: - await oc_gb.finish('请输入要关闭广播的群号', at_sender=True) - - -@del_group.handle() -async def _(bot: Bot, event: Event, state: T_State): - group = get_message_text(event.json()) - if group: - if is_number(group): - try: - await bot.set_group_leave(group_id=int(group)) - logger.info(f'退出群聊 {group} 成功') - await del_group.finish(f'退出群聊 {group} 成功', at_sender=True) - except Exception as e: - logger.info(f'退出群聊 {group} 失败 e:{e}') - else: - await del_group.finish(f'请输入正确的群号', at_sender=True) - else: - await del_group.finish(f'请输入群号', at_sender=True) - - -@cls_group.handle() -async def _(bot: Bot, event: Event, state: T_State): - gl = await bot.get_group_list(self_id=bot.self_id) - msg = ["{group_id} {group_name}".format_map(g) for g in gl] - msg = "\n".join(msg) - msg = f"bot:{bot.self_id}\n| 群号 | 群名 | 共{len(gl)}个群\n" + msg - await bot.send_private_msg(self_id=bot.self_id, user_id=int(list(bot.config.superusers)[0]), message=msg) - - -@cls_friend.handle() -async def _(bot: Bot, event: Event, state: T_State): - gl = await bot.get_friend_list(self_id=bot.self_id) - msg = ["{user_id} {nickname}".format_map(g) for g in gl] - msg = "\n".join(msg) - msg = f"| QQ号 | 昵称 | 共{len(gl)}个好友\n" + msg - await bot.send_private_msg(self_id=bot.self_id, user_id=int(list(bot.config.superusers)[0]), message=msg) - - -@update_group_info.handle() -async def _(bot: Bot, event: Event, state: T_State): - bot = get_bot() - gl = await bot.get_group_list(self_id=bot.self_id) - gl = [g['group_id'] for g in gl] - num = 0 - rst = '' - for g in gl: - group_info = await bot.get_group_info(group_id=g) - if await GroupInfo.add_group_info(group_info['group_id'], group_info['group_name'], - group_info['max_member_count'], group_info['member_count']): - num += 1 - logger.info(f'自动更新群组 {g} 信息成功') - else: - logger.info(f'自动更新群组 {g} 信息失败') - rst += f'{g} 更新失败\n' - await update_group_info.send(f'成功更新了 {num} 个群的信息\n{rst[:-1]}') - - -@update_friend_info.handle() -async def _(bot: Bot, event: Event, state: T_State): - num = 0 - rst = '' - fl = await get_bot().get_friend_list(self_id=bot.self_id) - for f in fl: - if await FriendUser.add_friend_info(f['user_id'], f['nickname']): - logger.info(f'自动更新好友 {f["user_id"]} 信息成功') - num += 1 - else: - logger.warning(f'自动更新好友 {f["user_id"]} 信息失败') - rst += f'{f["user_id"]} 更新失败\n' - await update_friend_info.send(f'成功更新了 {num} 个好友的信息\n{rst[:-1]}') - - -# @update_cmd.handle() -# async def _(bot: Bot, event: Event, state: T_State): -# gl = await bot.get_group_list(self_id=bot.self_id) -# gl = [g['group_id'] for g in gl] -# for g in gl: -# check_group_switch_json(g) -# for file in os.listdir(DATA_PATH + 'group_help'): -# os.remove(DATA_PATH + f'group_help/{file}') -# await update_cmd.finish('更新命令完成!', at_sender=True) - - - - - diff --git a/plugins/super_cmd/__pycache__/__init__.cpython-38.pyc b/plugins/super_cmd/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index e66c1331..00000000 Binary files a/plugins/super_cmd/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/super_cmd/__pycache__/__init__.cpython-39.pyc b/plugins/super_cmd/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index ab671aa2..00000000 Binary files a/plugins/super_cmd/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/super_cmd/__pycache__/data_source.cpython-38.pyc b/plugins/super_cmd/__pycache__/data_source.cpython-38.pyc deleted file mode 100644 index 8fd1428b..00000000 Binary files a/plugins/super_cmd/__pycache__/data_source.cpython-38.pyc and /dev/null differ diff --git a/plugins/super_cmd/__pycache__/data_source.cpython-39.pyc b/plugins/super_cmd/__pycache__/data_source.cpython-39.pyc deleted file mode 100644 index 3622359d..00000000 Binary files a/plugins/super_cmd/__pycache__/data_source.cpython-39.pyc and /dev/null differ diff --git a/plugins/super_cmd/data_source.py b/plugins/super_cmd/data_source.py deleted file mode 100644 index c9f837bd..00000000 --- a/plugins/super_cmd/data_source.py +++ /dev/null @@ -1,76 +0,0 @@ -from models.group_remind import GroupRemind - - -async def open_remind(group: int, name: str) -> str: - _name = '' - if name == 'zwa': - _name = '早晚安' - if name == 'dz': - _name = '地震播报' - if name == 'hy': - _name = '群欢迎' - if name == 'kxcz': - _name = '开箱重置提醒' - if name == 'gb': - _name = '广播' - if await GroupRemind.get_status(group, name): - return f'该群已经开启过 {_name} 通知,请勿重复开启!' - if await GroupRemind.set_status(group, name, True): - return f'成功开启 {_name} 通知!0v0' - else: - return f'开启 {_name} 通知失败了...' - - -async def close_remind(group: int, name: str) -> str: - _name = '' - if name == 'zwa': - _name = '早晚安' - if name == 'dz': - _name = '地震播报' - if name == 'hy': - _name = '群欢迎' - if name == 'kxcz': - _name = '开箱重置提醒' - if name == 'gb': - _name = '广播' - if not await GroupRemind.get_status(group, name): - return f'该群已经取消过 {_name} 通知,请勿重复取消!' - if await GroupRemind.set_status(group, name, False): - return f'成功关闭 {_name} 通知!0v0' - else: - return f'关闭 {_name} 通知失败了...' - - -# cmd_list = ['总开关', '签到', '发送图片', '色图', '黑白草图', 'coser', '鸡汤/语录', '骂我', '开箱', '鲁迅说', '假消息', '商店系统', -# '操作图片', '查询皮肤', '天气', '疫情', '识番', '搜番', '点歌', 'pixiv', 'rss', '方舟一井', '查干员', '骰子娘', '原神一井'] -# -# -# def check_group_switch_json(group_id): -# if not os.path.exists(DATA_PATH + f'rule/group_switch/'): -# os.mkdir(DATA_PATH + f'rule/group_switch/') -# if not os.path.exists(DATA_PATH + f'rule/group_switch/{group_id}.json'): -# with open(DATA_PATH + f'rule/group_switch/{group_id}.json', 'w', encoding='utf8') as f: -# data = {} -# for cmd in cmd_list: -# data[cmd] = True -# f.write(json.dumps(data, ensure_ascii=False)) -# else: -# with open(DATA_PATH + f'rule/group_switch/{group_id}.json', 'r', encoding='utf8') as f: -# try: -# data = json.load(f) -# except ValueError: -# data = {} -# if len(data.keys()) - 1 != len(cmd_list): -# for cmd in cmd_list: -# if cmd not in data.keys(): -# data[cmd] = True -# with open(DATA_PATH + f'rule/group_switch/{group_id}.json', 'w', encoding='utf8') as wf: -# wf.write(json.dumps(data, ensure_ascii=False)) -# reload(data) -# for file in os.listdir(DATA_PATH + 'group_help'): -# os.remove(DATA_PATH + f'group_help/{file}') - - -def reload(data): - static_group_dict = data - diff --git a/plugins/super_help/__init__.py b/plugins/super_help/__init__.py deleted file mode 100644 index fdec2b34..00000000 --- a/plugins/super_help/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -from nonebot import on_command -from nonebot.permission import SUPERUSER -from nonebot.typing import T_State -from nonebot.adapters import Bot, Event -from nonebot.rule import to_me - - -super_help = on_command("超级用户帮助", rule=to_me(), priority=1, permission=SUPERUSER, block=True) - - -@super_help.handle() -async def _(bot: Bot, event: Event, state: T_State): - result = '''超级用户帮助: - 1.添加/删除管理 - 2.查看群组/查看好友 - 3.广播 --> 指令:广播- - 4.更新色图 - 5.回复 --> 指令:/t 用户 群号 - 6.更新cookie --> 指令:更新cookie text - 7.开启广播通知 --> 指令:开启广播通知 群号 - 8.退群 --> 指令:退群 群号 - 9.自检 - 10.更新好友信息 - 11.更新群群信息''' - await super_help.finish(result, at_sender=True) \ No newline at end of file diff --git a/plugins/super_help/__pycache__/__init__.cpython-38.pyc b/plugins/super_help/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 6755e6d4..00000000 Binary files a/plugins/super_help/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/super_help/__pycache__/__init__.cpython-39.pyc b/plugins/super_help/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 5487f85a..00000000 Binary files a/plugins/super_help/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/test.py b/plugins/test.py deleted file mode 100644 index 4fa87c0c..00000000 --- a/plugins/test.py +++ /dev/null @@ -1,36 +0,0 @@ -from nonebot.rule import to_me -from nonebot.typing import T_State -from nonebot.adapters.cqhttp import Bot, GroupMessageEvent, MessageEvent -from nonebot import on_command, on_keyword -from nonebot.plugin import MatcherGroup -from nonebot.adapters.cqhttp.event import GroupRequestEvent -import nonebot -from models.open_cases_user import OpenCasesUser -from tzlocal import get_localzone -from datetime import datetime, timezone, timedelta -from util.utils import get_bot, get_message_imgs, get_local_proxy -from util.init_result import * -from nonebot.adapters.cqhttp.message import MessageSegment -import requests -import aiohttp -from models.bag_user import UserBag -from nonebot.adapters.cqhttp.message import Message -import asyncio -from models.group_member_info import GroupInfoUser - -# erm = on_command('异世相遇,尽享美味', aliases={'异世相遇 尽享美味', '异世相遇,尽享美味'}, priority=5, block=True) - -matcher = on_keyword({"test"}) - - -@matcher.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - for i in range(1001, len(os.listdir(IMAGE_PATH + 'setu/'))): - await matcher.send(f"id:{i}" + image(f'{i}.jpg', 'setu')) - await asyncio.sleep(0.5) - - -# @erm.handle() -# async def first_receive(bot: Bot, event: Event, state: T_State): -# print(record('erm')) -# await matcher.send(record('erm')) diff --git a/plugins/translate/__init__.py b/plugins/translate/__init__.py deleted file mode 100644 index e436eb88..00000000 --- a/plugins/translate/__init__.py +++ /dev/null @@ -1,37 +0,0 @@ -from nonebot import on_command -from util.utils import get_message_text -from services.log import logger -from nonebot.adapters.cqhttp import Bot, MessageEvent -from nonebot.typing import T_State -from .data_source import translate_msg - - -__plugin_name__ = '翻译' - - -translate = on_command("translate", aliases={'英翻', '翻英', - '日翻', '翻日', - '韩翻', '翻韩' - }, priority=5, block=True) - - -@translate.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - msg = get_message_text(event.json()) - if msg: - state['msg'] = msg - - -@translate.got('msg', prompt='你要翻译的消息是啥?') -async def _(bot: Bot, event: MessageEvent, state: T_State): - msg = state['msg'] - if len(msg) > 150: - await translate.finish('翻译过长!请不要超过150字', at_sender=True) - await translate.send(await translate_msg(state["_prefix"]["raw_command"], msg)) - logger.info( - f"(USER {event.user_id}, GROUP " - f"{event.group_id if event.message_type != 'private' else 'private'}) 使用翻译:{msg}") - - - - diff --git a/plugins/translate/__pycache__/__init__.cpython-38.pyc b/plugins/translate/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index a9261592..00000000 Binary files a/plugins/translate/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/translate/__pycache__/__init__.cpython-39.pyc b/plugins/translate/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 336f5431..00000000 Binary files a/plugins/translate/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/translate/__pycache__/data_source.cpython-38.pyc b/plugins/translate/__pycache__/data_source.cpython-38.pyc deleted file mode 100644 index 006b8c7e..00000000 Binary files a/plugins/translate/__pycache__/data_source.cpython-38.pyc and /dev/null differ diff --git a/plugins/translate/__pycache__/data_source.cpython-39.pyc b/plugins/translate/__pycache__/data_source.cpython-39.pyc deleted file mode 100644 index f181e919..00000000 Binary files a/plugins/translate/__pycache__/data_source.cpython-39.pyc and /dev/null differ diff --git a/plugins/translate/data_source.py b/plugins/translate/data_source.py deleted file mode 100644 index ff8c350d..00000000 --- a/plugins/translate/data_source.py +++ /dev/null @@ -1,69 +0,0 @@ -import aiohttp -from util.utils import get_local_proxy -from util.user_agent import get_user_agent - -url = f'http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule&smartresult=ugc&sessionFrom=null' - - -async def translate_msg(language_type, msg): - data = { - 'type': parse_language(language_type), - 'i': msg, - "doctype": "json", - "version": "2.1", - "keyfrom": "fanyi.web", - "ue": "UTF-8", - "action": "FY_BY_CLICKBUTTON", - "typoResult": "true" - } - async with aiohttp.ClientSession(headers=get_user_agent()) as session: - async with session.post(url, data=data, proxy=get_local_proxy()) as res: - data = await res.json() - if data['errorCode'] == 0: - return data['translateResult'][0][0]['tgt'] - return '翻译惜败..' - -# ZH_CN2EN 中文 » 英语 -# ZH_CN2JA 中文 » 日语 -# ZH_CN2KR 中文 » 韩语 -# ZH_CN2FR 中文 » 法语 -# ZH_CN2RU 中文 » 俄语 -# ZH_CN2SP 中文 » 西语 -# EN2ZH_CN 英语 » 中文 -# JA2ZH_CN 日语 » 中文 -# KR2ZH_CN 韩语 » 中文 -# FR2ZH_CN 法语 » 中文 -# RU2ZH_CN 俄语 » 中文 -# SP2ZH_CN 西语 » 中文 - - -def parse_language(language_type): - if language_type == '英翻': - return 'EN2ZH_CN' - if language_type == '日翻': - return 'JA2ZH_CN' - if language_type == '韩翻': - return 'KR2ZH_CN' - # if language_type == '法翻': - # return 'FR2ZH_CN' - # if language_type == '俄翻': - # return 'RU2ZH_CN' - if language_type == '翻英': - return 'ZH_CN2EN' - if language_type == '翻日': - return 'ZH_CN2JA' - if language_type == '翻韩': - return 'ZH_CN2KR' - # if language_type == '翻法': - # return 'ZH_CN2FR' - # if language_type == '翻俄': - # return 'ZH_CN2RU' - - - - - - - - - diff --git a/plugins/update_gocqhttp/__init__.py b/plugins/update_gocqhttp/__init__.py deleted file mode 100644 index 56ff418c..00000000 --- a/plugins/update_gocqhttp/__init__.py +++ /dev/null @@ -1,61 +0,0 @@ -from nonebot import on_command -from nonebot.typing import T_State -from nonebot.adapters.cqhttp import Bot, GroupMessageEvent -from .data_source import download_gocq_lasted, upload_gocq_lasted -import os -from nonebot.adapters.cqhttp.permission import GROUP -from services.log import logger -from util.utils import scheduler, get_bot, UserExistLimiter -from configs.config import UPDATE_GOCQ_GROUP -from pathlib import Path - -path = str(Path('/resources/gocqhttp_file/').absolute()) + '/' - -lasted_gocqhttp = on_command("更新gocq", permission=GROUP, priority=5, block=True) - - -_ulmt = UserExistLimiter() - - -@lasted_gocqhttp.handle() -async def _(bot: Bot, event: GroupMessageEvent, state: T_State): - # try: - if event.group_id in UPDATE_GOCQ_GROUP: - await lasted_gocqhttp.send('检测中...') - info = await download_gocq_lasted() - if info == 'gocqhttp没有更新!': - await lasted_gocqhttp.finish('gocqhttp没有更新!') - if _ulmt.check(event.group_id): - await lasted_gocqhttp.finish('gocqhttp正在更新,请勿重复使用该命令', at_sender=True) - _ulmt.set_True(event.group_id) - try: - for file in os.listdir(path): - await upload_gocq_lasted(file, event.group_id) - logger.info(f'更新了cqhttp...{file}') - await lasted_gocqhttp.send(f'gocqhttp更新了,已上传成功!\n更新内容:\n{info}') - except Exception as e: - logger.error(f'更新gocq错误 e:{e}') - _ulmt.set_False(event.group_id) - - -# 更新gocq -@scheduler.scheduled_job( - 'cron', - hour=3, - minute=1, -) -async def _(): - if UPDATE_GOCQ_GROUP: - bot = get_bot() - try: - info = await download_gocq_lasted() - if info == 'gocqhttp没有更新!': - logger.info('gocqhttp没有更新!') - return - for group in UPDATE_GOCQ_GROUP: - for file in os.listdir(path): - await upload_gocq_lasted(file, group) - await bot.send_group_msg(group_id=group, message=f"gocqhttp更新了,已上传成功!\n更新内容:\n{info}") - except Exception as e: - logger.error(f'自动更新gocq出错 e:{e}') - diff --git a/plugins/update_gocqhttp/__pycache__/__init__.cpython-38.pyc b/plugins/update_gocqhttp/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index d5285901..00000000 Binary files a/plugins/update_gocqhttp/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/update_gocqhttp/__pycache__/__init__.cpython-39.pyc b/plugins/update_gocqhttp/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index fa5e7fbe..00000000 Binary files a/plugins/update_gocqhttp/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/update_gocqhttp/__pycache__/data_source.cpython-38.pyc b/plugins/update_gocqhttp/__pycache__/data_source.cpython-38.pyc deleted file mode 100644 index 0c5aa246..00000000 Binary files a/plugins/update_gocqhttp/__pycache__/data_source.cpython-38.pyc and /dev/null differ diff --git a/plugins/update_gocqhttp/__pycache__/data_source.cpython-39.pyc b/plugins/update_gocqhttp/__pycache__/data_source.cpython-39.pyc deleted file mode 100644 index 534c95d4..00000000 Binary files a/plugins/update_gocqhttp/__pycache__/data_source.cpython-39.pyc and /dev/null differ diff --git a/plugins/update_gocqhttp/data_source.py b/plugins/update_gocqhttp/data_source.py deleted file mode 100644 index 4dc669cd..00000000 --- a/plugins/update_gocqhttp/data_source.py +++ /dev/null @@ -1,76 +0,0 @@ -import aiohttp -from util.utils import get_local_proxy, get_bot -from util.user_agent import get_user_agent -import asyncio -import platform -import aiofiles -from bs4 import BeautifulSoup -import os -if platform.system() == 'Windows': - path = os.getcwd() + '/resources/gocqhttp_file/' - asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) -else: - path = r'/home/hibiki/hibikibot/resources/gocqhttp_file/' - - -url = 'https://github.com/Mrs4s/go-cqhttp/releases' - - -async def download_gocq_lasted(): - async with aiohttp.ClientSession(headers=get_user_agent()) as session: - async with session.get(url, proxy=get_local_proxy()) as response: - soup = BeautifulSoup(await response.text(), 'lxml') - a = soup.find('div', {'class': 'release-header'}).find('a') - title = a.text - _url = a.get('href') - for file in os.listdir(path): - if file.endswith('.zip'): - if file == title + '-windows-amd64.zip' or file == title + '_windows_amd64.zip': - return 'gocqhttp没有更新!' - for file in os.listdir(path): - os.remove(path + file) - async with session.get("https://github.com" + _url, proxy=get_local_proxy()) as res: - update_info = '' - soup = BeautifulSoup(await res.text(), 'lxml') - info_div = soup.find('div', {'class': 'markdown-body'}) - for p in info_div.find_all('p'): - update_info += p.text.replace('
', '\n') + '\n' - div_all = soup.select('div.d-flex.flex-justify-between.flex-items-center.py-1.py-md-2.Box-body.px-2') - for div in div_all: - if div.find('a').find('span').text == title + '-windows-amd64.zip' or\ - div.find('a').find('span').text == title + '-linux-arm64.tar.gz' or\ - div.find('a').find('span').text == 'go-cqhttp_windows_amd64.zip' or \ - div.find('a').find('span').text == 'go-cqhttp_linux_arm64.tar.gz': - file_url = div.find('a').get('href') - if div.find('a').find('span').text.find('windows') == -1: - tag = '-linux-arm64.tar.gz' - else: - tag = '-windows-amd64.zip' - async with session.get("https://github.com" + file_url, proxy=get_local_proxy()) as res_file: - async with aiofiles.open(path + title + tag, 'wb') as f: - await f.write(await res_file.read()) - return update_info - - -async def upload_gocq_lasted(name, group_id): - bot = get_bot() - folder_id = 0 - for folder in (await bot.get_group_root_files(group_id=group_id))['folders']: - if folder['folder_name'] == 'gocq': - folder_id = folder['folder_id'] - if not folder_id: - await bot.send_group_msg(group_id=group_id, - message=f'请创建gocq文件夹后重试!') - for file in os.listdir(path): - os.remove(path+file) - else: - await bot.upload_group_file( - group_id=group_id, - folder=folder_id, - file=path + name, - name=name - ) - - -# asyncio.get_event_loop().run_until_complete(download_gocq_lasted()) - diff --git a/plugins/update_info.py b/plugins/update_info.py deleted file mode 100644 index 4c2d3ce7..00000000 --- a/plugins/update_info.py +++ /dev/null @@ -1,23 +0,0 @@ -from nonebot import on_command -from nonebot.adapters.cqhttp import Bot, Event -from nonebot.typing import T_State -from util.init_result import image - -__plugin_name__ = '更新信息' - - -update_info = on_command("更新信息", priority=5, block=True) - - -@update_info.handle() -async def _(bot: Bot, event: Event, state: T_State): - img = image('update_info.png') - if img: - await update_info.finish(image('update_info.png')) - else: - await update_info.finish('目前没有更新信息哦') - - - - - diff --git a/plugins/update_pic.py b/plugins/update_pic.py deleted file mode 100644 index 0ab3532f..00000000 --- a/plugins/update_pic.py +++ /dev/null @@ -1,250 +0,0 @@ -from nonebot import on_command -from PIL import Image, ImageFilter -from util.init_result import image -from configs.path_config import IMAGE_PATH -from services.log import logger -from nonebot.rule import to_me -from nonebot.adapters.cqhttp import Bot, MessageEvent -from nonebot.typing import T_State -from util.utils import get_message_imgs -import aiofiles -import aiohttp -from util.utils import is_number, get_message_text -from util.img_utils import CreateImg, pic2b64 -import cv2 -import numpy as np - - -__plugin_name__ = '图片' -__plugin_usage__ = '''图片用法(目前): -可以输入 指定操作 或 序号 来进行选择 - 1.修改尺寸 宽(x) 高(y) 图片(在文字后跟图片即可) - 示例:小真寻修改图片 修改尺寸 200 300 图片(在文字后跟图片即可) - 2.等比压缩 比例(x) 图片(在文字后跟图片即可) - 示例:小真寻修改图片 等比压缩 2 图片(在文字后跟图片即可) - 3.旋转图片 角度(x) 图片(在文字后跟图片即可) - 示例:小真寻修改图片 旋转图片 45 图片(在文字后跟图片即可) - 4.水平翻转 - 示例:小真寻修改图片 水平翻转 图片 - 5.铅笔滤镜 - 示例:小真寻修改图片 铅笔滤镜 图片 - 6.模糊效果 - 示例:小真寻修改图片 模糊效果 图片 - 7.锐化效果 - 示例:小真寻修改图片 锐化效果 图片 - 8.高斯模糊 - 示例:小真寻修改图片 高斯模糊 图片 - 9.边缘检测 - 示例:小真寻修改图片 边缘检测 图片 - 10.底色替换 颜色 颜色 图片 (不专业)支持:(红,蓝)->(红,蓝,白,绿,黄) - 示例:小真寻修改图片 底色替换 蓝色 红色 图片''' - -# IMAGE_LOCAL = IMAGE_PATH + "temp/{}_update.png" -method_flag = '' - -update_img = on_command("修改图片", aliases={'图片', '操作图片', '改图'}, priority=5, rule=to_me(), block=True) - -method_list = ['修改尺寸', '等比压缩', '旋转图片', '水平翻转', '铅笔滤镜', '模糊效果', '锐化效果', '高斯模糊', '边缘检测', '底色替换'] -method_str = '' -method_oper = [] -for i in range(len(method_list)): - method_str += f'\n{i + 1}.{method_list[i]}' - method_oper.append(method_list[i]) - method_oper.append(str(i + 1)) - -update_img_help = CreateImg(960, 700, font_size=24) -update_img_help.text((10, 10), __plugin_usage__) -update_img_help.save(IMAGE_PATH + 'update_img_help.png') - - -@update_img.args_parser -async def _(bot: Bot, event: MessageEvent, state: T_State): - global method_flag - if str(event.get_message()) in ['取消', '算了']: - await update_img.finish("已取消操作..", at_sender=True) - if state["_current_key"] in ['method']: - if str(event.get_message()) not in method_oper: - await update_img.reject(f"操作不正确,请重新输入!{method_str}") - state[state["_current_key"]] = str(event.get_message()) - method_flag = str(event.get_message()) - if method_flag in ['1', '修改尺寸']: - if state["_current_key"] == 'x': - if not is_number(str(event.get_message())): - await update_img.reject("宽度不正确!请重新输入数字...") - state[state["_current_key"]] = str(event.get_message()) - if state["_current_key"] == 'y': - if not is_number(str(event.get_message())): - await update_img.reject("长度不正确!请重新输入数字...") - state[state["_current_key"]] = str(event.get_message()) - elif method_flag in ['2', '等比压缩', '3', '旋转图片']: - if state["_current_key"] == 'x': - if not is_number(str(event.get_message())): - await update_img.reject("比率不正确!请重新输入数字...") - state[state["_current_key"]] = str(event.get_message()) - state['y'] = '' - elif method_flag in ['4', '水平翻转', '5', '铅笔滤镜', '6', '模糊效果', '7', '锐化效果', '8', '高斯模糊', '9', '边缘检测']: - state['x'] = '' - state['y'] = '' - elif method_flag in ['10', '底色替换']: - if state["_current_key"] == 'x': - if str(event.get_message()) not in ['红色', '蓝色', '红', '蓝']: - await update_img.reject('请输入支持的被替换的底色:\n红色 蓝色') - state['x'] = str(event.get_message()) - if state["_current_key"] == 'y': - if str(event.get_message()) not in ['红色', '白色', '蓝色', '绿色', '黄色', '红', '白', '蓝', '绿', '黄']: - await update_img.reject('请输入支持的替换的底色:\n红色 蓝色 白色 绿色') - state['y'] = str(event.get_message()) - if state["_current_key"] == 'imgs': - if not get_message_imgs(event.json()): - await update_img.reject("没图?没图?没图?来图速来!") - state[state["_current_key"]] = get_message_imgs(event.json()) - - -@update_img.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - if str(event.get_message()) in ['帮助']: - await update_img.finish(image('update_img_help.png')) - raw_arg = get_message_text(event.json()) - img_list = get_message_imgs(event.json()) - if raw_arg: - args = raw_arg.split("[")[0].split(" ") - print(args) - state['method'] = args[0] - if len(args) == 2: - if args[0] in ["等比压缩", '旋转图片']: - if is_number(args[1]): - state['x'] = args[1] - state['y'] = '' - elif len(args) > 2: - if args[0] in ["修改尺寸"]: - if is_number(args[1]): - state['x'] = args[1] - if is_number(args[2]): - state['y'] = args[2] - if args[0] in ['底色替换']: - if args[1] in ['红色', '蓝色', '蓝', '红']: - state['x'] = args[1] - if args[2] in ['红色', '白色', '蓝色', '绿色', '黄色', '红', '白', '蓝', '绿', '黄']: - state['y'] = args[2] - if args[0] in ['水平翻转', '铅笔滤镜', '模糊效果', '锐化效果', '高斯模糊', '边缘检测']: - state['x'] = '' - state['y'] = '' - if img_list: - state['imgs'] = img_list - - -@update_img.got("method", prompt=f"要使用图片的什么操作呢?{method_str}") -@update_img.got("x", prompt="[宽度? 比率? 旋转角度? 底色?]") -@update_img.got("y", prompt="[长度? 0 0 底色?]") -@update_img.got("imgs", prompt="图呢图呢图呢图呢?GKD!") -async def _(bot: Bot, event: MessageEvent, state: T_State): - method = state['method'] - x = state['x'] if state['x'] else '' - y = state['y'] if state['y'] else '' - img_list = state['imgs'] - if is_number(x): - x = float(x) - if is_number(y): - y = int(y) - index = 0 - result = '' - async with aiohttp.ClientSession() as session: - for img_url in img_list: - async with session.get(img_url, timeout=7) as response: - if response.status == 200: - async with aiofiles.open(IMAGE_PATH + f'temp/{event.user_id}_{index}_update.png', 'wb') as f: - await f.write(await response.read()) - index += 1 - else: - logger.warning(f"USER {event.user_id} GROUP " - f"{event.group_id if event.message_type != 'private' else 'private'} " - f"使用 {method} 时下载图片超时") - await update_img.finish("获取图片超时了...", at_sender=True) - if index == 0: - return - if method in ['修改尺寸', '1']: - for i in range(index): - img = Image.open(IMAGE_PATH + f'temp/{event.user_id}_{i}_update.png') - img = img.convert('RGB') - img = img.resize((int(x), int(y)), Image.ANTIALIAS) - result += image(b64=pic2b64(img)) - await update_img.finish(result, at_sender=True) - if method in ['等比压缩', '2']: - for i in range(index): - img = Image.open(IMAGE_PATH + f'temp/{event.user_id}_{i}_update.png') - width, height = img.size - img = img.convert('RGB') - if width * x < 8000 and height * x < 8000: - img = img.resize((int(x * width), int(x * height))) - result += image(b64=pic2b64(img)) - else: - await update_img.finish('小真寻不支持图片压缩后宽或高大于8000的存在!!') - if method in ['旋转图片', '3']: - for i in range(index): - img = Image.open(IMAGE_PATH + f'temp/{event.user_id}_{i}_update.png') - img = img.rotate(x) - result += image(b64=pic2b64(img)) - if method in ['水平翻转', '4']: - for i in range(index): - img = Image.open(IMAGE_PATH + f'temp/{event.user_id}_{i}_update.png') - img = img.transpose(Image.FLIP_LEFT_RIGHT) - result += image(b64=pic2b64(img)) - if method in ['铅笔滤镜', '5']: - for i in range(index): - img = Image.open(IMAGE_PATH + f'temp/{event.user_id}_{i}_update.png').filter(ImageFilter.CONTOUR) - result += image(b64=pic2b64(img)) - if method in ['模糊效果', '6']: - for i in range(index): - img = Image.open(IMAGE_PATH + f'temp/{event.user_id}_{i}_update.png').filter(ImageFilter.BLUR) - result += image(b64=pic2b64(img)) - if method in ['锐化效果', '7']: - for i in range(index): - img = Image.open(IMAGE_PATH + f'temp/{event.user_id}_{i}_update.png').filter(ImageFilter.EDGE_ENHANCE) - result += image(b64=pic2b64(img)) - if method in ['高斯模糊', '8']: - for i in range(index): - img = Image.open(IMAGE_PATH + f'temp/{event.user_id}_{i}_update.png').filter(ImageFilter.GaussianBlur) - result += image(b64=pic2b64(img)) - if method in ['边缘检测', '9']: - for i in range(index): - img = Image.open(IMAGE_PATH + f'temp/{event.user_id}_{i}_update.png').filter(ImageFilter.FIND_EDGES) - result += image(b64=pic2b64(img)) - if method in ['底色替换', '10']: - if x in ['蓝色', '蓝']: - lower = np.array([90, 70, 70]) - upper = np.array([110, 255, 255]) - if x in ['红色', '红']: - lower = np.array([0, 135, 135]) - upper = np.array([180, 245, 230]) - if y in ['蓝色', '蓝']: - color = (255, 0, 0) - if y in ['红色', '红']: - color = (0, 0, 255) - if y in ['白色', '白']: - color = (255, 255, 255) - if y in ['绿色', '绿']: - color = (0, 255, 0) - if y in ['黄色', '黄']: - color = (0, 255, 255) - for k in range(index): - img = cv2.imread(IMAGE_PATH + f'temp/{event.user_id}_{k}_update.png') - img = cv2.resize(img, None, fx=0.3, fy=0.3) - rows, cols, channels = img.shape - hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) - mask = cv2.inRange(hsv, lower, upper) - # erode = cv2.erode(mask, None, iterations=1) - dilate = cv2.dilate(mask, None, iterations=1) - for i in range(rows): - for j in range(cols): - if dilate[i, j] == 255: - img[i, j] = color - cv2.imwrite(IMAGE_PATH + f'temp/{event.user_id}_{k}_ok_update.png', img) - for i in range(index): - result += image(f'{event.user_id}_{i}_ok_update.png', 'temp') - if is_number(method): - method = method_list[int(method) - 1] - logger.info( - f"(USER {event.user_id}, GROUP" - f" {event.group_id if event.message_type != 'private' else 'private'}) 使用{method}") - await update_img.finish(result, at_sender=True) - diff --git a/plugins/update_setu/__init__.py b/plugins/update_setu/__init__.py deleted file mode 100644 index 4a0ba2c5..00000000 --- a/plugins/update_setu/__init__.py +++ /dev/null @@ -1,43 +0,0 @@ -from util.utils import scheduler -from nonebot import on_command -from nonebot.permission import SUPERUSER -from nonebot.typing import T_State -from nonebot.adapters import Bot, Event -from nonebot.rule import to_me -from .data_source import update_setu_img -from configs.config import DOWNLOAD_SETU - - -__name__ = "更新色图 [Hidden]" - - -update_setu = on_command("更新色图", rule=to_me(), permission=SUPERUSER, priority=1, block=True) - - -@update_setu.handle() -async def _(bot: Bot, event: Event, state: T_State): - if DOWNLOAD_SETU: - await update_setu.send("开始更新色图...", at_sender=True) - await update_setu.finish(await update_setu_img(), at_sender=True) - else: - await update_setu.finish('更新色图配置未开启') - - -# 更新色图 -@scheduler.scheduled_job( - 'cron', - # year=None, - # month=None, - # day=None, - # week=None, - # day_of_week="mon,tue,wed,thu,fri", - hour=4, - minute=30, - # second=None, - # start_date=None, - # end_date=None, - # timezone=None, -) -async def _(): - if DOWNLOAD_SETU: - await update_setu_img() diff --git a/plugins/update_setu/__pycache__/__init__.cpython-38.pyc b/plugins/update_setu/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 487f7d7b..00000000 Binary files a/plugins/update_setu/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/update_setu/__pycache__/__init__.cpython-39.pyc b/plugins/update_setu/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index e7f2f438..00000000 Binary files a/plugins/update_setu/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/update_setu/__pycache__/data_source.cpython-38.pyc b/plugins/update_setu/__pycache__/data_source.cpython-38.pyc deleted file mode 100644 index 5e57ef3b..00000000 Binary files a/plugins/update_setu/__pycache__/data_source.cpython-38.pyc and /dev/null differ diff --git a/plugins/update_setu/__pycache__/data_source.cpython-39.pyc b/plugins/update_setu/__pycache__/data_source.cpython-39.pyc deleted file mode 100644 index 6e349f93..00000000 Binary files a/plugins/update_setu/__pycache__/data_source.cpython-39.pyc and /dev/null differ diff --git a/plugins/update_setu/data_source.py b/plugins/update_setu/data_source.py deleted file mode 100644 index 08db0937..00000000 --- a/plugins/update_setu/data_source.py +++ /dev/null @@ -1,86 +0,0 @@ -from configs.path_config import IMAGE_PATH, TXT_PATH -import os -from util.user_agent import get_user_agent -from services.log import logger -from datetime import datetime -from util.img_utils import rar_imgs, get_img_hash -from util.utils import get_bot, get_local_proxy -from asyncio.exceptions import TimeoutError -import aiofiles -import aiohttp -try: - import ujson as json -except ModuleNotFoundError: - import json - - -async def update_setu_img(): - async with aiohttp.ClientSession(headers=get_user_agent()) as session: - for file_name in ['setu_url.txt', 'setu_r18_url.txt']: - if file_name == 'setu_url.txt': - json_name = 'setu_img_hash.json' - path = 'setu/' - else: - json_name = 'r18_setu_img_hash.json' - path = 'r18/' - try: - data = json.load(open(TXT_PATH + json_name)) - if not data: - continue - except (FileNotFoundError, TypeError): - continue - _success = 0 - _similar = 0 - try: - with open(TXT_PATH + file_name, 'r') as f: - txt_data = f.read() - if not txt_data: - continue - except FileNotFoundError: - continue - urls = list(set(txt_data[:-1].split(','))) - total = len(urls) - for url in urls: - index = str(len(os.listdir(IMAGE_PATH + path))) - logger.info(f'开始更新 index:{index} --> {url}') - for _ in range(3): - try: - async with session.get(url, proxy=get_local_proxy(), timeout=15) as response: - if response.status == 200: - async with aiofiles.open(IMAGE_PATH + 'rar/' + index + ".jpg", 'wb') as f: - await f.write(await response.read()) - _success += 1 - else: - logger.info(f'{url} 不存在,跳过更新') - break - if os.path.getsize(IMAGE_PATH + 'rar/' + str(index) + ".jpg") > 1024 * 1024 * 1.5: - rar_imgs( - 'rar/', - path, - in_file_name=index, - out_file_name=index - ) - else: - logger.info('不需要压缩,移动图片 ' + IMAGE_PATH + 'rar/' + index + ".jpg --> " - + IMAGE_PATH + path + index + ".jpg") - os.rename(IMAGE_PATH + 'rar/' + index + ".jpg", - IMAGE_PATH + path + index + ".jpg") - img_hash = str(get_img_hash(f'{IMAGE_PATH}{path}{index}.jpg')) - if img_hash in data.values(): - logger.info(f'index:{index} 与 ' - f'{list(data.keys())[list(data.values()).index(img_hash)]} 存在重复,删除') - os.remove(IMAGE_PATH + path + index + ".jpg") - _similar += 1 - data[index] = img_hash - break - except TimeoutError: - continue - with open(TXT_PATH + json_name, 'w', encoding='utf-8') as f: - json.dump(data, f, indent=4) - open(TXT_PATH + file_name, 'w') - logger.info( - f'{str(datetime.now()).split(".")[0]} 更新 {file_name.split(".")[0]}完成,预计更新 {total} 张,实际更新 {_success} 张,相似 {_similar} 张,实际存入 {_success - _similar} 张') - await get_bot().send_private_msg( - user_id=775757368, - message=f'{str(datetime.now()).split(".")[0]} 更新{file_name.split(".")[0]}完成,预计更新 {total} 张,实际更新 {_success} 张,相似 {_similar} 张,实际存入 {_success - _similar} 张' - ) diff --git a/plugins/upload_img/__init__.py b/plugins/upload_img/__init__.py deleted file mode 100644 index a2b51151..00000000 --- a/plugins/upload_img/__init__.py +++ /dev/null @@ -1,87 +0,0 @@ -from nonebot import on_command -from configs.path_config import IMAGE_PATH -from services.log import logger -import os -from nonebot.rule import to_me -from nonebot.typing import T_State -from nonebot.adapters import Bot, Event -from util.utils import get_message_imgs, get_message_text -import aiohttp -import aiofiles -from util.utils import cn2py -from configs.config import IMAGE_DIR_LIST - -__plugin_name__ = '上传图片' -__plugin_usage__ = '上传图片帮助:\n\t' \ - '1.查看列表 --> 指令: 上传图片 列表/目录\n\t' \ - '2.上传图片 序号 图片(在文字后跟图片即可), 即在相应目录下添加图片\n\t\t示例: 上传图片 1 图片(在文字后跟图片即可)' - - -upload_img = on_command("上传图片", rule=to_me(), priority=5, block=True) - - -@upload_img.args_parser -async def parse(bot: Bot, event: Event, state: T_State): - if str(event.get_message()) in ['取消', '算了']: - await upload_img.finish("已取消操作..", at_sender=True) - if state["_current_key"] in ['path']: - if str(event.get_message()) not in IMAGE_DIR_LIST: - await upload_img.reject("此目录不正确,请重新输入目录!") - state[state["_current_key"]] = str(event.get_message()) - if state["_current_key"] in ['imgs']: - if not get_message_imgs(event.json()): - await upload_img.reject("图呢图呢图呢图呢!GKD!") - state[state['_current_key']] = get_message_imgs(event.json()) - - -@upload_img.handle() -async def _(bot: Bot, event: Event, state: T_State): - raw_arg = get_message_text(event.json()) - img_list = get_message_imgs(event.json()) - if raw_arg: - if str(event.get_message()) in ['帮助']: - await upload_img.finish(__plugin_usage__) - if raw_arg.split("[")[0] in IMAGE_DIR_LIST: - state['path'] = raw_arg.split("[")[0] - if img_list: - state['imgs'] = img_list - - -@upload_img.got("path", prompt="要将图片上传至什么图库呢?") -@upload_img.got("imgs", prompt="图呢图呢图呢图呢!GKD!") -async def _(bot: Bot, event: Event, state: T_State): - path = IMAGE_PATH + cn2py(state['path']) - img_list = state['imgs'] - img_id = len(os.listdir(path)) - failed_list = [] - success_id = "" - async with aiohttp.ClientSession() as session: - for img_url in img_list: - try: - async with session.get(img_url, timeout=7) as response: - if response.status == 200: - async with aiofiles.open(path + str(img_id) + ".jpg", 'wb') as f: - await f.write(await response.read()) - success_id += str(img_id) + "," - img_id += 1 - else: - failed_list.append(img_url) - logger.warning(f"图片:{img_url} 下载失败....") - except TimeoutError as e: - logger.warning(f"图片:{img_url} 下载超时....e:{e}") - if img_url not in failed_list: - failed_list.append(img_url) - failed_result = "" - for img in failed_list: - failed_result += str(img) + "\n" - logger.info(f"USER {event.user_id} GROUP {event.group_id if event.message_type != 'private' else 'private'}" - f" 上传图片至 {state['path']} 共 {len(img_list)} 张,失败 {len(failed_list)} 张,id={success_id[:-1]}") - if failed_result: - await upload_img.finish(f"这次一共为 {state['path']}库 添加了 {len(img_list) - len(failed_list)} 张图片\n" - f"依次的Id为:{success_id[:-1]}\n" - f"上传失败:{failed_result[:-1]}\n" - f"小真寻感谢您对图库的扩充!WW", at_sender=True) - else: - await upload_img.finish(f"这次一共为 {state['path']}库 添加了 {len(img_list)} 张图片\n" - f"依次的Id为:{success_id[:-1]}\n" - f"小真寻感谢您对图库的扩充!WW", at_sender=True) diff --git a/plugins/upload_img/__pycache__/__init__.cpython-38.pyc b/plugins/upload_img/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 4722abc2..00000000 Binary files a/plugins/upload_img/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/upload_img/__pycache__/__init__.cpython-39.pyc b/plugins/upload_img/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index fabac69a..00000000 Binary files a/plugins/upload_img/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/weather/__init__.py b/plugins/weather/__init__.py deleted file mode 100644 index 509d2274..00000000 --- a/plugins/weather/__init__.py +++ /dev/null @@ -1,95 +0,0 @@ -from nonebot import on_keyword, on_regex -from .data_source import get_weather_of_city -from nonebot.adapters.cqhttp import Bot, Event -from jieba import posseg -from services.log import logger -from nonebot.typing import T_State -from .config import city_list -import re -from util.utils import get_message_text - -__plugin_name__ = '天气查询' -__plugin_usage__ = "普普通通的查天气吧\n示例:北京天气" - - -weather = on_regex(r".*?(.*)市?的?天气.*?", priority=5, block=True) - - -@weather.handle() -async def _(bot: Bot, event: Event, state: T_State): - if str(event.get_message()) in ['帮助']: - await weather.finish(__plugin_usage__) - msg = get_message_text(event.json()) - msg = re.search(r'.*?(.*)市?的?天气.*?', msg) - msg = msg.group(1) - if msg[-1] == '的': - msg = msg[:-1] - if msg[-1] != '市': - msg += '市' - city = '' - if msg: - for word in posseg.lcut(msg): - if word.word in city_list.keys(): - await weather.finish("不要查一个省的天气啊,这么大查起来很累人的..", at_sender=True) - if word.flag == 'ns': - city = str(word.word).strip() - break - if word.word == '火星': - await weather.finish('没想到你个小呆子还真的想看火星天气!\n火星大气中含有95%的二氧化碳,气压低,加之极度的干燥,' - '就阻止了水的形成积聚。这意味着火星几乎没有云,冰层覆盖了火星的两极,它们的融化和冻结受到火星与太' - '阳远近距离的影响,它产生了强大的尘埃云,阻挡了太阳光,使冰层的融化慢下来。\n所以说火星天气太恶劣了,' - '去过一次就不想再去第二次了') - if city: - city_weather = await get_weather_of_city(city) - logger.info(f'(USER {event.user_id}, GROUP {event.group_id if event.message_type != "private" else "private"} ) ' - f'查询天气:' + city) - await weather.finish(city_weather) - # if str(event.get_message()).strip() == '天气': - # state['city'] = '-1' - # return - # msg = str(event.get_message()).strip() - # print(msg) - # flag = True - # if msg.find('开启') != -1 or msg.find('关闭') != -1: - # state['city'] = '-1' - # return - # if msg.startswith('天气'): - # if not msg.endswith('市'): - # state['city'] = msg[2:] + '市' - # else: - # state['city'] = msg[2:] - # flag = False - # elif msg.find('的天气') != -1: - # i = msg.find('的天气') - # msg = msg[:i] + '市' + msg[i:] - # elif msg.find('天气') != -1: - # i = msg.find('天气') - # msg = msg[:i] + '市' + msg[i:] - # if msg != "天气" and flag: - # print(posseg.lcut(msg)) - # for word in posseg.lcut(msg): - # if word.word in city_list.keys():# and word.word in ['北京', '上海', '天津', '重庆', '台湾']: - # await weather.finish("不要查一个省的天气啊,这么大查起来很累人的..", at_sender=True) - # if word.flag == 'ns': - # state["city"] = word.word - # break - # if word.word == '火星': - # await weather.finish('没想到你个小呆子还真的想看火星天气!\n火星大气中含有95%的二氧化碳,气压低,加之极度的干燥,' - # '就阻止了水的形成积聚。这意味着火星几乎没有云,冰层覆盖了火星的两极,它们的融化和冻结受到火星与太' - # '阳远近距离的影响,它产生了强大的尘埃云,阻挡了太阳光,使冰层的融化慢下来。\n所以说火星天气太恶劣了,' - # '去过一次就不想再去第二次了') - - -# @weather.got("city", prompt="你想查询哪个城市的天气呢?") -# async def _(bot: Bot, event: Event, state: dict): -# if state['city'] == '-1' or not state['city'].strip(): -# return -# if state['city'] in ['取消', '算了']: -# await weather.finish('已取消此次调用..') -# if state['city'][-1] != '市': -# state['city'] += '市' -# city_weather = await get_weather_of_city(state['city'].strip()) -# logger.info(f'(USER {event.user_id}, GROUP {event.group_id if event.message_type != "private" else "private"} ) ' -# f'查询天气:' + state['city']) -# await weather.finish(city_weather) - diff --git a/plugins/weather/__pycache__/__init__.cpython-38.pyc b/plugins/weather/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 02657382..00000000 Binary files a/plugins/weather/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/weather/__pycache__/__init__.cpython-39.pyc b/plugins/weather/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 4cb3d4d7..00000000 Binary files a/plugins/weather/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/weather/__pycache__/config.cpython-38.pyc b/plugins/weather/__pycache__/config.cpython-38.pyc deleted file mode 100644 index 0189b6b1..00000000 Binary files a/plugins/weather/__pycache__/config.cpython-38.pyc and /dev/null differ diff --git a/plugins/weather/__pycache__/config.cpython-39.pyc b/plugins/weather/__pycache__/config.cpython-39.pyc deleted file mode 100644 index 21697e90..00000000 Binary files a/plugins/weather/__pycache__/config.cpython-39.pyc and /dev/null differ diff --git a/plugins/weather/__pycache__/data_source.cpython-38.pyc b/plugins/weather/__pycache__/data_source.cpython-38.pyc deleted file mode 100644 index 0be8a36e..00000000 Binary files a/plugins/weather/__pycache__/data_source.cpython-38.pyc and /dev/null differ diff --git a/plugins/weather/__pycache__/data_source.cpython-39.pyc b/plugins/weather/__pycache__/data_source.cpython-39.pyc deleted file mode 100644 index b90430cc..00000000 Binary files a/plugins/weather/__pycache__/data_source.cpython-39.pyc and /dev/null differ diff --git a/plugins/weather/config.py b/plugins/weather/config.py deleted file mode 100644 index 95b8313e..00000000 --- a/plugins/weather/config.py +++ /dev/null @@ -1,34 +0,0 @@ -city_list = { - "北京": ["北京"], - "天津": ["天津"], - "山西": ["太原", "阳泉", "晋城", "长治", "临汾", "运城", "忻州", "吕梁", "晋中", "大同", "朔州"], - "河北": ["沧州", "石家庄", "唐山", "保定", "廊坊", "衡水", "邯郸", "邢台", "张家口", "辛集", "秦皇岛", "定州", "承德", "涿州"], - "山东": ["济南", "淄博", "聊城", "德州", "滨州", "济宁", "菏泽", "枣庄", "烟台", "威海", "泰安", "青岛", "临沂", "莱芜", "东营", "潍坊", "日照"], - "河南": ["郑州", "新乡", "鹤壁", "安阳", "焦作", "濮阳", "开封", "驻马店", "商丘", "三门峡", "南阳", "洛阳", "周口", "许昌", "信阳", "漯河", "平顶山", "济源"], - "广东": ["珠海", "中山", "肇庆", "深圳", "清远", "揭阳", "江门", "惠州", "河源", "广州", "佛山", "东莞", "潮州", "汕尾", "梅州", "阳江", "云浮", "韶关", "湛江", "汕头", "茂名"], - "浙江": ["舟山", "温州", "台州", "绍兴", "衢州", "宁波", "丽水", "金华", "嘉兴", "湖州", "杭州"], - "宁夏": ["中卫", "银川", "吴忠", "石嘴山", "固原"], - "江苏": ["镇江", "扬州", "盐城", "徐州", "宿迁", "无锡", "苏州", "南通", "南京", "连云港", "淮安", "常州", "泰州"], - "湖南": ["长沙", "邵阳", "怀化", "株洲", "张家界", "永州", "益阳", "湘西", "娄底", "衡阳", "郴州", "岳阳", "常德", "湘潭"], - "吉林": ["长春", "长春", "通化", "松原", "四平", "辽源", "吉林", "延边", "白山", "白城"], - "福建": ["漳州", "厦门", "福州", "三明", "莆田", "宁德", "南平", "龙岩", "泉州"], - "甘肃": ["张掖", "陇南", "兰州", "嘉峪关", "白银", "武威", "天水", "庆阳", "平凉", "临夏", "酒泉", "金昌", "甘南", "定西"], - "陕西": ["榆林", "西安", "延安", "咸阳", "渭南", "铜川", "商洛", "汉中", "宝鸡", "安康"], - "辽宁": ["营口", "铁岭", "沈阳", "盘锦", "辽阳", "锦州", "葫芦岛", "阜新", "抚顺", "丹东", "大连", "朝阳", "本溪", "鞍山"], - "江西": ["鹰潭", "宜春", "上饶", "萍乡", "南昌", "景德镇", "吉安", "抚州", "新余", "九江", "赣州"], - "黑龙江": ["伊春", "七台河", "牡丹江", "鸡西", "黑河", "鹤岗", "哈尔滨", "大兴安岭", "绥化", "双鸭山", "齐齐哈尔", "佳木斯", "大庆"], - "安徽": ["宣城", "铜陵", "六安", "黄山", "淮南", "合肥", "阜阳", "亳州", "安庆", "池州", "宿州", "芜湖", "马鞍山", "淮北", "滁州", "蚌埠"], - "湖北": ["孝感", "武汉", "十堰", "荆门", "黄冈", "襄阳", "咸宁", "随州", "黄石", "恩施", "鄂州", "荆州", "宜昌", "潜江", "天门", "神农架", "仙桃"], - "青海": ["西宁", "海西", "海东", "玉树", "黄南", "海南", "海北", "果洛"], - "新疆": ["乌鲁木齐", "克州", "阿勒泰", "五家渠", "石河子", "伊犁", "吐鲁番", "塔城", "克拉玛依", "喀什", "和田", "哈密", "昌吉", "博尔塔拉", "阿克苏", "巴音郭楞", "阿拉尔", "图木舒克", "铁门关"], - "贵州": ["铜仁", "黔东南", "贵阳", "安顺", "遵义", "黔西南", "黔南", "六盘水", "毕节"], - "四川": ["遂宁", "攀枝花", "眉山", "凉山", "成都", "巴中", "广安", "自贡", "甘孜", "资阳", "宜宾", "雅安", "内江", "南充", "绵阳", "泸州", "凉山", "乐山", "广元", "甘孜", "德阳", "达州", "阿坝"], - "上海": ["上海"], - "广西": ["南宁", "贵港", "玉林", "梧州", "钦州", "柳州", "来宾", "贺州", "河池", "桂林", "防城港", "崇左", "北海", "百色"], - "西藏": ["拉萨", "山南", "日喀则", "那曲", "林芝", "昌都", "阿里"], - "云南": ["昆明", "红河", "大理", "玉溪", "昭通", "西双版纳", "文山", "曲靖", "普洱", "怒江", "临沧", "丽江", "红河", "迪庆", "德宏", "大理", "楚雄", "保山"], - "内蒙古": ["呼和浩特", "乌兰察布", "兴安", "赤峰", "呼伦贝尔", "锡林郭勒", "乌海", "通辽", "巴彦淖尔", "阿拉善", "鄂尔多斯", "包头"], - "海南": ["海口", "三沙", "三亚", "临高", "五指山", "陵水", "文昌", "万宁", "白沙", "乐东", "澄迈", "屯昌", "定安", "东方", "保亭", "琼中", "琼海", "儋州", "昌江"], - "重庆": ["重庆"], - "台湾": ["台北", "高雄", "基隆", "台中", "台南", "新竹", "嘉义", "新北", "桃园"] -} \ No newline at end of file diff --git a/plugins/weather/data_source.py b/plugins/weather/data_source.py deleted file mode 100644 index 3f054066..00000000 --- a/plugins/weather/data_source.py +++ /dev/null @@ -1,21 +0,0 @@ -import requests -from util.init_result import image - - -async def get_weather_of_city(city) -> str: - url = 'http://wthrcdn.etouch.cn/weather_mini?city=' + city - data_json = requests.get(url).json() - if 'desc' in data_json: - if data_json['desc'] == "invilad-citykey": - return "你为啥不查火星的天气呢?小真寻只支持国内天气查询!!" + image("shengqi", "zhenxun") - elif data_json['desc'] == "OK": - w_type = data_json['data']['forecast'][0]['type'] - w_max = data_json['data']['forecast'][0]['high'][3:] - w_min = data_json['data']['forecast'][0]['low'][3:] - fengli = data_json['data']['forecast'][0]['fengli'][9:-3] - ganmao = data_json['data']["ganmao"] - fengxiang = data_json['data']['forecast'][0]['fengxiang'] - repass = f'{city}的天气是 {w_type} 天\n最高温度: {w_max}\n最低温度: {w_min}\n风力: {fengli} {fengxiang}\n{ganmao}' - return repass - else: - return '好像出错了?' diff --git a/plugins/what_anime/__init__.py b/plugins/what_anime/__init__.py deleted file mode 100644 index 5bc61afe..00000000 --- a/plugins/what_anime/__init__.py +++ /dev/null @@ -1,76 +0,0 @@ - -from .data_source import get_anime -from nonebot import on_command -from nonebot.typing import T_State -from nonebot.adapters import Bot, Event -from util.utils import get_message_imgs -from services.log import logger -from util.utils import UserExistLimiter - - -__plugin_name__ = '识番' -__plugin_usage__ = r""" -以图识番 -识番 [图片] -""".strip() - -_ulmt = UserExistLimiter() - -what_anime = on_command('识番', priority=5, block=True) - - -@what_anime.args_parser -async def _(bot: Bot, event: Event, state: T_State): - if str(event.get_message()) in ['取消', '算了']: - await what_anime.finish("已取消操作..", at_sender=True) - img_url = get_message_imgs(event.json()) - if not img_url: - await what_anime.reject(prompt='图呢图呢图呢图呢GKD', at_sender=True) - state['img_url'] = img_url - - -@what_anime.handle() -async def _(bot: Bot, event: Event, state: T_State): - if str(event.get_message()) in ['帮助']: - await what_anime.finish(__plugin_usage__) - if _ulmt.check(event.user_id): - await what_anime.finish('您有识番任务正在进行,请稍等...', at_sender=True) - img_url = get_message_imgs(event.json()) - if img_url: - state['img_url'] = img_url - - -@what_anime.got('img_url', prompt='虚空识番?来图来图GKD') -async def _(bot: Bot, event: Event, state: T_State): - img_url = state['img_url'][0] - _ulmt.set_True(event.user_id) - await what_anime.send('开始识别.....') - anime_data_report = await get_anime(img_url) - if anime_data_report: - await what_anime.send(anime_data_report, at_sender=True) - logger.info(f"USER {event.user_id} GROUP "f"{event.group_id if event.message_type != 'private' else 'private'}" - f" 识番 {img_url} --> {anime_data_report}") - else: - logger.info(f"USER {event.user_id} GROUP " - f"{event.group_id if event.message_type != 'private' else 'private'} 识番 {img_url} 未找到!!") - await what_anime.send(f"没有寻找到该番剧,果咩..", at_sender=True) - _ulmt.set_False(event.user_id) - -# @whatanime.args_parser -# async def _(session: CommandSession): -# image_arg = session.current_arg_images -# -# if session.is_first_run: -# if image_arg: -# session.state['whatanime'] = image_arg[0] -# return -# -# if not image_arg: -# session.pause('没图说个J*,GKD!') -# -# session.state[session.current_key] = image_arg -# -# @on_natural_language(keywords={'whatanime', '识番', '識番'}, permission=get_bot().level) -# async def _(session: NLPSession): -# msg = session.msg -# return IntentCommand(90.0, 'whatanime', current_arg=msg or '') \ No newline at end of file diff --git a/plugins/what_anime/__pycache__/__init__.cpython-38.pyc b/plugins/what_anime/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 539fb2be..00000000 Binary files a/plugins/what_anime/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/what_anime/__pycache__/__init__.cpython-39.pyc b/plugins/what_anime/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 8e75f115..00000000 Binary files a/plugins/what_anime/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/what_anime/__pycache__/data_source.cpython-38.pyc b/plugins/what_anime/__pycache__/data_source.cpython-38.pyc deleted file mode 100644 index a4ed989e..00000000 Binary files a/plugins/what_anime/__pycache__/data_source.cpython-38.pyc and /dev/null differ diff --git a/plugins/what_anime/__pycache__/data_source.cpython-39.pyc b/plugins/what_anime/__pycache__/data_source.cpython-39.pyc deleted file mode 100644 index a5e20255..00000000 Binary files a/plugins/what_anime/__pycache__/data_source.cpython-39.pyc and /dev/null differ diff --git a/plugins/what_anime/data_source.py b/plugins/what_anime/data_source.py deleted file mode 100644 index cdc661cf..00000000 --- a/plugins/what_anime/data_source.py +++ /dev/null @@ -1,35 +0,0 @@ - -import time -from services.log import logger -from util.langconv import * -import aiohttp -from util.user_agent import get_user_agent - - -async def get_anime(anime: str) -> str: - s_time = time.time() - url = 'https://trace.moe/api/search?url={}'.format(anime) - logger.debug("[info]Now starting get the {}".format(url)) - try: - async with aiohttp.ClientSession(headers=get_user_agent()) as session: - async with session.get(url, timeout=45) as response: - if response.status == 200: - anime_json = await response.json() - if anime_json == 'Error reading imagenull': - return "图像源错误,注意必须是静态图片哦" - repass = "" - for anime in anime_json["docs"][:5]: - anime_name = anime["anime"] - episode = anime["episode"] - at = int(anime["at"]) - m, s = divmod(at, 60) - similarity = anime["similarity"] - putline = "[ {} ][{}][{}:{}] 相似度:{:.2%}". \ - format(Converter("zh-hans").convert(anime_name), - episode if episode else '?', m, s, similarity) - repass += putline + '\n' - return f'耗时 {int(time.time() - s_time)} 秒\n' + repass[:-1] - else: - return f'访问失败,请再试一次吧, status: {response.status}' - except Exception: - return '直接超时,那就没办法了,再试一次?' diff --git a/plugins/white2black_img.py b/plugins/white2black_img.py deleted file mode 100644 index 8cf478b6..00000000 --- a/plugins/white2black_img.py +++ /dev/null @@ -1,136 +0,0 @@ -from nonebot.typing import T_State -from nonebot.adapters.cqhttp import Bot, MessageEvent -from nonebot import on_command -from util.utils import get_message_imgs, get_local_proxy, get_message_text, is_Chinese -from util.init_result import image -import aiohttp -import aiofiles -from configs.path_config import IMAGE_PATH -from util.img_utils import CreateImg -from util.user_agent import get_user_agent -from services.log import logger - -# ZH_CN2EN 中文 » 英语 -# ZH_CN2JA 中文 » 日语 -# ZH_CN2KR 中文 » 韩语 -# ZH_CN2FR 中文 » 法语 -# ZH_CN2RU 中文 » 俄语 -# ZH_CN2SP 中文 » 西语 -# EN2ZH_CN 英语 » 中文 -# JA2ZH_CN 日语 » 中文 -# KR2ZH_CN 韩语 » 中文 -# FR2ZH_CN 法语 » 中文 -# RU2ZH_CN 俄语 » 中文 -# SP2ZH_CN 西语 » 中文 - - -__plugin_usage__ = '用法: \n\t黑白图 文字 图片\n示例:黑白草图 没有人不喜欢萝莉 (图片)' - -w2b_img = on_command('黑白草图', aliases={'黑白图'}, priority=5, block=True) - - -@w2b_img.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - if not get_message_text(event.json()) or get_message_text(event.json()) in ['帮助']: - await w2b_img.finish(__plugin_usage__) - # try: - img = get_message_imgs(event.json()) - msg = get_message_text(event.json()) - if not img or not msg: - await w2b_img.finish(f"格式错误:\n" + __plugin_usage__) - img = img[0] - async with aiohttp.ClientSession(headers=get_user_agent()) as session: - async with session.get(img, proxy=get_local_proxy()) as response: - async with aiofiles.open(IMAGE_PATH + f'temp/{event.user_id}_w2b.png', 'wb') as f: - await f.write(await response.read()) - msg = await get_translate(msg) - w2b = CreateImg(0, 0, background=IMAGE_PATH + f'temp/{event.user_id}_w2b.png') - w2b.convert('L') - msg_sp = msg.split('<|>') - w, h = w2b.size - add_h, font_size = init_h_font_size(h) - bg = CreateImg(w, h + add_h, color='black', font_size=font_size) - bg.paste(w2b) - chinese_msg = formalization_msg(msg) - if not bg.check_font_size(chinese_msg): - if len(msg_sp) == 1: - centered_text(bg, chinese_msg, add_h) - else: - centered_text(bg, chinese_msg + '<|>' + msg_sp[1], add_h) - elif not bg.check_font_size(msg_sp[0]): - centered_text(bg, msg, add_h) - else: - ratio = (bg.getsize(msg_sp[0])[0] + 20) / bg.w - add_h = add_h * ratio - bg.resize(ratio) - centered_text(bg, msg, add_h) - await w2b_img.send(image(b64=bg.pic2bs4())) - logger.info( - f"(USER {event.user_id}, GROUP {event.group_id if event.message_type != 'private' else 'private'})" - f" 制作黑白草图 {msg}") - - -def centered_text(img: CreateImg, text: str, add_h: int): - top_h = img.h - add_h + (img.h / 100) - bottom_h = img.h - (img.h / 100) - text_sp = text.split('<|>') - w, h = img.getsize(text_sp[0]) - if len(text_sp) == 1: - w = (img.w - w) / 2 - h = top_h + (bottom_h - top_h - h) / 2 - img.text((w, h), text_sp[0], (255, 255, 255)) - else: - br_h = top_h + (bottom_h - top_h) / 2 - w = (img.w - w) / 2 - h = top_h + (br_h - top_h - h) / 2 - img.text((w, h), text_sp[0], (255, 255, 255)) - w, h = img.getsize(text_sp[1]) - w = (img.w - w) / 2 - h = br_h + (bottom_h - br_h - h) / 2 - img.text((w, h), text_sp[1], (255, 255, 255)) - - -async def get_translate(msg: str) -> str: - url = f'http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule&smartresult=ugc&sessionFrom=null' - data = { - 'type': "ZH_CN2JA", - 'i': msg, - "doctype": "json", - "version": "2.1", - "keyfrom": "fanyi.web", - "ue": "UTF-8", - "action": "FY_BY_CLICKBUTTON", - "typoResult": "true" - } - async with aiohttp.ClientSession(headers=get_user_agent()) as session: - try: - async with session.post(url, data=data, proxy=get_local_proxy()) as res: - data = await res.json() - if data['errorCode'] == 0: - translate = data['translateResult'][0][0]['tgt'] - msg += '<|>' + translate - except Exception as e: - logger.warning(f'黑白草图翻译出错 e:{e}') - return msg - - -def formalization_msg(msg: str) -> str: - rst = '' - for i in range(len(msg)): - if is_Chinese(msg[i]): - rst += msg[i] + ' ' - else: - rst += msg[i] - if i + 1 < len(msg) and is_Chinese(msg[i + 1]) and msg[i].isalpha(): - rst += ' ' - return rst - - -def init_h_font_size(h): - # 高度 字体 - if h < 400: - return init_h_font_size(400) - elif 400 < h < 800: - return init_h_font_size(800) - return h * 0.2, h * 0.05 - diff --git a/plugins/yiqing/__init__.py b/plugins/yiqing/__init__.py deleted file mode 100644 index 5ee1a92d..00000000 --- a/plugins/yiqing/__init__.py +++ /dev/null @@ -1,53 +0,0 @@ -from nonebot import on_command -from .data_source import get_yiqing_data, clear_data -from services.log import logger -from nonebot.adapters.cqhttp import Bot, Event -from nonebot.typing import T_State -from .config import city_list -from util.utils import scheduler - -__plugin_name__ = '疫情查询' -__plugin_usage__ = '查询疫情帮助:\n\t对我说 查询疫情 省份/城市,我会回复疫情的实时数据\n\t示例: 查询疫情 温州' - - -yiqing = on_command("疫情", aliases={"查询疫情", "疫情查询"}, priority=5, block=True) - - -@yiqing.handle() -async def _(bot: Bot, event: Event, state: T_State): - if str(event.get_message()).strip() in ['帮助']: - await yiqing.finish(__plugin_usage__) - msg = str(event.get_message()).strip() - if msg: - if msg in city_list.keys(): - province = msg - city = '' - else: - for key in city_list.keys(): - if msg in city_list.get(key): - province = key - city = msg - break - else: - await yiqing.finish(__plugin_usage__) - try: - result = await get_yiqing_data(province, city) - if result: - await yiqing.send(result) - logger.info( - f"(USER {event.user_id}, GROUP {event.group_id if event.message_type != 'private' else 'private'}) 查询疫情:" + result) - else: - await yiqing.send("查询失败!!!!", at_sender=True) - logger.info( - f"(USER {event.user_id}, GROUP {event.group_id if event.message_type != 'private' else 'private'}) 查询疫情失败") - except UnboundLocalError: - await yiqing.finish('参数正确吗?只要一个参数啊', at_sender=True) - - -@scheduler.scheduled_job( - 'cron', - hour=0, - minute=1, -) -async def _(): - clear_data() diff --git a/plugins/yiqing/__pycache__/__init__.cpython-38.pyc b/plugins/yiqing/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index ad52899d..00000000 Binary files a/plugins/yiqing/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/plugins/yiqing/__pycache__/__init__.cpython-39.pyc b/plugins/yiqing/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 48f76158..00000000 Binary files a/plugins/yiqing/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/plugins/yiqing/__pycache__/config.cpython-38.pyc b/plugins/yiqing/__pycache__/config.cpython-38.pyc deleted file mode 100644 index 35048ce2..00000000 Binary files a/plugins/yiqing/__pycache__/config.cpython-38.pyc and /dev/null differ diff --git a/plugins/yiqing/__pycache__/config.cpython-39.pyc b/plugins/yiqing/__pycache__/config.cpython-39.pyc deleted file mode 100644 index 98558138..00000000 Binary files a/plugins/yiqing/__pycache__/config.cpython-39.pyc and /dev/null differ diff --git a/plugins/yiqing/__pycache__/data_source.cpython-38.pyc b/plugins/yiqing/__pycache__/data_source.cpython-38.pyc deleted file mode 100644 index 3192db06..00000000 Binary files a/plugins/yiqing/__pycache__/data_source.cpython-38.pyc and /dev/null differ diff --git a/plugins/yiqing/__pycache__/data_source.cpython-39.pyc b/plugins/yiqing/__pycache__/data_source.cpython-39.pyc deleted file mode 100644 index 406f2258..00000000 Binary files a/plugins/yiqing/__pycache__/data_source.cpython-39.pyc and /dev/null differ diff --git a/plugins/yiqing/config.py b/plugins/yiqing/config.py deleted file mode 100644 index 95b8313e..00000000 --- a/plugins/yiqing/config.py +++ /dev/null @@ -1,34 +0,0 @@ -city_list = { - "北京": ["北京"], - "天津": ["天津"], - "山西": ["太原", "阳泉", "晋城", "长治", "临汾", "运城", "忻州", "吕梁", "晋中", "大同", "朔州"], - "河北": ["沧州", "石家庄", "唐山", "保定", "廊坊", "衡水", "邯郸", "邢台", "张家口", "辛集", "秦皇岛", "定州", "承德", "涿州"], - "山东": ["济南", "淄博", "聊城", "德州", "滨州", "济宁", "菏泽", "枣庄", "烟台", "威海", "泰安", "青岛", "临沂", "莱芜", "东营", "潍坊", "日照"], - "河南": ["郑州", "新乡", "鹤壁", "安阳", "焦作", "濮阳", "开封", "驻马店", "商丘", "三门峡", "南阳", "洛阳", "周口", "许昌", "信阳", "漯河", "平顶山", "济源"], - "广东": ["珠海", "中山", "肇庆", "深圳", "清远", "揭阳", "江门", "惠州", "河源", "广州", "佛山", "东莞", "潮州", "汕尾", "梅州", "阳江", "云浮", "韶关", "湛江", "汕头", "茂名"], - "浙江": ["舟山", "温州", "台州", "绍兴", "衢州", "宁波", "丽水", "金华", "嘉兴", "湖州", "杭州"], - "宁夏": ["中卫", "银川", "吴忠", "石嘴山", "固原"], - "江苏": ["镇江", "扬州", "盐城", "徐州", "宿迁", "无锡", "苏州", "南通", "南京", "连云港", "淮安", "常州", "泰州"], - "湖南": ["长沙", "邵阳", "怀化", "株洲", "张家界", "永州", "益阳", "湘西", "娄底", "衡阳", "郴州", "岳阳", "常德", "湘潭"], - "吉林": ["长春", "长春", "通化", "松原", "四平", "辽源", "吉林", "延边", "白山", "白城"], - "福建": ["漳州", "厦门", "福州", "三明", "莆田", "宁德", "南平", "龙岩", "泉州"], - "甘肃": ["张掖", "陇南", "兰州", "嘉峪关", "白银", "武威", "天水", "庆阳", "平凉", "临夏", "酒泉", "金昌", "甘南", "定西"], - "陕西": ["榆林", "西安", "延安", "咸阳", "渭南", "铜川", "商洛", "汉中", "宝鸡", "安康"], - "辽宁": ["营口", "铁岭", "沈阳", "盘锦", "辽阳", "锦州", "葫芦岛", "阜新", "抚顺", "丹东", "大连", "朝阳", "本溪", "鞍山"], - "江西": ["鹰潭", "宜春", "上饶", "萍乡", "南昌", "景德镇", "吉安", "抚州", "新余", "九江", "赣州"], - "黑龙江": ["伊春", "七台河", "牡丹江", "鸡西", "黑河", "鹤岗", "哈尔滨", "大兴安岭", "绥化", "双鸭山", "齐齐哈尔", "佳木斯", "大庆"], - "安徽": ["宣城", "铜陵", "六安", "黄山", "淮南", "合肥", "阜阳", "亳州", "安庆", "池州", "宿州", "芜湖", "马鞍山", "淮北", "滁州", "蚌埠"], - "湖北": ["孝感", "武汉", "十堰", "荆门", "黄冈", "襄阳", "咸宁", "随州", "黄石", "恩施", "鄂州", "荆州", "宜昌", "潜江", "天门", "神农架", "仙桃"], - "青海": ["西宁", "海西", "海东", "玉树", "黄南", "海南", "海北", "果洛"], - "新疆": ["乌鲁木齐", "克州", "阿勒泰", "五家渠", "石河子", "伊犁", "吐鲁番", "塔城", "克拉玛依", "喀什", "和田", "哈密", "昌吉", "博尔塔拉", "阿克苏", "巴音郭楞", "阿拉尔", "图木舒克", "铁门关"], - "贵州": ["铜仁", "黔东南", "贵阳", "安顺", "遵义", "黔西南", "黔南", "六盘水", "毕节"], - "四川": ["遂宁", "攀枝花", "眉山", "凉山", "成都", "巴中", "广安", "自贡", "甘孜", "资阳", "宜宾", "雅安", "内江", "南充", "绵阳", "泸州", "凉山", "乐山", "广元", "甘孜", "德阳", "达州", "阿坝"], - "上海": ["上海"], - "广西": ["南宁", "贵港", "玉林", "梧州", "钦州", "柳州", "来宾", "贺州", "河池", "桂林", "防城港", "崇左", "北海", "百色"], - "西藏": ["拉萨", "山南", "日喀则", "那曲", "林芝", "昌都", "阿里"], - "云南": ["昆明", "红河", "大理", "玉溪", "昭通", "西双版纳", "文山", "曲靖", "普洱", "怒江", "临沧", "丽江", "红河", "迪庆", "德宏", "大理", "楚雄", "保山"], - "内蒙古": ["呼和浩特", "乌兰察布", "兴安", "赤峰", "呼伦贝尔", "锡林郭勒", "乌海", "通辽", "巴彦淖尔", "阿拉善", "鄂尔多斯", "包头"], - "海南": ["海口", "三沙", "三亚", "临高", "五指山", "陵水", "文昌", "万宁", "白沙", "乐东", "澄迈", "屯昌", "定安", "东方", "保亭", "琼中", "琼海", "儋州", "昌江"], - "重庆": ["重庆"], - "台湾": ["台北", "高雄", "基隆", "台中", "台南", "新竹", "嘉义", "新北", "桃园"] -} \ No newline at end of file diff --git a/plugins/yiqing/data_source.py b/plugins/yiqing/data_source.py deleted file mode 100644 index f9b9c691..00000000 --- a/plugins/yiqing/data_source.py +++ /dev/null @@ -1,50 +0,0 @@ -from datetime import datetime -import aiohttp -from util.user_agent import get_user_agent -import json -import os -from configs.path_config import TXT_PATH -from util.utils import get_local_proxy - - -url = "https://api.yimian.xyz/coro/" - - -async def get_yiqing_data(province, city_=''): - if not os.path.exists(TXT_PATH + "yiqing/"): - os.mkdir(TXT_PATH + "yiqing/") - if not os.path.exists(TXT_PATH + "yiqing/" + str(datetime.now().date()) + ".json"): - async with aiohttp.ClientSession(headers=get_user_agent()) as session: - async with session.get(url, proxy=get_local_proxy(), timeout=7) as response: - datalist = await response.json() - with open(TXT_PATH + "yiqing/" + str(datetime.now().date()) + ".json", 'w') as f: - json.dump(datalist, f) - datalist = json.load(open(TXT_PATH + "yiqing/" + str(datetime.now().date()) + ".json", 'r')) - result = '' - for data in datalist: - if data['provinceShortName'] == province: - if city_ == '': - result = province + "疫情数据:\n现存确诊: " + \ - str(data['currentConfirmedCount']) + "\n累计确诊: " + \ - str(data['confirmedCount']) + "\n治愈: " + \ - str(data['curedCount']) + "\n死亡: " + \ - str(data['deadCount']) - break - else: - for city in data['cities']: - if city['cityName'] == city_: - result = city_ + "疫情数据:\n现存确诊: " + \ - str(city['currentConfirmedCount']) + "\n累计确诊: " + str(city['confirmedCount']) +\ - "\n治愈: " + str(city['curedCount']) + "\n死亡: " + str(city['deadCount']) - break - return result - - -def clear_data(): - for file in os.listdir(TXT_PATH + "yiqing/"): - os.remove(TXT_PATH + "yiqing/" + file) - - -if __name__ == '__main__': - print(get_yiqing_data("浙江", city_='')) -