mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
update code
This commit is contained in:
parent
754a0c111c
commit
8d0b0e5505
@ -10,6 +10,10 @@ except ModuleNotFoundError:
|
||||
|
||||
|
||||
# 是否使用配置文件
|
||||
# 使用配置文件在每次启动时 plugins2info_dict, plugins2cd_dict, plugins2exists_dict 将从本地读取
|
||||
# 除了 plugins2info_dict 新增内容键值会写入 plugins2info_file
|
||||
# 其他修改或新增在 configs.config.py中对 plugins2info_dict, plugins2cd_dict, plugins2exists_dict 的配置无效
|
||||
# 目录:data/configs/
|
||||
USE_CONFIG_FILE: bool = False
|
||||
|
||||
# 回复消息名称
|
||||
@ -55,12 +59,12 @@ MAXINFO_PRIVATE_ANIME: int = 20 # 私聊搜索动漫返回的最大数量
|
||||
MAXINFO_GROUP_ANIME: int = 5 # 群搜索动漫返回的最大数量
|
||||
MAX_FIND_IMG_COUNT: int = 3 # 识图最大返回数
|
||||
# 参1:延迟撤回色图时间(秒),0 为关闭 | 参2:监控聊天类型,0(私聊) 1(群聊) 2(群聊+私聊)
|
||||
WITHDRAW_SETU_TIME: Tuple[int, int] = (0, 1)
|
||||
WITHDRAW_SETU_TIME: Tuple[int, int] = (90, 1)
|
||||
# 参1:延迟撤回PIX图片时间(秒),0 为关闭 | 参2:监控聊天类型,0(私聊) 1(群聊) 2(群聊+私聊)
|
||||
WITHDRAW_PIX_TIME: Tuple[int, int] = (0, 1)
|
||||
|
||||
# PIX图库 与 额外图库OmegaPixivIllusts 混合搜索的比例 参1:PIX图库 参2:OmegaPixivIllusts扩展图库(没有此图库请设置为0)
|
||||
PIX_OMEGA_PIXIV_RATIO: Tuple[int, int] = (10, 0)
|
||||
PIX_OMEGA_PIXIV_RATIO: Tuple[int, int] = (2, 8)
|
||||
|
||||
# 各种卡池的开关
|
||||
PRTS_FLAG = True # 明日方舟
|
||||
@ -92,7 +96,7 @@ CHECK_NOTICE_INFO_CD = 300 # 群检测,个人权限检测等各种检测提
|
||||
|
||||
# 注:即在 MALICIOUS_CHECK_TIME 时间内触发相同命令 MALICIOUS_BAN_COUNT 将被ban MALICIOUS_BAN_TIME 分钟
|
||||
MALICIOUS_BAN_TIME: int = 30 # 恶意命令触发检测触发后ban的时长(分钟)
|
||||
MALICIOUS_BAN_COUNT: int = 8 # 恶意命令触发检测最大触发次数
|
||||
MALICIOUS_BAN_COUNT: int = 3 # 恶意命令触发检测最大触发次数
|
||||
MALICIOUS_CHECK_TIME: int = 5 # 恶意命令触发检测规定时间内(秒)
|
||||
|
||||
# LEVEL
|
||||
@ -102,6 +106,7 @@ UPLOAD_LEVEL: int = 6 # 上传图片权限
|
||||
BAN_LEVEL: int = 5 # BAN权限
|
||||
OC_LEVEL: int = 2 # 开关群功能权限
|
||||
MUTE_LEVEL: int = 5 # 更改禁言设置权限
|
||||
MEMBER_ACTIVITY_LEVEL = 5 # 群员活跃检测设置权限
|
||||
GROUP_BILIBILI_SUB_LEVEL = 5 # 群内bilibili订阅需要的权限
|
||||
|
||||
DEFAULT_GROUP_LEVEL = 5 # 默认群等级
|
||||
@ -140,6 +145,7 @@ admin_plugins_auth = {
|
||||
"upload_img": UPLOAD_LEVEL,
|
||||
"admin_help": 1,
|
||||
"mute": MUTE_LEVEL,
|
||||
"member_activity_handle": MEMBER_ACTIVITY_LEVEL,
|
||||
}
|
||||
|
||||
# 需要cd的功能(方便管理)[秒]
|
||||
@ -307,10 +313,40 @@ HIBIAPI = HIBIAPI[:-1] if HIBIAPI[-1] == "/" else HIBIAPI
|
||||
RSSHUBAPP = RSSHUBAPP[:-1] if RSSHUBAPP[-1] == "/" else RSSHUBAPP
|
||||
|
||||
|
||||
# plugins2info_file = Path(DATA_PATH) / 'configs' / 'plugins2info.json'
|
||||
# plugins2info_file.parent.mkdir(exist_ok=True, parents=True)
|
||||
#
|
||||
# with open(f'{DATA_PATH}/configs/')
|
||||
if USE_CONFIG_FILE:
|
||||
# 读取配置文件
|
||||
plugins2info_file = Path(DATA_PATH) / 'configs' / 'plugins2info.json'
|
||||
plugins2info_file.parent.mkdir(exist_ok=True, parents=True)
|
||||
|
||||
if plugins2info_file.exists():
|
||||
with open(plugins2info_file, 'r') as f:
|
||||
_data = json.load(f)
|
||||
for p in plugins2info_dict:
|
||||
if not _data.get(p):
|
||||
_data[p] = plugins2info_dict[p]
|
||||
with open(plugins2info_file, 'w') as wf:
|
||||
json.dump(_data, wf, ensure_ascii=False, indent=4)
|
||||
plugins2info_dict = _data
|
||||
else:
|
||||
with open(plugins2info_file, 'w', encoding='utf8') as wf:
|
||||
json.dump(plugins2info_dict, wf, ensure_ascii=False, indent=4)
|
||||
|
||||
plugins2cd_file = Path(DATA_PATH) / 'configs' / 'plugins2cd.json'
|
||||
if plugins2cd_file.exists():
|
||||
with open(plugins2cd_file, 'r', encoding='utf8') as f:
|
||||
plugins2cd_dict = json.load(f)
|
||||
else:
|
||||
with open(plugins2cd_file, 'w', encoding='utf8') as wf:
|
||||
json.dump(plugins2cd_dict, wf, ensure_ascii=False, indent=4)
|
||||
|
||||
plugins2exists_file = Path(DATA_PATH) / 'configs' / 'plugins2exists.json'
|
||||
if plugins2exists_file.exists():
|
||||
with open(plugins2exists_file, 'r', encoding='utf8') as f:
|
||||
plugins2exists_dict = json.load(f)
|
||||
else:
|
||||
with open(plugins2exists_file, 'w', encoding='utf8') as wf:
|
||||
json.dump(plugins2exists_dict, wf, ensure_ascii=False, indent=4)
|
||||
|
||||
|
||||
# 配置文件应用
|
||||
# if USE_CONFIG_FILE:
|
||||
|
||||
@ -24,6 +24,7 @@ class GroupInfoUser(db.Model):
|
||||
belonging_group: int,
|
||||
user_name: str,
|
||||
user_join_time: datetime,
|
||||
uid: Optional[int] = None,
|
||||
) -> bool:
|
||||
"""
|
||||
说明:
|
||||
@ -33,6 +34,7 @@ class GroupInfoUser(db.Model):
|
||||
:param belonging_group: 群号
|
||||
:param user_name: 用户名称
|
||||
:param user_join_time: 入群时间
|
||||
:param uid: 用户唯一 id(自动生成)
|
||||
"""
|
||||
query = cls.query.where(
|
||||
(cls.user_qq == user_qq) & (cls.belonging_group == belonging_group)
|
||||
@ -44,6 +46,7 @@ class GroupInfoUser(db.Model):
|
||||
user_name=user_name,
|
||||
belonging_group=belonging_group,
|
||||
user_join_time=user_join_time,
|
||||
uid=uid
|
||||
)
|
||||
return True
|
||||
except Exception:
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
from nonebot import on_command, export
|
||||
from nonebot import on_command, on_notice
|
||||
from nonebot.typing import T_State
|
||||
from nonebot.adapters.cqhttp import Bot, GroupMessageEvent, GROUP
|
||||
from nonebot.adapters.cqhttp import Bot, GroupMessageEvent, GROUP, GroupIncreaseNoticeEvent
|
||||
from .data_source import update_member_info
|
||||
|
||||
__plugin_name__ = "更新群组成员列表"
|
||||
@ -12,8 +12,6 @@ __plugin_usage__ = """
|
||||
更新群组成员列表
|
||||
"""
|
||||
|
||||
export = export()
|
||||
export.update_member_info = update_member_info
|
||||
|
||||
refresh_member_group = on_command(
|
||||
"更新群组成员列表", aliases={"更新群组成员信息"}, permission=GROUP, priority=5, block=True
|
||||
@ -26,3 +24,12 @@ async def _(bot: Bot, event: GroupMessageEvent, state: T_State):
|
||||
await refresh_member_group.finish("更新群员信息成功!", at_sender=True)
|
||||
else:
|
||||
await refresh_member_group.finish("更新群员信息失败!", at_sender=True)
|
||||
|
||||
|
||||
group_increase_handle = on_notice(priority=1, block=False)
|
||||
|
||||
|
||||
@group_increase_handle.handle()
|
||||
async def _(bot: Bot, event: GroupIncreaseNoticeEvent, state: dict):
|
||||
if event.user_id == int(bot.self_id):
|
||||
await update_member_info(event.group_id)
|
||||
|
||||
@ -19,6 +19,10 @@ __plugin_usage__ = f'''[权限等级]管理帮助:
|
||||
\t\t/设置检测次数/设置禁言时长
|
||||
[5]7.群订阅相关 -> 指令:添加订阅 [主播/up/番剧] [id/番名/链接]
|
||||
\t\t/删除订阅 [id]/ 查看订阅
|
||||
[5]8.群员活跃度相关 --> 指令:群员活跃检测设置
|
||||
设置群员活跃检测时长(天)
|
||||
添加群员活跃检测白名单[at]...
|
||||
查看群员活跃检测白名单
|
||||
[6]8.上传图片/连续上传图片(6)
|
||||
[7]9.移动图片(7)
|
||||
[7]10.删除图片(7)
|
||||
|
||||
@ -279,9 +279,13 @@ async def _get_season_status(id_) -> Optional[str]:
|
||||
_idx = (await BilibiliSub.get_sub(id_)).season_current_episode
|
||||
new_ep = season_info["media"]["new_ep"]["index"]
|
||||
if new_ep != _idx:
|
||||
await BilibiliSub.update_sub_info(id_, season_current_episode=new_ep, season_update_time=datetime.now())
|
||||
await BilibiliSub.update_sub_info(
|
||||
id_, season_current_episode=new_ep, season_update_time=datetime.now()
|
||||
)
|
||||
return (
|
||||
f'{image(season_info["media"]["cover"])}\n' f"[{title}]更新啦\n" f"最新集数:{new_ep}"
|
||||
f'{image(season_info["media"]["cover"])}\n'
|
||||
f"[{title}]更新啦\n"
|
||||
f"最新集数:{new_ep}"
|
||||
)
|
||||
return None
|
||||
|
||||
@ -363,6 +367,8 @@ class SubManager:
|
||||
:return:
|
||||
"""
|
||||
sub = None
|
||||
if not self.live_data and not self.up_data and not self.season_data:
|
||||
return sub
|
||||
self.current_index += 1
|
||||
if self.current_index == 0:
|
||||
if self.live_data:
|
||||
@ -382,5 +388,3 @@ class SubManager:
|
||||
return sub
|
||||
await self.reload_sub_data()
|
||||
return await self.random_sub_data()
|
||||
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ coser = on_command(
|
||||
)
|
||||
|
||||
|
||||
url = "http://81.70.100.130/api/cosplay.php"
|
||||
url = "http://api520.ltd/api/cosplay.php"
|
||||
|
||||
|
||||
@coser.handle()
|
||||
@ -29,9 +29,9 @@ async def _(bot: Bot, event: MessageEvent, state: T_State):
|
||||
for _ in range(3):
|
||||
try:
|
||||
async with session.get(url, timeout=2) as response:
|
||||
r = re.search(r'±img=(.*)±', await response.text())
|
||||
if r:
|
||||
async with session.get(r.group(1), timeout=5, verify_ssl=False) as res:
|
||||
_url = await response.text()
|
||||
async with session.get(_url, timeout=5, verify_ssl=False) as res:
|
||||
if res.status == 200:
|
||||
async with aiofiles.open(f'{IMAGE_PATH}/temp/{event.user_id}_coser.jpg', 'wb') as f:
|
||||
await f.write(await res.read())
|
||||
logger.info(
|
||||
@ -43,6 +43,8 @@ async def _(bot: Bot, event: MessageEvent, state: T_State):
|
||||
break
|
||||
except TimeoutError:
|
||||
pass
|
||||
else:
|
||||
await coser.send('你cos给我看!')
|
||||
except Exception as e:
|
||||
await coser.send('发生了预料之外的错误..请稍后再试或联系管理员修复...')
|
||||
logger.error(f'coser 发送了未知错误 {type(e)}:{e}')
|
||||
|
||||
@ -116,15 +116,10 @@ async def _(matcher: Matcher, bot: Bot, event: GroupMessageEvent, state: T_State
|
||||
return
|
||||
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)
|
||||
if isinstance(event, GroupMessageEvent):
|
||||
try:
|
||||
await bot.send_group_msg(
|
||||
group_id=event.group_id,
|
||||
@ -133,9 +128,6 @@ async def _(matcher: Matcher, bot: Bot, event: GroupMessageEvent, state: T_State
|
||||
except ActionFailed:
|
||||
pass
|
||||
else:
|
||||
if not static_flmt.check(event.user_id):
|
||||
return
|
||||
static_flmt.start_cd(event.user_id)
|
||||
try:
|
||||
await bot.send_private_msg(
|
||||
user_id=event.user_id,
|
||||
|
||||
@ -31,7 +31,10 @@ driver: Driver = nonebot.get_driver()
|
||||
@driver.on_startup
|
||||
async def init_image():
|
||||
SIGN_RESOURCE_PATH.mkdir(parents=True, exist_ok=True)
|
||||
await GroupInfoUser.add_member_info(114514, 114514, "", datetime.min)
|
||||
await GroupInfoUser.add_member_info(114514, 114514, "", datetime.min, 0)
|
||||
_u = await GroupInfoUser.get_member_info(114514, 114514)
|
||||
if _u.uid is None:
|
||||
await _u.update(uid=0).apply()
|
||||
generate_progress_bar_pic()
|
||||
clear_sign_data_pic()
|
||||
|
||||
|
||||
@ -15,6 +15,7 @@ yiqing = on_command("疫情", aliases={"查询疫情", "疫情查询"}, priority
|
||||
@yiqing.handle()
|
||||
async def _(bot: Bot, event: MessageEvent, state: T_State):
|
||||
msg = get_message_text(event.json())
|
||||
if msg:
|
||||
result = await get_yiqing_data(msg)
|
||||
if result:
|
||||
await yiqing.send(result)
|
||||
|
||||
@ -7,8 +7,7 @@
|
||||
"models/pixiv.py",
|
||||
"models/russian_user.py",
|
||||
"models/setu.py",
|
||||
"plugins/admin_bot_manage/data_source.py",
|
||||
"plugins/admin_bot_manage/switch_rule.py",
|
||||
"plugins/admin_bot_manage",
|
||||
"plugins/admin_help/__init__.py",
|
||||
"plugins/ai/__init__.py",
|
||||
"plugins/ai/data_source.py",
|
||||
@ -65,9 +64,7 @@
|
||||
"utils/static_data/__init__.py",
|
||||
"utils/static_data/data_class.py",
|
||||
"utils/static_data/group_manager.py",
|
||||
"utils/utils.py"
|
||||
],
|
||||
"add_file": [
|
||||
"utils/utils.py",
|
||||
"models/omega_pixiv_illusts.py",
|
||||
"models/sign_group_user.py",
|
||||
"plugins/bilibili_sub",
|
||||
@ -79,5 +76,6 @@
|
||||
"plugins/withdraw.py",
|
||||
"resources/img/sign"
|
||||
],
|
||||
"add_file": [],
|
||||
"delete_file": ["plugins/nonebot_plugin_withdraw", "models/sigin_group_user.py"]
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user