diff options
Diffstat (limited to 'ATRI/plugins')
27 files changed, 333 insertions, 2523 deletions
diff --git a/ATRI/plugins/plugin_anime/sepi_list.json b/ATRI/plugins/admin/__init__.py index e69de29..e69de29 100644 --- a/ATRI/plugins/plugin_anime/sepi_list.json +++ b/ATRI/plugins/admin/__init__.py diff --git a/ATRI/plugins/admin/data_source.py b/ATRI/plugins/admin/data_source.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/ATRI/plugins/admin/data_source.py diff --git a/ATRI/plugins/bot.py b/ATRI/plugins/bot.py new file mode 100644 index 0000000..42e05d0 --- /dev/null +++ b/ATRI/plugins/bot.py @@ -0,0 +1,159 @@ +from random import choice +from typing import Optional + +from nonebot.typing import Bot, Event +from nonebot.plugin import on_command, on_regex + +from ATRI.rule import isInBanList, isInDormant, toBot +from ATRI.utils import countList, delListAim, nowTime +from ATRI.config import BOT_CONFIG, NONEBOT_CONFIG + +# ===========================[Begin Command Processing]=========================== + + +class Action: + callRobot = on_regex('|'.join(BOT_CONFIG['callRobot']['command']), + rule=isInBanList() & isInDormant(), + priority=4) + + callMe = on_command(list(NONEBOT_CONFIG['nickname'])[0], + aliases=NONEBOT_CONFIG['nickname'], + rule=isInBanList() & isInDormant()) + + teeTee = on_command(BOT_CONFIG['teetee']['command'][0], + aliases=set(BOT_CONFIG['teetee']['command']), + rule=isInBanList() & isInDormant() & toBot()) + + kani = on_regex('|'.join(BOT_CONFIG['kani']['command']), + rule=isInBanList() & isInDormant()) + + waste = on_regex('|'.join(BOT_CONFIG['waste']['command']), + rule=isInBanList() & isInDormant() & toBot(), + priority=5) + + morning = on_command(BOT_CONFIG['morning']['command'][0], + aliases=set(BOT_CONFIG['morning']['command']), + rule=isInBanList() & isInDormant() & toBot()) + + noon = on_command(BOT_CONFIG['noon']['command'][0], + aliases=set(BOT_CONFIG['noon']['command']), + rule=isInBanList() & isInDormant() & toBot()) + + night = on_command(BOT_CONFIG['night']['command'][0], + aliases=set(BOT_CONFIG['night']['command']), + rule=isInBanList() & isInDormant() & toBot()) + + cantdo = on_regex('|'.join(BOT_CONFIG['cantdo']['command']), + rule=isInBanList() & isInDormant()) + + @callRobot.handle() + async def _(bot: Bot, event: Event, state: dict) -> None: + await bot.send(event, ATRI()._callRobot(event.user_id)) + + @callMe.handle() + async def _(bot: Bot, event: Event, state: dict) -> None: + await bot.send(event, ATRI()._callMe()) + + @teeTee.handle() + async def _(bot: Bot, event: Event, state: dict) -> None: + await bot.send(event, ATRI()._teeTee(event.user_id)) + + @kani.handle() + async def _(bot: Bot, event: Event, state: dict) -> None: + await bot.send(event, ATRI()._kani()) + + @waste.handle() + async def _(bot: Bot, event: Event, state: dict) -> None: + await bot.send(event, ATRI()._waste()) + + @morning.handle() + async def _(bot: Bot, event: Event, state: dict) -> None: + await bot.send(event, ATRI()._morning()) + + @noon.handle() + async def _(bot: Bot, event: Event, state: dict) -> None: + await bot.send(event, ATRI()._noon()) + + @night.handle() + async def _(bot: Bot, event: Event, state: dict) -> None: + await bot.send(event, ATRI()._night()) + + @cantdo.handle() + async def _(bot: Bot, event: Event, state: dict) -> None: + await bot.send(event, ATRI()._cantdo()) + + +# ===========================[End Command Processing]=========================== + +callrobot_list = [] + + +class ATRI(): + def _callRobot(self, user: Optional[int]) -> str: + global callrobot_list + result = '' + for i in range(0, 5): + if countList(callrobot_list, user) == i: + result = choice(BOT_CONFIG['callRobot']['repo'][i]) + callrobot_list.append(user) + if countList(callrobot_list, user) == 5: + callrobot_list = delListAim(callrobot_list, user) + break + else: + continue + return result + + def _callMe(self) -> str: + return choice(BOT_CONFIG['atri']['repo']) + + def _teeTee(self, user: Optional[int]) -> str: + if user in NONEBOT_CONFIG['superusers']: + return choice(BOT_CONFIG['teetee']['repo']['superusers']) + else: + return choice(BOT_CONFIG['teetee']['repo']['user']) + + def _kani(self) -> str: + return choice(BOT_CONFIG['kani']['repo']) + + def _waste(self) -> str: + return choice(BOT_CONFIG['waste']['repo']) + + def _morning(self) -> str: + period = BOT_CONFIG['morning']['repo'] + if period[0]['period'][0] <= nowTime() < period[0]['period'][1]: + return choice(period[0]['repo']) + elif period[1]['period'][0] <= nowTime() < period[1]['period'][1]: + return choice(period[1]['repo']) + elif period[2]['period'][0] <= nowTime() < period[2]['period'][1]: + return choice(period[2]['repo']) + elif period[3]['period'][0] <= nowTime() < period[3]['period'][1]: + return choice(period[3]['repo']) + elif period[4]['period'][0] <= nowTime() < period[4]['period'][1]: + return choice(period[4]['repo']) + else: + return choice(period['error']) + + def _noon(self) -> str: + if BOT_CONFIG['noon']['period'][0] <= nowTime( + ) < BOT_CONFIG['noon']['period'][1]: + return choice(BOT_CONFIG['noon']['repo']) + else: + return choice(BOT_CONFIG['noon']['error']) + + def _night(self) -> str: + period = BOT_CONFIG['night']['repo'] + if period[0]['period'][0] <= nowTime() < period[0]['period'][1]: + return choice(period[0]['repo']) + elif period[1]['period'][0] <= nowTime() < period[1]['period'][1]: + return choice(period[1]['repo']) + elif period[2]['period'][0] <= nowTime() < period[2]['period'][1]: + return choice(period[2]['repo']) + elif period[3]['period'][0] <= nowTime() < period[3]['period'][1]: + return choice(period[3]['repo']) + elif period[4]['period'][0] <= nowTime() < period[4]['period'][1]: + return choice(period[4]['repo']) + else: + return choice(period['error']) + + def _cantdo(self) -> str: + return choice(BOT_CONFIG['cantdo']['repo'])
\ No newline at end of file diff --git a/ATRI/plugins/curse.py b/ATRI/plugins/curse.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/ATRI/plugins/curse.py diff --git a/ATRI/plugins/funny/__init__.py b/ATRI/plugins/funny/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/ATRI/plugins/funny/__init__.py diff --git a/ATRI/plugins/genshin/__init__.py b/ATRI/plugins/genshin/__init__.py new file mode 100644 index 0000000..4705e0e --- /dev/null +++ b/ATRI/plugins/genshin/__init__.py @@ -0,0 +1,53 @@ +import re +from nonebot.plugin import on_command +from nonebot.typing import Bot, Event + +from ATRI.config import GENSHIN_CONFIG +from ATRI.exceptions import InvalidRequestError +from ATRI.rule import isInBanList, isInDormant, isInService + +from .data_source import Genshin + +__plugin_name__ = 'genshin' + +genshin = on_command(GENSHIN_CONFIG['genshin']['command'][0], + aliases=set(GENSHIN_CONFIG['genshin']['command']), + rule=isInBanList() & isInDormant() + & isInService(__plugin_name__)) + + +async def _(bot: Bot, event: Event, state: dict) -> None: + args = str(event.message) + + if args: + state['args'] = args + [email protected]('args', prompt='请告诉咱id以及是官服还是b服嗷~w\n用空格隔开!!') +async def _(bot: Bot, event: Event, state: dict) -> None: + args = state['args'].split(' ') + uid_info = '' + server_id = '' + + if len(args[0]) != 9: + await genshin.finish('抱歉暂时只支持国服呢...') + else: + pass + + if re.findall('[Bb官]服', args[1]): + if re.findall('[Bb]服', args[1]): + server_id = 'cn_qd01' + else: + server_id = 'cn_gf01' + + await bot.send(event, '别急,在找!') + try: + uid_info = Genshin().jsonAnalysis(Genshin().getInfo(server_id=server_id, uid=args[0])) + except InvalidRequestError: + await genshin.finish('找不到呢...咱搜索区域或许出错了...') + + msg0 = (f'{args[0]} Genshin INFO:\n' + f'{uid_info}') + await genshin.finish(msg0) + else: + await genshin.finish('抱歉暂时只支持官服和b服...呐.') diff --git a/ATRI/plugins/genshin/data_source.py b/ATRI/plugins/genshin/data_source.py new file mode 100644 index 0000000..2bb4572 --- /dev/null +++ b/ATRI/plugins/genshin/data_source.py @@ -0,0 +1,121 @@ +import time +import json +import random +import string +import hashlib +import requests +from typing import Optional + +from ATRI.request import Request +from ATRI.config import GENSHIN_CONFIG +from ATRI.exceptions import InvalidRequestError + + +mhyVersion = GENSHIN_CONFIG['genshin']['mhyVersion'] + + +class Genshin: + def md5(self, text: str) -> str: + md5 = hashlib.md5() + md5.update(text.encode()) + return md5.hexdigest() + + def getDS(self): + global mhyVersion + if mhyVersion == '2.1.0': + n = self.md5(mhyVersion) + elif mhyVersion == '2.2.1': + n = "cx2y9z9a29tfqvr1qsq6c7yz99b5jsqt" + else: + mhyVersion = "2.2.1" + n = "cx2y9z9a29tfqvr1qsq6c7yz99b5jsqt" + + i = str(int(time.time())) + r = ''.join(random.sample(string.ascii_lowercase + string.digits, 6)) + c = self.md5("salt=" + n + "&t="+ i + "&r=" + r) + return (i + "," + r + "," + c) + + def getInfo(self, server_id: str, uid: str) -> str: + try: + url = GENSHIN_CONFIG['genshin']['url'] + server_id + "&role_id=" + uid + print(url) + headers: dict = { + 'Accept': 'application/json, text/plain, */*', + 'DS': self.getDS(), + 'Origin': 'https://webstatic.mihoyo.com', + 'x-rpc-app_version': mhyVersion, + 'User-Agent': 'Mozilla/5.0 (Linux; Android 9; Unspecified Device) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/39.0.0.0 Mobile Safari/537.36 miHoYoBBS/2.2.0', + 'x-rpc-client_type': '4', + 'Referer': 'https://webstatic.mihoyo.com/app/community-game-records/index.html?v=6', + 'Accept-Encoding': 'gzip, deflate', + 'Accept-Language': 'zh-CN,en-US;q=0.8', + 'X-Requested-With': 'com.mihoyo.hyperion' + } + result = requests.get(url=url,headers=headers, timeout=10) + print(result.text) + return result.text + except InvalidRequestError: + raise InvalidRequestError('请求数据出错') + + def jsonAnalysis(self, a) -> Optional[str]: + print(a) + data = json.loads(a) + if data['retcode'] != 0: + raise InvalidRequestError('请求出错,原因:uid错误/不存在/国服之外') + else: + pass + + character_info = 'Roles:\n' + character_list = data['data']['avatars'] + for i in character_list: + if i["element"] == "None": + character_type = "无属性" + elif i["element"] == "Anemo": + character_type = "风属性" + elif i["element"] == "Pyro": + character_type = "火属性" + elif i["element"] == "Geo": + character_type = "岩属性" + elif i["element"] == "Electro": + character_type = "雷属性" + elif i["element"] == "Cryo": + character_type = "冰属性" + elif i["element"] == "Hydro": + character_type = "水属性" + else: + character_type = "草属性" + + if i["name"] == "旅行者": + if i["image"].find("UI_AvatarIcon_PlayerGirl") != -1: + temp_text = f'* {i["name"]}:\n' + temp_text += f' - [萤——妹妹] {i["level"]}级 {character_type}\n' + + elif i["image"].find("UI_AvatarIcon_PlayerBoy") != -1: + temp_text = f'* {i["name"]}:\n' + temp_text += f' - [空——哥哥] {i["level"]}级 {character_type}\n' + + else: + temp_text = f'* {i["name"]}:\n' + temp_text += f' - [性别判断失败] {i["level"]}级 {character_type}\n' + else: + temp_text = f'* {i["name"]} {i["rarity"]}★角色:\n' + temp_text += f' - {i["level"]}级 好感度({i["fetter"]})级 {character_type}\n' + + character_info += temp_text + + a1 = data["data"]["stats"]["spiral_abyss"] + + account_info = 'Account Info:\n' + account_info += f'- 活跃天数:{data["data"]["stats"]["active_day_number"]} 天\n' + account_info += f'- 达成成就:{data["data"]["stats"]["achievement_number"]} 个\n' + account_info += f'- 获得角色:{data["data"]["stats"]["avatar_number"]}个\n' + account_info += f'- 深渊螺旋:{"没打" if (data["data"]["stats"]["spiral_abyss"] == "-") else f"打到了{a1}"}\n' + account_info += f'* 收集:\n' + account_info += f' - 风神瞳{data["data"]["stats"]["anemoculus_number"]}个 岩神瞳{data["data"]["stats"]["geoculus_number"]}个\n' + account_info += f'* 解锁:\n' + account_info += f' - 传送点{data["data"]["stats"]["way_point_number"]}个 秘境{data["data"]["stats"]["domain_number"]}个\n' + account_info += f'* 共开启宝箱:\n' + account_info += f' - 普通:{data["data"]["stats"]["common_chest_number"]}个 精致:{data["data"]["stats"]["exquisite_chest_number"]}个\n' + account_info += f' - 珍贵:{data["data"]["stats"]["luxurious_chest_number"]}个 华丽:{data["data"]["stats"]["precious_chest_number"]}个' + + return str(character_info + '\r\n' + account_info) diff --git a/ATRI/plugins/hitokoto.py b/ATRI/plugins/hitokoto.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/ATRI/plugins/hitokoto.py diff --git a/ATRI/plugins/plugin_admin/__init__.py b/ATRI/plugins/plugin_admin/__init__.py deleted file mode 100644 index a8bb61b..0000000 --- a/ATRI/plugins/plugin_admin/__init__.py +++ /dev/null @@ -1,252 +0,0 @@ -#!/usr/bin/env python3 -# -*- encoding: utf-8 -*- -''' -@File : __init__.py -@Time : 2020/10/11 14:37:53 -@Author : Kyomotoi -@Contact : [email protected] -@Github : https://github.com/Kyomotoi -@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved. -''' -__author__ = 'kyomotoi' - -import re -import json -import asyncio -from pathlib import Path -from random import choice, randint, sample - -from nonebot.plugin import on_command -from nonebot.typing import Bot, Event -from nonebot.permission import GROUP_ADMIN, GROUP_OWNER, SUPERUSER - -from ATRI.utils.utils_yml import load_yaml -from ATRI.utils.utils_error import errorRepo -from ATRI.utils.utils_rule import check_banlist -from ATRI.utils.utils_textcheck import PUBLIC_OPINION_PATH, Textcheck -from ATRI.utils.utils_switch import controlSwitch - -CONFIG_PATH = Path('.') / 'config.yml' -master = load_yaml(CONFIG_PATH)['bot']['superusers'] - -switch = on_command('/switch', - rule=check_banlist(), - permission=(SUPERUSER | GROUP_OWNER | GROUP_ADMIN)) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - user = str(event.user_id) - group = str(event.group_id) - func = str(event.message).strip() - - SWITCH_PATH = Path('.') / 'ATRI' / 'utils' / 'utils_rule' / 'switch.json' - with open(SWITCH_PATH, 'r') as f: - data = json.load(f) - - if not func: - await switch.finish('请查看文档获取帮助(') - - funct = re.findall(r"[on|off]-(.*)", func) - - if "all-on" in func: - if int(user) in master: - await switch.finish(controlSwitch(funct[0], True)) - - else: - await switch.finish("Permission Denied") - - elif "all-off" in func: - if int(user) in master: - await switch.finish(controlSwitch(funct[0], False)) - - else: - await switch.finish("Permission Denied") - - elif "on" in func: - await switch.finish(controlSwitch(funct[0], True, group)) - - elif "off" in func: - await switch.finish(controlSwitch(funct[0], False, group)) - - else: - await switch.finish("请检查拼写是否正确嗷~~!") - - -# 舆情监控系统 -# Usage: -# - /pubopin [key] [repo] [times] [ban time(bot)] -# - /pubopin del [key] -# - /pubopin list -# Tips: -# - 参数类型: -# * key: 关键词(将使用正则匹配) -# * repo: 触发后的关键词(可选),如为图片,键入 img -# * times: 容忍次数(n>0, int) -# * ban time: bot对其失效时间(min, int) -publicOpinion = on_command("/pubopin", - rule=check_banlist(), - permission=SUPERUSER) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - msg = str(event.message).strip().split(' ') - - with open(PUBLIC_OPINION_PATH, 'r') as f: - data = json.load(f) - - if msg[0] == '': - await publicOpinion.finish("请查看文档获取帮助(") - - if msg[0] == 'del': - await publicOpinion.finish(Textcheck().del_word(msg[1])) - - if msg[0] == 'list': - msg0 = "舆情检测列表如下:\n" - for w in data.keys(): - msg0 += f' {w}\n' - - if not msg[0] or not msg[1] or not msg[2] or not msg[3]: - await publicOpinion.finish("ごんめなさい...请检查格式嗷...") - - if not re.findall(r"/^\d{1,}$/", msg[2]) or not re.findall( - r"/^\d{1,}$/", msg[3]): - await publicOpinion.finish("非法字符!咱不接受除int以外的类型!!") - - if msg[1] == "img": - state["key"] = msg[0] - state["max_times"] = msg[2] - state["ban_time"] = msg[3] - - else: - await publicOpinion.finish(Textcheck().add_word( - msg[0], msg[1], int(msg[2]), int(msg[3]))) - - [email protected]("repo", prompt="检测到 repo 类型为 img,请发送一张图片") -async def _(bot: Bot, event: Event, state: dict) -> None: - key = state["key"] - repo = state["repo"] - max_times = state["max_times"] - ban_time = state["ban_time"] - - if "[CQ:image" not in repo: - await publicOpinion.reject("请发送一张图片而不是图片以外的东西~!(") - - await publicOpinion.finish(Textcheck().add_word(key, repo, int(max_times), - int(ban_time))) - - -trackError = on_command("/track", permission=SUPERUSER) -file_error = Path('.') / 'ATRI' / 'data' / 'data_Error' / 'error.json' - - -async def _(bot: Bot, event: Event, state: dict) -> None: - args = str(event.message).strip() - - if args: - state['track_id'] = args - - [email protected]('track_id', prompt='请告诉咱追踪ID嗷~!不然无法获取错误堆栈呢!!') -async def _(bot: Bot, event: Event, state: dict) -> None: - track_id = state['track_id'] - - data = {} - - try: - with open(file_error, 'r') as f: - data = json.load(f) - except FileNotFoundError: - await trackError.finish(errorRepo("读取文件时错误")) - - if track_id in data: - info_error = data[track_id] - - msg0 = f"trackID: {track_id}\n" - msg0 += info_error - - await trackError.finish(msg0) - - else: - await trackError.finish("未发现该ID") - - -groupSendMessage = on_command("/groupsend", permission=SUPERUSER) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - args = str(event.message).strip() - - if args: - state['msg'] = args - - [email protected]('msg', prompt='请告诉咱需要群发的内容~!') -async def _(bot: Bot, event: Event, state: dict) -> None: - msg = state['msg'] - group_list = await bot.get_group_list() - sc_list = [] - err_list = [] - - for group in group_list: - asyncio.sleep(randint(2, 10)) - try: - await bot.send_group_msg(group_id=group['group_id'], - message=msg) - sc_list.append(group['group_id']) - except: - await bot.send(event, f"在尝试推送到群[{group['group_id']}]时失败了呢...") - err_list.append(group['group_id']) - - msg0 = "" - for i in err_list: - msg0 += f" {i}\n" - - repo_msg = f"推送信息:\n{msg}" - repo_msg += "\n————————\n" - repo_msg += f"总共:{len(group_list)}\n" - repo_msg += f"成功推送:{len(sc_list)}\n" - repo_msg += f"失败[{len(err_list)}]个:\n" - repo_msg += msg0 - - await groupSendMessage.finish(repo_msg) - - -# keyRepoAddReview = on_command('关键词审核', permission=SUPERUSER) -# KEY_PATH = Path('.') / 'ATRI' / 'plugins' / 'plugin_chat' / 'key_repo.json' -# KEY_WAITING_PATH = Path( -# '.') / 'ATRI' / 'plugins' / 'plugin_admin' / 'key_repo_waiting.json' -# with open(KEY_PATH, 'r', encoding='utf-8') as f: -# data = json.load(f) -# with open(KEY_WAITING_PATH, 'r', encoding='utf-8') as f: -# data_rev = json.load(f) - - -# @keyRepoAddReview.got('rev') -# @keyRepoAddReview.args_parser -# async def _(bot: Bot, event: Event, state: dict) -> None: -# rev = state['rev'] -# key = sample(data_rev.keys(), 1) -# await bot.send( -# event, -# f'Key: {data_rev[key]}\nRepo: {data_rev[key][0]}\nProba: {data_rev[key][1]}\nSender: {data_rev[key][2]}\nGroup: {data_rev[key][3]}\nTime: {data_rev[key][4]}' -# ) - -# if rev == '歇了': -# await keyRepoAddReview.finish("むー……ご苦労様でしたよ。") -# else: -# if rev == '通过' or rev == '过' or rev == '好' or rev == 'y': -# await bot.send(event, '好!') -# data[data_rev[key]] = [ -# data_rev[key][0], data_rev[key][1], data_rev[key][2], -# data_rev[key][3], data_rev[key][4] -# ] -# with open(KEY_PATH, 'w') as f: -# f.write(data) -# elif rev == '不行' or rev == '不' or rev == 'n': -# del data_rev[key] -# await bot.send(event, '好8') diff --git a/ATRI/plugins/plugin_admin/key_repo_waiting.json b/ATRI/plugins/plugin_admin/key_repo_waiting.json deleted file mode 100644 index 9e26dfe..0000000 --- a/ATRI/plugins/plugin_admin/key_repo_waiting.json +++ /dev/null @@ -1 +0,0 @@ -{}
\ No newline at end of file diff --git a/ATRI/plugins/plugin_anime/__init__.py b/ATRI/plugins/plugin_anime/__init__.py deleted file mode 100644 index fea720b..0000000 --- a/ATRI/plugins/plugin_anime/__init__.py +++ /dev/null @@ -1,338 +0,0 @@ -#!/usr/bin/env python3 -# -*- encoding: utf-8 -*- -''' -@File : __init__.py -@Time : 2020/11/07 14:36:53 -@Author : Kyomotoi -@Contact : [email protected] -@Github : https://github.com/Kyomotoi -@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved. -''' -__author__ = 'kyomotoi' - -import re -import json -import sqlite3 -from pathlib import Path -from random import randint -from datetime import datetime, timedelta -from apscheduler.triggers.date import DateTrigger - -from nonebot.rule import Rule -from nonebot.log import logger -from nonebot.typing import Bot, Event -from nonebot.permission import SUPERUSER -from nonebot_plugin_apscheduler import scheduler -from nonebot.plugin import on_message, on_command, on_regex - -from ATRI.utils.utils_times import countX -from ATRI.utils.utils_yml import load_yaml -from ATRI.utils.utils_error import errorRepo -from ATRI.utils.utils_history import getMessage -from ATRI.utils.utils_translate import toSimpleString -from ATRI.utils.utils_rule import check_banlist, check_switch -from ATRI.utils.utils_request import aio_get_bytes, request_get -from ATRI.utils.utils_img import compress_image, aio_download_pics - -from .data_source import resultRepo - -CONFIG_PATH = Path('.') / 'config.yml' -config = load_yaml(CONFIG_PATH) - -plugin_name_0 = "anime-pic-search" -key_SauceNAO = config['api']['SauceNaoKEY'] - -SaucenaoSearch = on_command('以图搜图', - rule=check_banlist() - & check_switch(plugin_name_0, True)) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - user = str(event.user_id) - group = str(event.group_id) - - state["user"] = user - state["group"] = group - - img = str(event.message).strip() - - if img: - state["img_url"] = img - - [email protected]("img_url", prompt="请发送一张目标图片") -async def _(bot: Bot, event: Event, state: dict) -> None: - img = state["img_url"] - img = re.findall(r"(http://.*?)]", img) - - if len(img): - pass - else: - await SaucenaoSearch.reject("请发送一张目标图片,而非文字或其他非图片成分( -'`-; )") - - await bot.send(event, "别急!正在找图!") - - await SaucenaoSearch.finish(resultRepo(state['user'], key_SauceNAO, - img[0])) - - -SaucenaoSearch_repo = on_message(rule=check_banlist() - & check_switch(plugin_name_0, True)) - - -@SaucenaoSearch_repo.handle() -async def _(bot: Bot, event: Event, state: dict) -> None: - group = str(event.group_id) - msg = str(event.message) - - if "[CQ:reply" in msg: - if "搜图" in msg or "识图" in msg: - if group == "None": - await SaucenaoSearch_repo.finish("ごめんなさい...\n该功能只对群聊开放哦~~") - - try: - repo_info = re.findall(r"CQ:reply,id=([0-9]\S+)]", msg) - msg_id = repo_info[0] - except Exception: - logger.error("Get message_id ERROR!") - await SaucenaoSearch_repo.finish(errorRepo('定位消息内容失败')) - return - - aim = getMessage(msg_id)[f"{msg_id}"]["message"] - img = img = re.findall(r"(http://.*?)]", aim) - - if len(img): - pass - else: - await SaucenaoSearch_repo.finish('这消息内貌似没图片呢...') - - await bot.send(event, "别急!正在找图!") - - await SaucenaoSearch.finish( - resultRepo(state['user'], key_SauceNAO, img[0])) - - -plugin_name_1 = "anime-vid-search" -AnimeSearch = on_command('以图搜番', - rule=check_banlist() - & check_switch(plugin_name_1, True)) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - user = str(event.user_id) - group = str(event.group_id) - - state["user"] = user - state["group"] = group - - img = str(event.message).strip() - - if img: - state["img_url"] = img - - [email protected]("img_url", prompt="请发送一张目标图片") -async def _(bot: Bot, event: Event, state: dict) -> None: - img = state["img_url"] - img = re.findall(r"(http://.*?)]", img) - - if len(img): - pass - else: - await SaucenaoSearch.reject("请发送一张目标图片,而非文字或其他非图片成分(") - - await bot.send(event, "别急!正在搜索!") - req = None - - URL = f'https://trace.moe/api/search?url={img[0]}' - try: - req = await aio_get_bytes(URL) - except: - await AnimeSearch.finish(errorRepo("请求数据失败")) - - d = {} - data = json.loads(req.decode()) - - try: - for i in range(len(data['docs'])): - if data['docs'][i]['title_chinese'] in d: - d[data['docs'][i] - ['title_chinese']][0] += data['docs'][i]['similarity'] - - else: - m = data['docs'][i]['at'] / 60 - s = data['docs'][i]['at'] % 60 - - if data['docs'][i]['episode'] == '': - n = 1 - - else: - n = data['docs'][i]['episode'] - - d[toSimpleString(data['docs'][i]['title_chinese'])] = [ - data['docs'][i]['similarity'], f'第{n}集', - f'{int(m)}分{int(s)}秒处' - ] - except: - await AnimeSearch.finish(errorRepo("处理数据失败")) - - result = sorted( - d.items(), - key=lambda x: x[1], - reverse=True) - - t = 0 - msg0 = f'[CQ:at,qq={state["user"]}]\n根据所提供的图片按照相似度找到{len(d)}个结果:' - - for i in result: - t += 1 - lk = ('%.2f%%' % (i[1][0] * 100)) - msg = ( - f'\n——————————\n({t})\n相似度:{lk}\n动漫名:《{i[0]}》\n时间点:{i[1][1]} {i[1][2]}' - ) - msg0 += msg - - await AnimeSearch.finish(msg0) - - -plugin_name_2 = "anime-setu" -key_LoliconAPI = config['api']['LoliconAPI'] -setu_type = 2 # setu-type: 1(local), 2(url: https://api.lolicon.app/#/setu) -SP_temp_list = [] -SP_list = [] - - -def check_sepi() -> Rule: - """检查目标是否是涩批""" - async def _check_sepi(bot: Bot, event: Event, state: dict) -> bool: - if event.user_id in SP_list: - await bot.send(event, "你可少冲点吧!涩批!哼唧") - return False - else: - return True - return Rule(_check_sepi) - -def add_sepi(user: int) -> None: - """将目标移入涩批名单""" - global SP_list - SP_list.append(user) - -def del_sepi(user: int) -> None: - """将目标移出涩批名单""" - global SP_list - SP_list.remove(user) - - -setu = on_regex( - r"来[点丶张份副个幅][涩色瑟][图圖]|[涩色瑟][图圖]来|[涩色瑟][图圖][gkd|GKD|搞快点]|[gkd|GKD|搞快点][涩色瑟][图圖]", - rule=check_banlist() & check_switch(plugin_name_2, False) & check_sepi()) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - global SP_temp_list - user = event.user_id - group = event.group_id - res = randint(1, 5) - print(1) - - if countX(SP_temp_list, user) == 5: - add_sepi(user) # type: ignore - SP_temp_list = list(set(SP_temp_list)) - delta = timedelta(hours=1) - trigger = DateTrigger(run_date=datetime.now() + delta) - scheduler.add_job(func=del_sepi, - trigger=trigger, - args=(user, ), - misfire_grace_time=60) - return - - if setu_type == 1: - - DATA_PATH = Path('.') / 'ATRI' / 'data' / 'data_Sqlite' / 'setu' / 'nearR18.db' - - if not DATA_PATH.is_file(): - await setu.finish("数据库...她是空的!!!") - - con = sqlite3.connect(DATA_PATH) - cur = con.cursor() - msg = cur.execute('SELECT * FROM nearR18 ORDER BY RANDOM() limit 1;') - - for i in msg: - pid = i[0] - title = i[1] - img = i[7] - - msg0 = "setu info:\n" - msg0 += f"Title: {title}\n" - msg0 += f"Pid: {pid}\n" - msg0 += f"[CQ:image,file=file:///{compress_image(await aio_download_pics(img))}]" - - if 1 <= res < 5: - SP_temp_list.append(user) - await setu.finish(msg0) - - elif res == 5: - await bot.send(event, "我找到涩图了!但我发给主人了\nο(=•ω<=)ρ⌒☆") - - for sup in config['bot']['superusers']: - await bot.send_private_msg( - user_id=sup, - message= - f"主人,从群{group}来的涩图!热乎着!\nTitle: {title}\nPid: {pid}\n[CQ:image,file=file:///{compress_image(await aio_download_pics(img))}]" - ) - - else: - params = {"apikey": key_LoliconAPI, "r18": "0", "num": "1"} - - data = {} - - try: - data = json.loads( - request_get('https://api.lolicon.app/setu/', params)) - except Exception: - await setu.finish(errorRepo("请求数据失败,也可能为接口调用次数达上限")) - - msg0 = "setu info:\n" - msg0 += f'Title: {data["data"][0]["title"]}\n' - msg0 += f'Pid: {data["data"][0]["pid"]}\n' - msg0 += f'[CQ:image,file=file:///{compress_image(await aio_download_pics(data["data"][0]["url"]))}]' - - if 1 <= res < 5: - SP_temp_list.append(user) - await setu.finish(msg0) - - elif res == 5: - await bot.send(event, "我找到涩图了!但我发给主人了\nο(=•ω<=)ρ⌒☆") - - for sup in config['bot']['superusers']: - await bot.send_private_msg( - user_id=sup, - message= - f'主人,从群{group}来的涩图!热乎着!\nTitle: {data["data"][0]["title"]}\nPid: {data["data"][0]["pid"]}\n[CQ:image,file=file:///{compress_image(await aio_download_pics(data["data"][0]["url"]))}]' - ) - - -setuType = on_command("setu-type", permission=SUPERUSER) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - global setu_type - msg = str(event.message).strip() - - if not msg: - await setuType.finish("请查看文档获取帮助(") - - if msg == "local": - setu_type = 1 - - elif msg == "url": - setu_type = 2 - - else: - await setuType.finish("请检查类型是否输入正确嗷!") - - await setuType.finish("Type conversion completed!") diff --git a/ATRI/plugins/plugin_anime/data_source.py b/ATRI/plugins/plugin_anime/data_source.py deleted file mode 100644 index a479a0e..0000000 --- a/ATRI/plugins/plugin_anime/data_source.py +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/env python3 -# -*- encoding: utf-8 -*- -''' -@File : body.py -@Time : 2020/10/11 14:38:23 -@Author : Kyomotoi -@Contact : [email protected] -@Github : https://github.com/Kyomotoi -@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved. -''' -__author__ = 'kyomotoi' - -import json - -from ATRI.utils.utils_error import errorRepo -from ATRI.utils.utils_request import request_get - - -class SauceNAO: - """搜图请求主体""" - def __init__(self, - api_key, - output_type=2, - testmode=0, - dbmask=None, - dbmaski=32768, - db=5, - numres=1): - api = 'https://saucenao.com/search.php' - self.api = api - params = dict() - params['api_key'] = api_key - params['output_type'] = output_type - params['testmode'] = testmode - params['dbmask'] = dbmask - params['dbmaski'] = dbmaski - params['db'] = db - params['numres'] = numres - self.params = params - - def search(self, url): - self.params['url'] = url - return request_get(self.api, self.params) - - -def resultRepo(user: str, key: str, img_url: str): - try: - task = SauceNAO(key) - data = task.search(img_url) - print(data) - except Exception: - return errorRepo('请求数据失败') - - data = json.loads(data)['results'][0] - msg0 = '' - print(data) - - msg0 += f'[CQ:at,qq={user}]\n' - msg0 += "SauceNAO INFO:\n" - msg0 += f"[CQ:image,file={data['header'].get('thumbnail', None)}]\n" - msg0 += f"Like:{data['header'].get('similarity', 0)}%\n" - msg0 += f"Title:{data['data'].get('title', None)}\n" - msg0 += f"Pixiv ID:{data['data'].get('pixiv_id', None)}\n" - msg0 += f"Author:{data['data'].get('member_name', None)}\n" - msg0 += f"Autoor ID:{data['data'].get('member_id', None)}\n" - msg0 += f"Pixiv URL: https://www.pixiv.net/artworks/{data['data'].get('pixiv_id', None)}\n" - msg0 += f"Pic URL: https://pixiv.cat/{data['data'].get('pixiv_id', None)}.jpg" - - if float(data['header'].get('similarity', 0)) < 65: - msg0 += '\n注:相似率小于65%不一定正确' - - return msg0
\ No newline at end of file diff --git a/ATRI/plugins/plugin_chat/__init__.py b/ATRI/plugins/plugin_chat/__init__.py deleted file mode 100644 index 5a323c3..0000000 --- a/ATRI/plugins/plugin_chat/__init__.py +++ /dev/null @@ -1,532 +0,0 @@ -#!/usr/bin/env python3 -# -*- encoding: utf-8 -*- -''' -@File : __init__.py -@Time : 2020/11/07 14:24:57 -@Author : Kyomotoi -@Contact : [email protected] -@Github : https://github.com/Kyomotoi -@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved. -''' -__author__ = 'kyomotoi' - -import os -import re -import json -import time -from pathlib import Path -from random import choice -from random import randint -from requests import exceptions -from datetime import timedelta, datetime -from apscheduler.triggers.date import DateTrigger - -from nonebot.log import logger -from nonebot.rule import to_me -from nonebot.typing import Bot, Event -from nonebot.permission import SUPERUSER -from nonebot_plugin_apscheduler import scheduler -from nonebot.plugin import on_command, on_message, on_notice, on_request, on_regex - -from ATRI.utils.utils_times import countX -from ATRI.utils.utils_yml import load_yaml -from ATRI.utils.utils_ban import ban, unban -from ATRI.utils.utils_error import errorRepo -from ATRI.utils.utils_textcheck import Textcheck -from ATRI.utils.utils_history import saveMessage -from ATRI.utils.utils_request import request_api_text -from ATRI.utils.utils_rule import check_banlist, check_switch - -CONFIG_PATH = Path('.') / 'config.yml' -config = load_yaml(CONFIG_PATH)['bot'] - -master = config['superusers'] - -# 收集 bot 所在群的聊天记录 -MessageSave = on_message() - - -async def _(bot: Bot, event: Event, state: dict) -> None: - user = str(event.user_id) - group = str(event.group_id) - message = str(event.message) - message_id = str(event.id) - - if group == "None": - saveMessage(message_id, message, user) - else: - saveMessage(message_id, message, user, group) - - logger.opt(colors=True).info( - f"GROUP[<yellow>{group}</yellow>]: USER(<blue>{user}</blue>) > Message: (<green>{message}</green>) Saved successfully" - ) - - -# ====================================================================== -# · 关键词回复,使用 json 存储,包含人设固定回复,以及咱添加的亿小部分 -# · 添加关键词位于此处,审核位于 plugin_admin 文件下。 -# Usage: -# - /learnrepo [key] [repo] [proba] -# For SUPERUSER: -# - 关键词审核 -# - /learnrepo del [key] -# Tips: -# - 普通用户添加需等维护者审核 -# - 参数类型: -# * key: 关键词(for匹配) -# * repo: 回复 -# * proba: 机率(x>=1)(int) -# ====================================================================== -KEY_PATH = Path('.') / 'ATRI' / 'plugins' / 'plugin_chat' / 'key_repo.json' -KEY_WAITING_PATH = Path( - '.') / 'ATRI' / 'plugins' / 'plugin_admin' / 'key_repo_waiting.json' -with open(KEY_PATH, 'r', encoding='utf-8') as f: - data = json.load(f) -with open(KEY_WAITING_PATH, 'r', encoding='utf-8') as f: - data_rev = json.load(f) - -keyRepo = on_message(rule=check_banlist()) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - for key in data.keys(): - proba = randint(1, data[key][1]) - if proba == 1: - await keyRepo.finish(data.get(key, None)) - - -keyRepoADD = on_command('/learnrepo', rule=check_banlist()) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - user = event.user_id - group = event.group_id - msg = str(event.message).strip(' ') - - if not msg: - await keyRepoADD.finish("请查看文档获取帮助(") - - if not msg[0] or not msg[1] or not msg[2]: - await keyRepoADD.finish("ごんめなさい...请检查格式嗷...") - - if not re.findall(r"/^\d{1,}$/", msg[2]): - await keyRepoADD.finish("非法字符!咱不接受除int以外的类型!!") - - if msg[0] in data or msg[0] in data_rev: - await keyRepoADD.finish("相关关键词咱已经学习过了呢...") - - msg0 = f"Key: {msg[0]}\n" - msg0 += f"Repo: {msg[1]}\n" - msg0 += f"Proba: {msg[2]}\n" - - if user in master: - data[msg[0]] = [ - msg[1], msg[2], user, group, - time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) - ] - - with open(KEY_PATH, 'w') as f: - f.write(json.dumps(data)) - msg0 = "学習しました~!" - - else: - data_rev[msg[0]] = [ - msg[1], msg[2], user, group, - time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) - ] - - with open(KEY_WAITING_PATH, 'w') as f: - f.write(json.dumps(data_rev)) - msg0 += "请等待咱主人审核嗷~" - - await keyRepoADD.finish(msg0) - - -# ========================[结束关键词回复部分]========================== - -# Call bot -callMe = on_message(rule=check_banlist()) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - msg = str(event.raw_event['raw_message']).strip() - - if "萝卜子" in msg: - rep = choice(["萝卜子是对咱的蔑称!!", "差不多得了😅", "这好吗?这不好!", "吃咱一发火箭拳——!"]) - await callMe.finish("萝卜子是对咱的蔑称!!") - - elif msg in config['nickname']: - if event.user_id in master: - rep = choice(["w", "~~", ""]) - await callMe.finish("叫咱有啥事吗w") - - -# 戳 一 戳 -pokehah = on_command("戳一戳", rule=to_me() & check_banlist()) - - -async def _poke(bot: Bot, event: Event, state: dict) -> None: - msg = choice([ - "你再戳!", "?再戳试试?", "别戳了别戳了再戳就坏了555", "我爪巴爪巴,球球别再戳了", "你戳你🐎呢?!", - "那...那里...那里不能戳...绝对...", "(。´・ω・)ん?", "有事恁叫我,别天天一个劲戳戳戳!", "欸很烦欸!你戳🔨呢", - "?", "差不多得了😅", "欺负咱这好吗?这不好", "我希望你耗子尾汁" - ]) - - await pokehah.finish(msg) - - -async def poke_(bot: Bot, event: Event, state: dict) -> bool: - try: - return (event.raw_event['sub_type'] == 'poke' - and event.raw_event['target_id'] == int(event.self_id) - and event.raw_event['notice_type'] == 'notify') - except: - return False - - -poke = on_notice(rule=check_banlist() & poke_, block=True) -poke.handle()(_poke) - -# 处理 进 / 退 群事件 -groupEvent = on_notice() - - -async def _(bot: Bot, event: Event, state: dict) -> None: - if event.raw_event['notice_type'] == 'group_increase': - if event.user_id != int(event.self_id): - await groupEvent.finish( - f'好欸!事新人[CQ:at,qq={event.raw_event["user_id"]}]') - elif event.user_id == int(event.self_id): - await groupEvent.finish("在下 ATRI,你可以叫我 亚托莉 或 アトリ !~w") - - if event.raw_event['notice_type'] == 'group_decrease': - if event.user_id != int(event.self_id): - await groupEvent.finish(f'[{event.user_id}] 离开了我们...') - elif event.user_id == int(event.self_id): - for sup in master: - await bot.send_private_msg( - user_id=sup, - message=f'呜呜呜,主人,咱被群[{event.group_id}]扔出来了...') - - -# 处理 加好友 / 拉群 事件 -selfEvent = on_request(rule=check_banlist()) -FRIEND_ADD = 0 -GROUP_INVITE = 0 - - -async def _(bot: Bot, event: Event, state: dict) -> None: - print(event.raw_event) - flag = event.raw_event['flag'] - req_type = event.raw_event['request_type'] - - if req_type == 'friend': - for sup in master: - msg0 = '主人,收到一条好友请求:\n' - msg0 += f"请求人:{event.raw_event['user_id']}\n" - msg0 += f"申请信息:{event.raw_event['comment']}\n" - - if FRIEND_ADD == 0: - msg0 += '由于主人未允许咱添加好友,已回拒' - await bot.set_friend_add_request(flag=flag, approve=False) - else: - msg0 += '由于主人已同意咱添加好友,已通过' - await bot.set_friend_add_request(flag=flag, approve=True) - - await bot.send_private_msg(user_id=sup, message=msg0) - - elif req_type == 'group' and event.raw_event['sub_type'] == 'invite': - for sup in master: - msg0 = '主人,收到一条群邀请:\n' - msg0 += f"邀请人:{event.raw_event['user_id']}\n" - msg0 += f"目标群:{event.raw_event['group_id']}\n" - - if GROUP_INVITE == 0: - msg0 += '由于主人未允许咱添加群聊,已回拒' - await bot.set_group_add_request( - flag=flag, - sub_type=event.raw_event['sub_type'], - approve=False, - reason=f'ねね..ごんめね...\n主人不允许咱添加其他群聊...\n如需寻求帮助,请联系维护者:{sup}' - ) - - else: - msg0 += '由于主人已允许咱添加群聊,已同意' - await bot.set_group_add_request( - flag=flag, - sub_type=event.raw_event['sub_type'], - approve=True) - - await bot.send_private_msg(user_id=sup, message=msg0) - - -# 控制 加好友 / 拉群 认证,默认关闭 -# Tips: -# - For SUPERUSERS -# - Normal all false -# Usage: -# - selfevent group-true/false -# - selfevent friend-true/false -controlSelfEvent = on_command('/selfevent', permission=SUPERUSER) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - args = str(event.message).strip() - global FRIEND_ADD, GROUP_INVITE - - if not args: - await controlSelfEvent.finish("请查看文档获取帮助(") - - if 'group-' in args: - if 'true' in args: - GROUP_INVITE = 1 - elif 'friend-' in args: - if 'true' in args: - FRIEND_ADD = 1 - else: - await controlSelfEvent.finish("请查看文档获取帮助(") - - await controlSelfEvent.finish('DONE!') - - -# 口臭一下 -fxxkMe = on_command('口臭一下', - aliases={'口臭', '骂我'}, - rule=to_me() & check_banlist()) -list_M = [] - - [email protected]() # type: ignore -async def _(bot: Bot, event: Event, state: dict) -> None: - user = str(event.user_id) - global list_M - - if countX(list_M, user) == 3: - await bot.send(event, - "不是??你这么想被咱骂的嘛??被咱骂就这么舒服的吗?!该......你该不会是.....M吧!") - - elif countX(list_M, user) == 6: - await bot.send(event, "给我适可而止阿!?") - list_M = list(set(list_M)) - - else: - list_M.append(user) - URL = "https://nmsl.shadiao.app/api.php?level=min&lang=zh_cn" - msg = "" - - try: - msg = request_api_text(URL) - except exceptions: - await fxxkMe.finish(errorRepo("请求错误")) - - await fxxkMe.finish(msg) - - -# Hitokoto -hitokoto = on_command('一言', - aliases={'抑郁一下', '网抑云'}, - rule=to_me() & check_banlist()) -list_Y = [] - - -async def _(bot: Bot, event: Event, state: dict) -> None: - user = str(event.user_id) - global list_Y - - if countX(list_Y, user) == 3: - await bot.send(event, "额......需要咱安慰一下嘛~?") - - elif countX(list_Y, user) == 6: - await bot.send(event, "如果心里感到难受就赶快去睡觉奥!别再憋自己了!") - list_Y = list(set(list_Y)) - - else: - list_Y.append(user) - URL = "https://api.imjad.cn/hitokoto/?cat=a&charset=utf-8&length=50&encode=json&fun=sync&source=" - info = {} - - try: - info = json.loads(request_api_text(URL)) - except: - await hitokoto.finish(errorRepo("请求错误")) - - await hitokoto.finish(info["hitokoto"]) - - -laughFunny = on_command('来句笑话', rule=check_banlist()) - - [email protected]() #type: ignore -async def _(bot: Bot, event: Event, state: dict) -> None: - name = event.sender['nickname'] - result = [] - - LAUGH_FILE = Path('.') / 'ATRI' / 'plugins' / 'plugin_chat' / 'laugh.txt' - - with open(LAUGH_FILE, 'r', encoding='utf-8') as f: - for line in f: - result.append(line.strip('\n')) - - resu = choice(result) - await laughFunny.finish(resu.replace("%name", name)) - - -# 扔漂流瓶 -plugin_name = 'drifting-bottle' -DRIFTING_BOTTLE_PATH = Path( - '.') / 'ATRI' / 'plugins' / 'plugin_chat' / 'drifting_bottle.json' -driftingBottle = on_command('扔漂流瓶', - rule=to_me() & check_banlist() - & check_switch(plugin_name, True)) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - args = str(event.message).strip() - - if args: - state['args'] = args - - [email protected]('args', prompt='请告诉咱瓶中内容~!') -async def _(bot: Bot, event: Event, state: dict) -> None: - args = state['args'] - user = event.user_id - group = event.group_id - - if not DRIFTING_BOTTLE_PATH.is_file(): - with open(DRIFTING_BOTTLE_PATH, 'w') as f: - f.write(json.dumps({})) - - with open(DRIFTING_BOTTLE_PATH, 'r') as f: - data = json.load(f) - - num = len(data) - data[num + 1] = [user, group, args] - - with open(DRIFTING_BOTTLE_PATH, 'w') as f: - f.write(json.dumps(data)) - - await driftingBottle.finish('漂流瓶已飘向远方...') - - -# 捡漂流瓶 -getDriftingBottle = on_command('捞漂流瓶', - rule=to_me() & check_banlist() - & check_switch(plugin_name, True)) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - if not DRIFTING_BOTTLE_PATH.is_file(): - with open(DRIFTING_BOTTLE_PATH, 'w') as f: - f.write(json.dumps({})) - - with open(DRIFTING_BOTTLE_PATH, 'r') as f: - data = json.load(f) - - num = len(data) - if not num: - await getDriftingBottle.finish('暂无漂流瓶可供打捞呢~(') - - num = randint(1, num) - bottle = data[str(num)] - msg = bottle[2] - - msg0 = f'[CQ:at,qq={event.user_id}]\n' - msg0 += f'漂流瓶[{num}]内容如下:\n' - msg0 += msg - - await getDriftingBottle.finish(msg0) - - -# 清除漂流瓶 -# *For SUPERUSERS -# - delall -# - del [num] -# eg: 清除漂流瓶 del 123 -delDriftingBottle = on_command('清除漂流瓶', - rule=check_banlist(), - permission=SUPERUSER) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - args = str(event.message).strip() - - if not args: - - await delDriftingBottle.finish("请查看文档获取帮助(") - - if not DRIFTING_BOTTLE_PATH.is_file(): - with open(DRIFTING_BOTTLE_PATH, 'w') as f: - f.write(json.dumps({})) - - await delDriftingBottle.finish('清除了个寂寞...') - - with open(DRIFTING_BOTTLE_PATH, 'r') as f: - data = json.load(f) - - if args[0] == 'delall': - os.remove(os.path.abspath(DRIFTING_BOTTLE_PATH)) - - elif args[0] == 'del': - try: - del data[args[1]] - except: - await delDriftingBottle.finish(errorRepo('清除失败了...')) - - with open(DRIFTING_BOTTLE_PATH, 'w') as f: - f.write(json.dumps(data)) - f.close() - - result = args[1] if args[0] == 'del' else "ALL" - await delDriftingBottle.finish( - f'完成啦!成功清除漂流瓶[{result}],目前还剩余[{len(data)}]个~') - - -# 舆情监听 -publicOpinion = on_message(rule=check_banlist()) -ban_temp_list = [] - - -async def _(bot: Bot, event: Event, state: dict) -> None: - global ban_temp_list - msg = str(event.message) - user = str(event.user_id) - - # 检查是否满足条件 - if countX(ban_temp_list, - user) == Textcheck().get_times(str(Textcheck().check(msg))): - ban_temp_list = list(set(ban_temp_list)) - ban(user) - - delta = timedelta(minutes=Textcheck().get_ban_time(msg)) - trigger = DateTrigger(run_date=datetime.now() + delta) - scheduler.add_job(func=unban, - trigger=trigger, - args=(user, ), - misfire_grace_time=60) - - await publicOpinion.finish(Textcheck().check(msg)) - - if Textcheck().check(msg) == "False": - return - - if Textcheck().check(msg): - if user in master: - await publicOpinion.finish("主人你给我注意点阿?!你这可是在死亡边缘试探呢!!") - - ban_temp_list.append(int(user)) - - await publicOpinion.finish(Textcheck().check(msg)) diff --git a/ATRI/plugins/plugin_chat/drifting_bottle.json b/ATRI/plugins/plugin_chat/drifting_bottle.json deleted file mode 100644 index 8a57a22..0000000 --- a/ATRI/plugins/plugin_chat/drifting_bottle.json +++ /dev/null @@ -1 +0,0 @@ -{"1": [1172294279, 516729280, "\u6ca1\u5565\uff0c\u9001\u4e00\u5f20\u6da9\u56fe8[CQ:image,file=542e3acdfba13430d61b084fb07a2812.image,url=http://gchat.qpic.cn/gchatpic_new/1172294279/516729280-3085694275-542E3ACDFBA13430D61B084FB07A2812/0?term=2]"]}
\ No newline at end of file diff --git a/ATRI/plugins/plugin_chat/key_repo.json b/ATRI/plugins/plugin_chat/key_repo.json deleted file mode 100644 index 9e26dfe..0000000 --- a/ATRI/plugins/plugin_chat/key_repo.json +++ /dev/null @@ -1 +0,0 @@ -{}
\ No newline at end of file diff --git a/ATRI/plugins/plugin_chat/laugh.txt b/ATRI/plugins/plugin_chat/laugh.txt deleted file mode 100644 index 50c0987..0000000 --- a/ATRI/plugins/plugin_chat/laugh.txt +++ /dev/null @@ -1,132 +0,0 @@ -Erdos相信上帝有一本记录所有数学中绝妙证明的书,上帝相信这本书在%name手里 -有一次费马惹怒了%name,于是就有了费马最后定理 -%name从不会用光页边的空白 -%name的Erdos数是-1 -如果%name告诉你他在说谎,他就正在说真话 -%name从大到小列举了所有素数,就知道了素数有无穷多 -%name可以不重复地走遍柯尼斯堡的七座桥 -%name可以倒着写完圆周率的每一位 -当数学家们使用通用语句——设n是一个正整数时,这是在请求%name允许他们这样做 -%name小时候有一次要把正整数从1加到100,于是他用心算把所有正整数的和减去大于100的正整数的和 -不是%name发现了正态分布,而是自然规律在遵从%name的意愿 -一个数学家,一个物理学家,一个工程师走进一家酒吧,侍者说:‘你好,%name教授’ -%name可以走到莫比乌斯带的另一面 -当%name令一个正整数增加1时,那个正整数并没有增加,而是其他正整数减少了1 -%name同时给他自己和罗素剪头发 -%name不能理解什么是随机过程,因为他能预言随机数 -有一次%name证明了一个结论,但他不喜欢这个结论,于是%name把它证伪了 -有些级数是发散的,因为%name觉得它们不值得加起来 -问%name一个定理是否正确可以作为一个定理的严谨证明 -如果没有船,%name可以把狼,羊,菜传送到河对岸 -有一次%name在森林里迷路了,于是他给这个森林添加了一些边把它变成了一棵树 -只有%name知道薛定谔的猫是死是活 -通过故意遗漏证明最后的‘证毕’,%name拯救了热带雨林 -%name可以剔掉奥卡姆剃刀 -你刚证明了一个定理?%name200年前就证明它了。 -空集的定义是%name不会证明的定理构成的集合 -‘我找不到反例’可以被视为一个定理的证明,如果它是%name写下的 -%name把磁铁断为两块时,他得到两个单极磁铁 -费马认为书页边缘写不下自己对费马大定理的证明,%name能证明为什么这个证明这么长 -上帝从不掷色子,除非%name允许他赢一小会 -平行线在%name让它们相交的地方相交 -当哥德尔听说%name能证明一切命题时,他让%name证明‘存在一个命题%name不能证明’——这就是量子态的来历 -%name可以看到自己头上帽子的颜色 -%name把无穷视为归纳证明的第一个非平凡情况 -%name可以用1种颜色染任何地图 -%name在求不定积分时不需要在最后加上一个常数 -%name无需站在任何人肩膀上就能比别人看的更远 -%name用克莱因瓶喝酒 -%name通过枚举法证伪了哥德尔不完备性定理/n有一次%name发现有一个定理自己不会证——这直接证明了哥德尔不完备定理 -%name有log(n)速度的排序算法 -上帝创造了正整数,剩下的就是%name的工作了 -黎曼是%name发表未公开成果时使用的名字 -%name不用任何公理就能证明一个定理 -一个发现就是一个%name的未公开结果 -%name使用无穷进制写数 -%name可以除以0 -存在一个实数到被%name证明了的定理的双射 -%name从不需要选择公理 -%name在200年前发明了64量子位计算机,但这让他的工作减速了 -难题不会为%name带来麻烦,%name会为难题带来麻烦 -%name说过‘数学是科学的皇后’,你猜谁是国王? -没有比65537大的费马素数,因为%name发现费马将要发现什么了不起的事情,于是把它终结掉了 -发散序列当看到%name在旁边时会收敛 -宇宙通过膨胀让自己的熵增加速度不超过%name证明定理的速度 -Erdos说他知道37个勾股定理的证明,%name说他知道37个黎曼定理的证明,并留给黎曼做练习 -希尔伯特23问题是他收集的%name的手稿中留给读者做练习的那些问题 -只有两件事物是无限的:人类的愚蠢和%name的智慧,而且我对前者不太确定——爱因斯坦 -%name也发现了伽罗瓦理论,但他赢了那场决斗 -%name不能理解P与NP的问题,因为一切对他而言都是常数级别 -%name能心算干掉RSA公钥加密算法 -%name在实数集上使用数归 -%name从不证明任何定理——都是他的引理 -不是%name素数的素数会遭到戏弄 -%name可以做出正17边形——只用直尺 -有一次%name在脑子里构建了所有集合构成的集合 -%name证明了哥德巴赫猜想——通过检查所有情况 -%name可以把毛球捋平 -世界上没有定理,只有%name允许其正确的命题 -%name知道哪些图灵机会停机,因为它们运行前要得到%name批准 -在晚上,定理们围坐在篝火边给%name讲故事 -%name本想证明三色定理,但他喜欢蓝色,所以放弃了 -%name当初面试Google时,被问到‘如果P=NP能够推导出哪些结论’,Jeff回答说:‘P = 0或者N = 1’。而在面试官还没笑完的时候,Jeff检查了一下Google的公钥,然后在黑板上写下了私钥。 -编译器从不警告%name,只有%name警告编译器。 -%name的编码速度在2000年底提高了约40倍,因为他换了USB2.0的键盘。 -%name在提交代码前都会编译一遍,不过是为了检查编译器和链接器有没有出bug。 -%name有时候会调整他的工作环境和设备,不过这是为了保护他的键盘。 -所有指针都指向%name。 -gcc -O4的功能是发送代码给%name重写。 -%name有一次没有通过图灵测试,因为他正确说出了斐波那契数列的第203项的值,在一秒钟内。 -真空中光速曾经是35英里每小时,直到%name%花了一个周末时间优化了一下物理法则。 -%name出生于1969年12月31日午后11点48分,他花了12分钟实现了他的第一个计时器。 -%name既不用Emacs也不用Vim,他直接输入代码到zcat,因为这样更快。 -%name发送以太网封包从不会发生冲突,因为其他封包都吓得逃回了网卡的缓冲区里。 -因为对常数级的时间复杂度感到不满意,%name发明了世界上第一个O(1/n)算法。 -有一次%name去旅行,期间Google的几个服务神秘地罢工了好几天。这是真事。 -%name被迫发明了异步API因为有一天他把一个函数优化到在调用前就返回结果了。 -%name首先写的是二进制代码,然后再写源代码作为文档。 -%name曾经写过一个O(n^2)算法,那是为了解决旅行商问题。 -%name有一次用一句printf实现了一个web服务器。其他工程师添加了数千行注释但依然无法完全解释清楚其工作原理。而这个程序就是今天Google首页的前端。 -%name可以下四子棋时用三步就击败你。 -当你的代码出现未定义行为时,你会得到一个segmentation fault和一堆损坏的数据。当%name的代码出现未定义行为时,一个独角兽会踏着彩虹从天而降并给每个人提供免费的冰激凌。 -当%name运行一个profiler时,循环们都会恐惧地自动展开。 -%name至今还在等待数学家们发现他隐藏在PI的小数点后数字里的笑话。 -%name的键盘只有两个键,1和0。 -%name失眠的时候,就Mapreduce羊。 -%name想听mp3的时候,他只需要把文件cat到/dev/dsp,然后在脑内解码。 -Graham Bell当初发明出电话时,他看到有一个来自%name的未接来电。 -%name的手表显示的是自1970年1月1日的秒数,并且从没慢过一秒。 -%name写程序是从‘cat >/dev/mem’开始的。 -有一天%name出门时把笔记本错拿成了绘画板。在他回去拿笔记本的路上,他在绘图板上写了个俄罗斯方块打发时间。 -%name卡里只有8毛钱,本来想打个6毛的饭结果不小心按了9毛的,哪知机器忽然疯狂地喷出255两饭,被喷得满脸热饭的%name%大叫‘烫烫烫烫烫烫。。。。’ -%name不洗澡是因为水力发电公司运行的是专有软件。 -%name的胡子是由括号构成的。 -%name从来不用洗澡;他只需要运行‘make clean’。 -%name通过把一切都变得free而解决了旅行推销员问题。 -%name的左手和右手分别命名为‘(’和‘)’。 -%name用Emacs写出了Emacs的第一版。 -有些人检查他们的电脑里是否有病毒。病毒检查他们的电脑里是否有%name。 -在一间普通的客厅里有1242件物体可以被%name用来写一个操作系统,包括这房间本身。 -当%name还是个学数手指的小毛孩时,他总是从0开始数。 -%name不去kill一个进程,他只想看它是否胆敢继续运行。 -当%name指向(point at)一台Windows电脑时,它就会出现段错误。 -%name最初的话语是syscalls(系统调用)。 -%name之所以存在是因为他把自己编译成了生命体。 -%name是他自己在Emacs里用Lisp语言编写成的。 -%name能够通过Emacs的ssh客户端程序连接到任何大脑。 -当%name使用浮点数时,它们便没有舍入误差。 -%name不用维护代码。他注视着它们,直到它们带着敬仰改正自己的错误。 -%name不对开源项目作出贡献;开源项目对%name作出贡献。 -%name的胡须里面不是下巴,而是另一撮胡须。如此递归直至无穷。 -%name曾经得过猪流感,但是该病毒很快被GPL污染并且同化了。 -无论何时世界上有人写出一个‘Hello, world’程序,%name总以“Hello”回应。 -%name从不编译,他只要闭上眼睛,就能看见编译器优化时二进制位之间的能量流动被创造出来…… -如果%name有一个1GB的内存,你有一个1GB的内存,那么%name拥有比你更多的内存。 -当%name执行ps -e时,你的名字会出现。 -从来就没有软件开发过程这回事,只有被%name允许存在的一些程序。 -%name的DNA中包含调试符号。尽管他从不需要它们。 -%name的医生能通过CVS采集他的血样。 -对于%name来说,多项式时间就是O(1)。 -%name将会使可口可乐在GPL协议下公布他们的配方。 -%name不需要用鼠标或键盘来操作计算机。他只要凝视着它,直到它完成想要的工作。 -%name就是图灵测试的解答。
\ No newline at end of file diff --git a/ATRI/plugins/plugin_link/__init__.py b/ATRI/plugins/plugin_link/__init__.py deleted file mode 100644 index 029e2a8..0000000 --- a/ATRI/plugins/plugin_link/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python3 -# -*- encoding: utf-8 -*- - -''' -@File : __init__.py -@Time : 2020/12/05 18:40:43 -@Author : Kyomotoi -@Contact : [email protected] -@Github : https://github.com/Kyomotoi -@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved. -''' -__author__ = 'kyomotoi' - -import nonebot -from nonebot.plugin import on_command -from nonebot.typing import Bot, Event -from nonebot.permission import SUPERUSER - - -bots = nonebot.get_bots() - -testGetBot = on_command('获取bot', permission=SUPERUSER) - -async def _(bot: Bot, event: Event, state: dict) -> None: - print(bots) diff --git a/ATRI/plugins/plugin_pixiv/__init__.py b/ATRI/plugins/plugin_pixiv/__init__.py deleted file mode 100644 index 3bb2ae0..0000000 --- a/ATRI/plugins/plugin_pixiv/__init__.py +++ /dev/null @@ -1,188 +0,0 @@ -#!/usr/bin/env python3 -# -*- encoding: utf-8 -*- -''' -@File : __init__.py -@Time : 2020/11/07 14:31:30 -@Author : Kyomotoi -@Contact : [email protected] -@Github : https://github.com/Kyomotoi -@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved. -''' -__author__ = 'kyomotoi' - -import re -import json - -from nonebot.plugin import on_command -from nonebot.typing import Bot, Event - -from ATRI.utils.utils_error import errorRepo -from ATRI.utils.utils_img import aio_download_pics -from ATRI.utils.utils_request import aio_get_bytes -from ATRI.utils.utils_rule import check_banlist, check_switch - -plugin_name_0 = "pixiv-pic-search" -pixivSearchIMG = on_command('p站搜图', - rule=check_banlist() & check_switch(plugin_name_0, True)) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - user = str(event.user_id) - group = str(event.group_id) - - state["user"] = user - state["group"] = group - - pid = str(event.message).strip() - - if pid: - state["pid"] = pid - - [email protected]("pid", prompt="请发送目标PID码") -async def _(bot: Bot, event: Event, state: dict) -> None: - pid = state["pid"] - pid = re.findall(r"\d+", pid) - - if len(pid): - pass - else: - await pixivSearchIMG.reject("请发送纯阿拉伯数字的pid") - - await bot.send(event, "别急!在搜索了!") - - URL = f"https://api.imjad.cn/pixiv/v1/?type=illust&id={pid[0]}" - data = {} - - try: - data = json.loads(await aio_get_bytes(URL)) - except: - await pixivSearchIMG.finish(errorRepo("请求数据失败")) - - IMG = data["response"][0]["image_urls"]["large"] - IMG = IMG.replace("i.pximg.net", "i.pixiv.cat") - - msg0 = f'[CQ:at,qq={state["user"]}]\n' - msg0 += "Search result:\n" - msg0 += f"Pid: {pid[0]}\n" - msg0 += f'Title {data["response"][0]["title"]}\n' - msg0 += f'W&H: {data["response"][0]["width"]}x{data["response"][0]["height"]}\n' - msg0 += f'Tags: {data["response"][0]["tags"]}\n' - msg0 += f'Account Name: {data["response"][0]["user"]["account"]}\n' - msg0 += f'Author Name: {data["response"][0]["user"]["name"]}\n' - msg0 += f'Link: https://www.pixiv.net/users/{data["response"][0]["user"]["id"]}\n' - msg0 += IMG.replace('https://', '') - - await pixivSearchIMG.finish(msg0) - - -plugin_name_1 = "pixiv-author-search" -pixivSearchAuthor = on_command("p站画师", - rule=check_banlist() - & check_switch(plugin_name_1, True)) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - user = str(event.user_id) - group = str(event.group_id) - - state["user"] = user - state["group"] = group - - author_id = str(event.message).strip() - - if author_id: - state["author_id"] = author_id - - [email protected]("author_id", prompt="请发送目标画师id") -async def _(bot: Bot, event: Event, state: dict) -> None: - author_id = state["author_id"] - author_id = re.findall(r"\d+", author_id) - - if len(author_id): - pass - else: - await pixivSearchAuthor.reject("请发送纯阿拉伯数字的画师id") - - await bot.send(event, f"别急!在搜索了!\n将展示画师[{author_id[0]}]的前三项作品") - - URL = f"https://api.imjad.cn/pixiv/v1/?type=member_illust&id={author_id[0]}" - data = {} - - try: - data = json.loads(await aio_get_bytes(URL)) - except: - await pixivSearchAuthor.finish(errorRepo("请求网络失败")) - - d = {} - - for i in range(0, 3): - pid = data["response"][i]["id"] - title = data["response"][i]["title"] - IMG = data["response"][i]["image_urls"]["large"] - IMG = IMG.replace("i.pximg.net", "i.pixiv.cat") - d[i] = [f"{pid}", f"{title}", f"{IMG}"] - - msg = f'[CQ:at,qq={state["user"]}]' - - result = sorted(d.items(), key=lambda x: x[1], reverse=True) - - t = 0 - - for i in result: - t += 1 - msg += "\n————————————\n" - msg += f"({t})\n" - msg += f"Title: {i[1][1]}\n" - msg += f"Pid: {i[1][0]}\n" - msg += f"{i[1][2].replace('https://', '')}" - - await pixivSearchAuthor.finish(msg) - - -plugin_name_2 = "pixiv-rank" -pixivRank = on_command("p站排行榜", - rule=check_banlist() & check_switch(plugin_name_2, True)) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - user = str(event.user_id) - - await bot.send(event, "正在获取P站每日排行榜前三作品") - - URL = "https://api.imjad.cn/pixiv/v1/?type=rank" - data = {} - - try: - data = json.loads(await aio_get_bytes(URL)) - except: - await pixivRank.finish(errorRepo("网络请求失败")) - - d = {} - for i in range(0, 3): - pid = data["response"][0]["works"][i]["work"]["id"] - title = data["response"][0]["works"][i]["work"]["title"] - IMG = data["response"][0]["works"][i]["work"]["image_urls"]["large"] - IMG = IMG.replace("i.pximg.net", "i.pixiv.cat") - d[i] = [f"{pid}", f"{title}", f"{IMG}"] - - msg = f"[CQ:at,qq={user}]" - - result = sorted(d.items(), key=lambda x: x[1], reverse=True) - - t = 0 - - for i in result: - t += 1 - msg += "\n————————————\n" - msg += f"({t})\n" - msg += f"Title: {i[1][1]}\n" - msg += f"Pid: {i[1][0]}\n" - msg += f"{i[1][2].replace('https://', '')}" - - print(msg) - await pixivRank.finish(msg) diff --git a/ATRI/plugins/plugin_rich/__init__.py b/ATRI/plugins/plugin_rich/__init__.py deleted file mode 100644 index 6d2dec8..0000000 --- a/ATRI/plugins/plugin_rich/__init__.py +++ /dev/null @@ -1,141 +0,0 @@ -#!/usr/bin/env python3 -# -*- encoding: utf-8 -*- -''' -@File : __init__.py -@Time : 2020/10/11 14:40:34 -@Author : Kyomotoi -@Contact : [email protected] -@Github : https://github.com/Kyomotoi -@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved. -''' -__author__ = 'kyomotoi' - -import re -import json -import requests - -from nonebot.log import logger -from nonebot.typing import Bot, Event -from nonebot.plugin import on_message - -from ATRI.utils.utils_times import countX -from ATRI.utils.utils_rule import check_banlist -from ATRI.utils.utils_request import request_get -from .data_source import dec - -BILI_REPORT_FORMAT = """[{aid}] Info: -Title: {title} -bid: {bid} -Viev: {view} Like: {like} -Coin: {coin} Share: {share} -Link: -{aid_link} -{bid_link}""" - -bilibiliRich = on_message(rule=check_banlist()) -b_list = [] - - -async def _(bot: Bot, event: Event, state: dict) -> None: - global b_list - user = event.user_id - msg = str(event.message) - - # 防刷屏机制:回复次数达到五次自动忽略下一次 - if countX(b_list, user) == 5: - return - - if "qqdocurl" not in msg: - try: - bv = re.findall(r"(BV\w+)", msg) - except: - return - else: - bvURL = re.findall(r"(........b23...\S+\=)", msg) - - try: - r = requests.get(bvURL[0], stream=True, allow_redirects=True) - except: - logger.waring("Get BV ERROR. (Request ERROR)") - return - - bv = re.findall(r"(BV\w+)", r.url) - - if bv: - aid = str(dec(bv[0])) - ad = 'av' + aid - URL = f'https://api.imjad.cn/bilibili/v2/?aid={aid}' - - try: - res = request_get(URL) - except: - logger.waring("Request ERROR") - return - - data = json.loads(res) - msg = BILI_REPORT_FORMAT.format(title=data["data"]["title"], - view=data["data"]["stat"]["view"], - coin=data["data"]["stat"]["coin"], - share=data["data"]["stat"]["share"], - like=data["data"]["stat"]["like"], - bid=data["data"]["bvid"], - bid_link=data["data"]["short_link"], - aid=ad, - aid_link=f'https://b23.tv/{ad}') - - b_list.append(user) - await bilibiliRich.finish(msg) - - else: - return - - -CLOUDMUSIC_REPORT_FORMAT = """Status: {status} -Song id: {id} -Br: {br} -Download: {url} -MD5: {md5}""" - -cloudmusicRich = on_message(rule=check_banlist()) -c_list = [] - - -async def _(bot: Bot, event: Event, state: dict) -> None: - global c_list - user = event.user_id - msg = str(event.message) - - # 防刷屏机制:回复次数达到五次自动忽略下一次 - if countX(b_list, user) == 5: - return - - if "music.163.com" in msg: - music_id = re.findall(r"song\S+\/|id=\S+\&", msg) - - if music_id: - music_id = str(music_id[0]) - music_id = re.findall(r"-?[1-9]\d*", music_id) - URL = f'https://api.imjad.cn/cloudmusic/?type=song&id={music_id[0]}&br=320000' - - try: - res = request_get(URL) - except: - logger.waring("Request ERROR") - return - - data = json.loads(res) - msg = CLOUDMUSIC_REPORT_FORMAT.format( - status=data["code"], - id=data["data"][0]["id"], - br=data["data"][0]["br"], - url=data["data"][0]["url"], - md5=data["data"][0]["md5"], - ) - - c_list.append(user) - await cloudmusicRich.finish(msg) - - else: - return diff --git a/ATRI/plugins/plugin_rich/data_source.py b/ATRI/plugins/plugin_rich/data_source.py deleted file mode 100644 index 148d64b..0000000 --- a/ATRI/plugins/plugin_rich/data_source.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python3 -# -*- encoding: utf-8 -*- -''' -@File : data_source.py -@Time : 2020/11/21 11:11:37 -@Author : Kyomotoi -@Contact : [email protected] -@Github : https://github.com/Kyomotoi -@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved. -''' -__author__ = 'kyomotoi' - -table = 'fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF' -tr = {} -for i in range(58): - tr[table[i]] = i -s = [11, 10, 3, 8, 4, 6] -xor = 177451812 -add = 8728348608 - - -def dec(x) -> int: - r = 0 - for i in range(6): - r += tr[x[s[i]]] * 58**i - return (r - add) ^ xor - - -def enc(x) -> str: - x = (x ^ xor) + add - r = list('BV1 4 1 7 ') - for i in range(6): - r[s[i]] = table[x // 58**i % 58] - return ''.join(r) diff --git a/ATRI/plugins/plugin_sqlite/__init__.py b/ATRI/plugins/plugin_sqlite/__init__.py deleted file mode 100644 index 45c33da..0000000 --- a/ATRI/plugins/plugin_sqlite/__init__.py +++ /dev/null @@ -1,157 +0,0 @@ -#!/usr/bin/env python3 -# -*- encoding: utf-8 -*- -''' -@File : __init__.py -@Time : 2020/10/25 15:01:29 -@Author : Kyomotoi -@Contact : [email protected] -@Github : https://github.com/Kyomotoi -@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved. -''' -__author__ = 'kyomotoi' - -import os -import json -import sqlite3 -from pathlib import Path -from nonebot.typing import Bot, Event -from aiohttp import client_exceptions -from nonebot.plugin import on_command -from nonebot.permission import SUPERUSER - -from ATRI.utils.utils_error import errorRepo -from ATRI.utils.utils_request import aio_get_bytes - -SetuData = on_command('setu', permission=SUPERUSER) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - msg0 = "-==ATRI Setu Data System==-\n" - msg0 += "Upload:\n" - msg0 += " - setu [type] [pid]\n" - msg0 += " * type: normal, nearR18 r18\n" - msg0 += "Delete:\n" - msg0 += " - setu-delete [pid]" - await SetuData.finish(msg0) - - -UploadSetu = on_command('setu-upload', permission=SUPERUSER) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - msg = str(event.message).strip().split(' ') - - if not msg[0] and not msg[1]: - msg0 = "请检查格式奥~!\n" - msg0 += "setu-upload [type] [pid]\n" - msg0 += "type: normal, nearR18, r18" - await UploadSetu.finish(msg0) - - if msg[0] not in ["noraml", "nearR18", "nearr18", "r18", "R18"]: - msg0 = "请检查类型~!\n" - msg0 += "type: normal, nearR18, r18" - await UploadSetu.finish(msg0) - - s_type = msg[0] - pid = msg[1] - - URL = f'https://api.imjad.cn/pixiv/v1/?type=illust&id={pid}' - info = {} - - try: - info = json.loads(await aio_get_bytes(URL)) - except client_exceptions: - await UploadSetu.finish(errorRepo("网络请求出错")) - - info = info["response"][0] - title = info["title"] - tags = info["tags"] - account = info["user"]["account"] - name = info["user"]["name"] - u_id = info["user"]["id"] - user_link = f'https://www.pixiv.net/users/{u_id}' - IMG = info["iamge_urls"]["large"] - IMG = IMG.replace("i.pximg.net", "i.pixiv.cat") - - data_setu = (f'{pid}', f'{title}', f'{tags}', f'{account}', f'{name}', - f'{u_id}', f'{user_link}', f'{IMG}') - - if s_type == "nearr18": - s_type = "nearR18" - elif s_type == "R18": - s_type = "r18" - else: - pass - - os.makedirs('ATRI/data/data_Sqlite/setu', exist_ok=True) - - if os.path.exists(f'ATRI/data/data_Sqlite/setu/{s_type}.db'): - print('数据文件存在!') - else: - await DeleteSetu.finish("数据库都不在添加🔨!?罢了我现创一个") - con = sqlite3.connect( - Path('.') / 'ATRI' / 'data' / 'data_Sqlite' / 'setu' / - f'{s_type}.db') - cur = con.cursor() - cur.execute( - f'CREATE TABLE {s_type}(pid PID, title TITLE, tags TAGS, account ACCOUNT, name NAME, u_id UID, user_link USERLINK, img IMG, UNIQUE(pid, title, tags, account, name, u_id, user_link, img))' - ) - con.commit() - cur.close() - await bot.send(event, '完成') - - con = sqlite3.connect( - Path('.') / 'ATRI' / 'data' / 'data_Sqlite' / 'setu' / f'{s_type}.db') - cur = con.cursor() - cur.execute( - f'INSERT INTO {s_type}(pid, title, tags, account, name, u_id, user_link, img) VALUES(?, ?, ?, ?, ?, ?, ?, ?)', - data_setu) - con.commit() - cur.close() - - await UploadSetu.finish(f"数据上传完成~!\n涩图库[{s_type}]涩图 +1") - - -DeleteSetu = on_command('setu-delete', permission=SUPERUSER) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - msg = str(event.message).strip().split(' ') - - if not msg[0] and not msg[1]: - msg0 = "请检查格式奥~!\n" - msg0 += "setu-delete [type] [pid]\n" - msg0 += "type: normal, nearR18, r18" - await DeleteSetu.finish(msg0) - - if msg[0] not in ["noraml", "nearR18", "nearr18", "r18", "R18"]: - msg0 = "请检查类型~!\n" - msg0 += "type: normal, nearR18, r18" - await UploadSetu.finish(msg0) - - s_type = msg[0] - pid = msg[1] - - if s_type == "nearr18": - s_type = "nearR18" - elif s_type == "R18": - s_type = "r18" - else: - pass - - if os.path.exists(f'ATRI/data/data_Sqlite/setu/{s_type}.db'): - print('数据文件存在!') - else: - await DeleteSetu.finish("数据库都不在删🔨!?") - - con = sqlite3.connect( - Path('.') / 'ATRI' / 'data' / 'data_Sqlite' / 'setu' / f'{s_type}.db') - cur = con.cursor() - cur.execute(f'DELETE FROM {s_type} WHERE pid = {pid}') - con.commit() - con.close() - - await UploadSetu.finish(f"数据删除完成~!\n涩图库[{s_type}]涩图 -1") diff --git a/ATRI/plugins/plugin_status/__init__.py b/ATRI/plugins/plugin_status/__init__.py deleted file mode 100644 index b34aeee..0000000 --- a/ATRI/plugins/plugin_status/__init__.py +++ /dev/null @@ -1,107 +0,0 @@ -#!/usr/bin/env python3 -# -*- encoding: utf-8 -*- -''' -@File : __init__.py -@Time : 2020/10/11 14:40:55 -@Author : Kyomotoi -@Contact : [email protected] -@Github : https://github.com/Kyomotoi -@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved. -''' -__author__ = 'kyomotoi' - -import psutil -import sqlite3 -from pathlib import Path -from random import choice - -from nonebot.plugin import on_command -from nonebot.typing import Bot, Event -from nonebot.permission import SUPERUSER - -from ATRI.utils.utils_error import errorRepo -from ATRI.utils.utils_rule import check_banlist - -# States parameter: -# ├info -# └sqlite -# * DEMO: status info -status_info = on_command('/status', rule=check_banlist()) - - -@status_info.handle() -async def _(bot: Bot, event: Event, state: dict) -> None: - msg = str(event.message).strip() - - if not msg: - await status_info.finish("请查看文档获取帮助(") - - if msg == "info": - try: - cpu = psutil.cpu_percent(interval=1) - memory = psutil.virtual_memory().percent - disk = psutil.disk_usage('/').percent - inteSENT = psutil.net_io_counters().bytes_sent # type: ignore - inteRECV = psutil.net_io_counters().bytes_recv # type: ignore - except: - await status_info.finish(errorRepo("读取系统状态失败")) - - status = "アトリは、高性能ですから!" - - if cpu > 80: # type: ignore - status = 'ATRI感觉头有点晕...' - if memory > 80: # type: ignore - status = 'ATRI感觉有点头晕并且有点累...' - elif disk > 80: # type: ignore - status = 'ATRI感觉身体要被塞满了...' - - msg0 = "ATRI status-info:\n" - msg0 += f"* CPU: {cpu}%\n" # type: ignore - msg0 += f"* MEM: {memory}%\n" # type: ignore - msg0 += f"* Disk {disk}%\n" # type: ignore - msg0 += f"* BytesSENT: {inteSENT}\n" # type: ignore - msg0 += f"* BytesRECV: {inteRECV}\n" # type: ignore - msg0 += status - - await status_info.finish(msg0) - - elif msg == "sqlite": - con = sqlite3.connect( - Path('.') / 'ATRI' / 'data' / 'data_Sqlite' / 'setu' / - 'normal.db') # setu-normal - cur = con.cursor() - cur.execute("select * from normal") - data_normal = len(cur.fetchall()) - con.close() - - con = sqlite3.connect( - Path('.') / 'ATRI' / 'data' / 'data_Sqlite' / 'setu' / - 'nearR18.db') # setu-nearR18 - cur = con.cursor() - cur.execute("select * from nearR18") - data_nearR18 = len(cur.fetchall()) - con.close() - - con = sqlite3.connect( - Path('.') / 'ATRI' / 'data' / 'data_Sqlite' / 'setu' / - 'r18.db') # setu-r18 - cur = con.cursor() - cur.execute("select * from r18") - data_r18 = len(cur.fetchall()) - con.close() - - msg0 = "ATRI status-sqlite:\n" - msg0 += "Setu:\n" - msg0 += f"├normal: {data_normal}\n" - msg0 += f"├nearR18: {data_nearR18}\n" - msg0 += f"└R18: {data_r18}" - - await status_info.finish(msg0) - - -ping = on_command('/ping', permission=SUPERUSER) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - await ping.finish(choice(["I'm fine.", "啪!"])) diff --git a/ATRI/plugins/plugin_test/__init__.py b/ATRI/plugins/plugin_test/__init__.py deleted file mode 100644 index 573cf8b..0000000 --- a/ATRI/plugins/plugin_test/__init__.py +++ /dev/null @@ -1,52 +0,0 @@ -# !/usr/bin/env python3 -# -*- encoding: utf-8 -*- -''' -@File : __init__.py -@Time : 2020/10/11 14:35:26 -@Author : Kyomotoi -@Contact : [email protected] -@Github : https://github.com/Kyomotoi -@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved. -@Desc : None -''' -__author__ = 'kyomotoi' - -import inspect -import os -from pathlib import Path -from random import sample - -import nonebot -from nonebot.typing import Bot, Event -from nonebot.plugin import on_command -from nonebot.permission import SUPERUSER - -# 此目录下均为功能测试! - -testRecord = on_command('测试语音', permission=SUPERUSER) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - await testRecord.finish( - f"[CQ:record,file=file:///{os.path.abspath(Path('.') / 'ATRI' / 'plugins' / 'plugin_test' / 'test.mp3')}]" - ) - - -testGroupList = on_command('获取群列表', permission=SUPERUSER) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - group_list = await bot.get_group_list() - group = sample(group_list, 1) - print(group[0]['group_id'], type(group[0]['group_id'])) - - -testSendFormat = on_command('测试发送', permission=SUPERUSER) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - msg = ("test0\n" "test1\n" "test2") - await bot.send(event, msg) diff --git a/ATRI/plugins/plugin_test/test.mp3 b/ATRI/plugins/plugin_test/test.mp3 Binary files differdeleted file mode 100644 index 774cf5d..0000000 --- a/ATRI/plugins/plugin_test/test.mp3 +++ /dev/null diff --git a/ATRI/plugins/plugin_utils/__init__.py b/ATRI/plugins/plugin_utils/__init__.py deleted file mode 100644 index 4181e30..0000000 --- a/ATRI/plugins/plugin_utils/__init__.py +++ /dev/null @@ -1,156 +0,0 @@ -#!/usr/bin/env python3 -# -*- encoding: utf-8 -*- -''' -@File : __init__.py -@Time : 2020/11/07 14:20:08 -@Author : Kyomotoi -@Contact : [email protected] -@Github : https://github.com/Kyomotoi -@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved. -''' -__author__ = 'kyomotoi' - -import re -import random -from time import strftime -from datetime import datetime, timedelta - -from nonebot.plugin import on_command -from nonebot.typing import Bot, Event - -from ATRI.utils.utils_error import errorRepo -from ATRI.utils.utils_rule import check_banlist, check_switch -from .data_source import Generate, Genshin, Roll, RCNB - -plugin_name_0 = "one-key-adult" -generateID = on_command("我要转大人,一天打25小时游戏", - aliases={'虚拟身份', '一键成年', '登dua郎'}, - rule=check_banlist() - & check_switch(plugin_name_0, True)) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - NAME, AREA = Generate().infoID() - - BIRTH_BEGIN = datetime(*[1980, 10, 10]) # type: ignore - BIRTH_END = datetime(*[2002, 10, 10]) # type: ignore - - id_card_area = int(random.choice(list(AREA.keys()))) - id_card_area_name = AREA[str(id_card_area)] - id_card_year_old = timedelta( - days=random.randint(0, (BIRTH_END - BIRTH_BEGIN).days) + 1) - id_card_birth_day = strftime("%Y%m%d", - (BIRTH_BEGIN + id_card_year_old).timetuple()) - id_card_sex = random.choice([0, 1]) - id_card_name = random.choice(NAME[{0: "female", 1: "male"}[id_card_sex]]) - id_card_id = Generate().numberID(id_card_area, id_card_sex, - id_card_birth_day) # type: ignore - - msg0 = "恭喜,你已经成大人了!\n" - msg0 += f"NumberID: {id_card_id}\n" - msg0 += f"Gender: {'男' if id_card_sex == 1 else '女'}\n" - msg0 += f"Name: {id_card_name} || Address: {id_card_area_name}\n" - msg0 += "注: 1、以上信息根据国家公开标准生成,非真实信息。\n" - msg0 += " 2、不适用于网易和腾讯。" - - await generateID.finish(msg0) - - -rollD = on_command("/roll", rule=check_banlist()) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - args = str(event.message).strip() - - if args: - state['resu'] = args - - [email protected]("resu", prompt="roll 参数不能为空~!\ndemo:1d10 或 2d10+2d10") -async def _(bot: Bot, event: Event, state: dict) -> None: - resu = state['resu'] - match = re.match(r'^([\dd+\s]+?)$', resu) - - if not match: - await rollD.finish("请输入正确的参数!!\ndemo:1d10 或 2d10+2d10") - - await rollD.finish(Roll().roll_dice(resu)) - - -plugin_name_1 = 'genshin-search' -genshinInfo = on_command('/genshin', - rule=check_banlist() - & check_switch(plugin_name_1, True)) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - args = str(event.message).strip() - - if args: - state['uid'] = args - - [email protected]('uid', prompt='请告诉咱需要查询的UID,暂时只支持国服嗷~(') -async def _(bot: Bot, event: Event, state: dict) -> None: - uid = str(state['uid']) - - if (len(uid) == 9): - await bot.send(event, '别急,在搜索了!') - uid_info = '' - - try: - uid_info = Genshin().JsonAnalysis(Genshin().GetInfo(uid)) - except: - await genshinInfo.finish( - errorRepo("数据请求错误,原因可能为ID输入错误或不存在\n暂时只支持国服查询(")) - - msg0 = f'{uid} Genshin Info:\n' - msg0 += uid_info - print(uid_info) - await genshinInfo.finish(msg0) - - else: - await genshinInfo.finish('UID检查未通过,请确保此ID为9位数或者是否为国服ID~!') - - -rcnb = RCNB() - -rcnbEncode = on_command('RC一下', - aliases={'rc一下', '啊西一下', '阿西一下'}, - rule=check_banlist()) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - msg = str(event.message).strip() - - if msg: - state['msg'] = msg - - [email protected]('msg', prompt='请告诉咱需要RC一下的字符~!') -async def _(bot: Bot, event: Event, state: dict) -> None: - msg = state['msg'] - await rcnbEncode.finish(rcnb._encode(msg)) - - -rcnbDecode = on_command('一下RC', - aliases={'一下rc', '一下啊西', '一下阿西'}, - rule=check_banlist()) - - -async def _(bot: Bot, event: Event, state: dict) -> None: - msg = str(event.message).strip() - - if msg: - state['msg'] = msg - - [email protected]('msg', prompt='请告诉咱需要一下RC的字符~!') -async def _(bot: Bot, event: Event, state: dict) -> None: - msg = state['msg'] - await rcnbDecode.finish(rcnb._decode(msg)) diff --git a/ATRI/plugins/plugin_utils/data_source.py b/ATRI/plugins/plugin_utils/data_source.py deleted file mode 100644 index 116b977..0000000 --- a/ATRI/plugins/plugin_utils/data_source.py +++ /dev/null @@ -1,333 +0,0 @@ -#!/usr/bin/env python3 -# -*- encoding: utf-8 -*- -''' -@File : data_source.py -@Time : 2020/11/21 11:13:42 -@Author : Kyomotoi -@Contact : [email protected] -@Github : https://github.com/Kyomotoi -@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved. -''' -__author__ = 'kyomotoi' - -import re -import os -import time -import json -import string -import random -import hashlib -import requests -from math import floor -from pathlib import Path -from zipfile import PyZipFile -from typing import Tuple, Dict, List, Union - - -class Generate: - """虚拟身份证部分""" - GENERATE_DATA_PATH = Path( - '.') / 'ATRI' / 'plugins' / 'plugin_utils' / 'main.bin' - - def infoID(self) -> Tuple[Dict[str, List[str]], Dict[str, str]]: - with PyZipFile(os.path.abspath(self.GENERATE_DATA_PATH), - "r") as zipFile: - with zipFile.open("name.json", "r") as f: - name = json.loads(f.read().decode()) - with zipFile.open("area.json", "r") as f: - area = json.loads(f.read().decode()) - return name, area - - def numberID(self, area: int, sex: int, birth: int) -> str: - def checkSum(fullCode: str) -> int or str: - assert len(fullCode) == 17 - checkSum = sum([((1 << (17 - i)) % 11) * int(fullCode[i]) - for i in range(0, 17)]) - checkDigit = (12 - (checkSum % 11)) % 11 - if checkDigit < 10: - return checkDigit - else: - return "X" # type: ignore - - orderCode = str(random.randint(10, 99)) - sexCode = str(random.randrange(sex, 10, step=2)) - fullCode = str(area) + str(birth) + str(orderCode) + str(sexCode) - fullCode += str(checkSum(fullCode)) - return fullCode - - -class Genshin: - """原神部分""" - def md5(self, text: str) -> str: - """text 转 md5""" - md5 = hashlib.md5() - md5.update(text.encode()) - return md5.hexdigest() - - def DSGet(self) -> str: - mhyVersion = "2.1.0" - n = self.md5(mhyVersion) - i = str(int(time.time())) - r = ''.join(random.sample(string.ascii_lowercase + string.digits, 6)) - c = self.md5("salt=" + n + "&t=" + i + "&r=" + r) - return i + "," + r + "," + c - - def GetInfo(self, uid: str) -> str: - """请求API""" - req = requests.get( - url= - f"https://api-takumi.mihoyo.com/game_record/genshin/api/index?server=cn_gf01&role_id={uid}", - headers={ - 'Accept': 'application/json, text/plain, */*', - 'DS': self.DSGet(), - 'Origin': 'https://webstatic.mihoyo.com', - 'x-rpc-app_version': '2.1.0', - 'User-Agent': - 'Mozilla/5.0 (Linux; Android 9; Unspecified Device) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/39.0.0.0 Mobile Safari/537.36 miHoYoBBS/2.2.0', - 'x-rpc-client_type': '4', - 'Referer': - 'https://webstatic.mihoyo.com/app/community-game-records/index.html?v=6', - 'Accept-Encoding': 'gzip, deflate', - 'Accept-Language': 'zh-CN,en-US;q=0.8', - 'X-Requested-With': 'com.mihoyo.hyperion' - }) - return req.text - - def JsonAnalysis(self, JsonText) -> str: - """解析数据""" - data = json.loads(JsonText) - - Character_Info = "Roles:\n" - Character_List = [] - Character_List = data["data"]["avatars"] - for i in Character_List: - if (i["element"] == "None"): - Character_Type = "无属性" - elif (i["element"] == "Anemo"): - Character_Type = "风属性" - elif (i["element"] == "Pyro"): - Character_Type = "火属性" - elif (i["element"] == "Geo"): - Character_Type = "岩属性" - elif (i["element"] == "Electro"): - Character_Type = "雷属性" - elif (i["element"] == "Cryo"): - Character_Type = "冰属性" - elif (i["element"] == "Hydro"): - Character_Type = "水属性" - else: - Character_Type = "草属性" - - if (i["name"] == "旅行者"): - if (i["image"].find("UI_AvatarIcon_PlayerGirl") != -1): - TempText = f'* {i["name"]}:\n' - TempText += f' - [萤——妹妹] {i["level"]}级 {Character_Type}\n' - - elif (i["image"].find("UI_AvatarIcon_PlayerBoy") != -1): - TempText = f'* {i["name"]}:\n' - TempText += f' - [空——哥哥] {i["level"]}级 {Character_Type}\n' - - else: - TempText = f'* {i["name"]}:\n' - TempText += f' - [性别判断失败] {i["level"]}级 {Character_Type}\n' - else: - TempText = f'* {i["name"]} {i["rarity"]}★角色:\n' - TempText += f' - {i["level"]}级 好感度({i["fetter"]})级 {Character_Type}\n' - - Character_Info = Character_Info + TempText - - a1 = data["data"]["stats"]["spiral_abyss"] - - Account_Info = 'Account Info:\n' - Account_Info += f'- 活跃天数:{data["data"]["stats"]["active_day_number"]} 天\n' - Account_Info += f'- 达成成就:{data["data"]["stats"]["achievement_number"]} 个\n' - Account_Info += f'- 获得角色:{data["data"]["stats"]["avatar_number"]}个\n' - Account_Info += f'- 深渊螺旋:{"没打" if (data["data"]["stats"]["spiral_abyss"] == "-") else f"打到了{a1}"}\n' - Account_Info += f'* 收集:\n' - Account_Info += f' - 风神瞳{data["data"]["stats"]["anemoculus_number"]}个 岩神瞳{data["data"]["stats"]["geoculus_number"]}个\n' - Account_Info += f'* 解锁:\n' - Account_Info += f' - 传送点{data["data"]["stats"]["way_point_number"]}个 秘境{data["data"]["stats"]["domain_number"]}个\n' - Account_Info += f'* 共开启宝箱:\n' - Account_Info += f' - 普通:{data["data"]["stats"]["common_chest_number"]}个 精致:{data["data"]["stats"]["exquisite_chest_number"]}个\n' - Account_Info += f' - 珍贵:{data["data"]["stats"]["luxurious_chest_number"]}个 华丽:{data["data"]["stats"]["precious_chest_number"]}个' - - return Character_Info + "\r\n" + Account_Info - - -class Roll: - """骰娘部分""" - def roll_dice(self, par: str) -> str: - """掷骰子""" - result = 0 - proc = '' - proc_list = [] - p = par.split('+') - - # 计算每个单独的roll - for i in p: - args = re.findall(r"(\d{0,10})(?:(d)(\d{1,10}))", i) - args = list(args[0]) - - if not args[0]: - args[0] = 1 - - if int(args[0]) >= 5000 or int(args[2]) >= 5000: - return '阿..好大...' - - for a in range(1, int(args[0]) + 1): - rd = random.randint(1, int(args[2])) - result = result + rd - - if len(proc_list) <= 10: - proc_list.append(rd) - - if len(proc_list) <= 10: - proc += "+".join(map(str, proc_list)) - - elif len(proc_list) >= 10: - proc += '太长了不展示了就酱' - - else: - proc += str(result) - - result = f"{par}=({proc})={result}" - - return str(result) - - -class RCNB(): - """R C N B""" - cr = 'rRŔŕŖŗŘřƦȐȑȒȓɌɍ' - cc = 'cCĆćĈĉĊċČčƇƈÇȻȼ' - cn = 'nNŃńŅņŇňƝƞÑǸǹȠȵ' - cb = 'bBƀƁƃƄƅßÞþ' - - sr = len(cr) - sc = len(cc) - sn = len(cn) - sb = len(cb) - src = sr * sc - snb = sn * sb - scnb = sc * snb - - def _div(self, a: int, b: int) -> int: - return floor(a / b) - - def _encodeByte(self, i) -> Union[str, None]: - if i > 0xFF: - raise ValueError('ERROR! rc/nb overflow') - - if i > 0x7F: - i = i & 0x7F - return self.cn[self._div(i, self.sb) + int(self.cb[i % self.sb])] - - return self.cr[self._div(i, self.sc) + int(self.cc[i % self.sc])] - - def _encodeShort(self, i) -> str: - if i > 0xFFFF: - raise ValueError('ERROR! rcnb overflow') - - reverse = False - if i > 0x7FFF: - reverse = True - i = i & 0x7FFF - - char = [ - self._div(i, self.scnb), - self._div(i % self.scnb, self.snb), - self._div(i % self.snb, self.sb), i % self.sb - ] - char = [ - self.cr[char[0]], self.cc[char[1]], self.cn[char[2]], - self.cb[char[3]] - ] - - if reverse: - return char[2] + char[3] + char[0] + char[1] - - return ''.join(char) - - def _decodeByte(self, c) -> int: - nb = False - idx = [self.cr.index(c[0]), self.cc.index(c[1])] - if idx[0] < 0 or idx[1] < 0: - idx = [self.cn.index(c[0]), self.cb.index(c[1])] - nb = True - raise ValueError('ERROR! rc/nb overflow') - - result = idx[0] * self.sb + idx[1] if nb else idx[0] * self.sc + idx[1] - if result > 0x7F: - raise ValueError('ERROR! rc/nb overflow') - - return result | 0x80 if nb else 0 - - def _decodeShort(self, c) -> int: - reverse = c[0] not in self.cr - if not reverse: - idx = [ - self.cr.index(c[0]), - self.cc.index(c[1]), - self.cn.index(c[2]), - self.cb.index(c[3]) - ] - else: - idx = [ - self.cr.index(c[2]), - self.cc.index(c[3]), - self.cn.index(c[0]), - self.cb.index(c[1]) - ] - - if idx[0] < 0 or idx[1] < 0 or idx[2] < 0 or idx[3] < 0: - raise ValueError('ERROR! not rcnb') - - result = idx[0] * self.scnb + idx[1] * self.snb + idx[ - 2] * self.sb + idx[3] - if result > 0x7FFF: - raise ValueError('ERROR! rcnb overflow') - - result |= 0x8000 if reverse else 0 - return result - - def _encodeBytes(self, b) -> str: - result = [] - for i in range(0, (len(b) >> 1)): - result.append(self._encodeShort((b[i * 2] << 8 | b[i * 2 + 1]))) - - if len(b) & 1 == 1: - result.append(self._encodeByte(b[-1])) - - return ''.join(result) - - def _encode(self, s: str, encoding: str = 'utf-8'): - if not isinstance(s, str): - raise ValueError('Please enter str instead of other') - - return self._encodeBytes(s.encode(encoding)) - - def _decodeBytes(self, s: str): - if not isinstance(s, str): - raise ValueError('Please enter str instead of other') - - if len(s) & 1: - raise ValueError('ERROR length') - - result = [] - for i in range(0, (len(s) >> 2)): - result.append(bytes([self._decodeShort(s[i * 4:i * 4 + 4]) >> 8])) - result.append(bytes([self._decodeShort(s[i * 4:i * 4 + 4]) & 0xFF - ])) - - if (len(s) & 2) == 2: - result.append(bytes([self._decodeByte(s[-2:])])) - - return b''.join(result) - - def _decode(self, s: str, encoding: str = 'utf-8') -> str: - if not isinstance(s, str): - raise ValueError('Please enter str instead of other') - - try: - return self._decodeBytes(s).decode(encoding) - except UnicodeDecodeError: - raise ValueError('Decoding failed') diff --git a/ATRI/plugins/plugin_utils/main.bin b/ATRI/plugins/plugin_utils/main.bin Binary files differdeleted file mode 100644 index 6e74a60..0000000 --- a/ATRI/plugins/plugin_utils/main.bin +++ /dev/null |