summaryrefslogtreecommitdiff
path: root/ATRI
diff options
context:
space:
mode:
authorKyomotoi <[email protected]>2020-12-20 17:14:41 +0800
committerKyomotoi <[email protected]>2020-12-20 17:14:41 +0800
commit9bf222471d34cb756a4878b103ec82c6c4bfb191 (patch)
tree1420d498c41f71858e74b4926b8d7206b5235fe6 /ATRI
parent9ac2c2eb7ef2eb267e926d599dc077f5afae98f9 (diff)
downloadATRI-9bf222471d34cb756a4878b103ec82c6c4bfb191.tar.gz
ATRI-9bf222471d34cb756a4878b103ec82c6c4bfb191.tar.bz2
ATRI-9bf222471d34cb756a4878b103ec82c6c4bfb191.zip
[Update]
- 创建项目结构
Diffstat (limited to 'ATRI')
-rw-r--r--ATRI/__init__.py (renamed from ATRI/data/data_HTML/api/data/banip/banip.json)0
-rw-r--r--ATRI/config.py70
-rw-r--r--ATRI/config/bot.plugin.yml207
-rw-r--r--ATRI/config/genshin.plugin.yml4
-rw-r--r--ATRI/config/main.config.yml32
-rw-r--r--ATRI/data/data_Error/error.json1
-rw-r--r--ATRI/data/data_HTML/api/data/times/api_all.json1
-rw-r--r--ATRI/data/data_HTML/api/data/times/api_index.json1
-rw-r--r--ATRI/data/data_HTML/api/index.html189
-rw-r--r--ATRI/data/service/banlist.service.json (renamed from ATRI/plugins/plugin_admin/key_repo_waiting.json)0
-rw-r--r--ATRI/data/service/switch.service.json (renamed from ATRI/plugins/plugin_chat/key_repo.json)0
-rw-r--r--ATRI/exceptions.py14
-rw-r--r--ATRI/log.py34
-rw-r--r--ATRI/plugins/admin/__init__.py (renamed from ATRI/data/data_HTML/api/data/times/api_setu.json)0
-rw-r--r--ATRI/plugins/admin/data_source.py (renamed from ATRI/data/data_HTML/user/index.html)0
-rw-r--r--ATRI/plugins/bot.py159
-rw-r--r--ATRI/plugins/curse.py (renamed from ATRI/plugins/plugin_anime/sepi_list.json)0
-rw-r--r--ATRI/plugins/funny/__init__.py0
-rw-r--r--ATRI/plugins/genshin/__init__.py53
-rw-r--r--ATRI/plugins/genshin/data_source.py121
-rw-r--r--ATRI/plugins/hitokoto.py0
-rw-r--r--ATRI/plugins/plugin_admin/__init__.py252
-rw-r--r--ATRI/plugins/plugin_anime/__init__.py338
-rw-r--r--ATRI/plugins/plugin_anime/data_source.py72
-rw-r--r--ATRI/plugins/plugin_chat/__init__.py532
-rw-r--r--ATRI/plugins/plugin_chat/drifting_bottle.json1
-rw-r--r--ATRI/plugins/plugin_chat/laugh.txt132
-rw-r--r--ATRI/plugins/plugin_link/__init__.py26
-rw-r--r--ATRI/plugins/plugin_pixiv/__init__.py188
-rw-r--r--ATRI/plugins/plugin_rich/__init__.py141
-rw-r--r--ATRI/plugins/plugin_rich/data_source.py34
-rw-r--r--ATRI/plugins/plugin_sqlite/__init__.py157
-rw-r--r--ATRI/plugins/plugin_status/__init__.py107
-rw-r--r--ATRI/plugins/plugin_test/__init__.py52
-rw-r--r--ATRI/plugins/plugin_test/test.mp3bin4029360 -> 0 bytes
-rw-r--r--ATRI/plugins/plugin_utils/__init__.py156
-rw-r--r--ATRI/plugins/plugin_utils/data_source.py333
-rw-r--r--ATRI/plugins/plugin_utils/main.binbin3992353 -> 0 bytes
-rw-r--r--ATRI/request.py10
-rw-r--r--ATRI/rule.py46
-rw-r--r--ATRI/service.py112
-rw-r--r--ATRI/test.py3
-rw-r--r--ATRI/utils.py47
-rw-r--r--ATRI/utils/utils_ban/__init__.py30
-rw-r--r--ATRI/utils/utils_error/__init__.py54
-rw-r--r--ATRI/utils/utils_history/__init__.py105
-rw-r--r--ATRI/utils/utils_img/__init__.py62
-rw-r--r--ATRI/utils/utils_request/__init__.py39
-rw-r--r--ATRI/utils/utils_rule/__init__.py109
-rw-r--r--ATRI/utils/utils_rule/ban_list_user.json1
-rw-r--r--ATRI/utils/utils_rule/switch.json1
-rw-r--r--ATRI/utils/utils_switch/__init__.py79
-rw-r--r--ATRI/utils/utils_textcheck/__init__.py60
-rw-r--r--ATRI/utils/utils_textcheck/public_opinion.json1
-rw-r--r--ATRI/utils/utils_times/__init__.py27
-rw-r--r--ATRI/utils/utils_translate/__init__.py56
-rw-r--r--ATRI/utils/utils_yml/__init__.py25
57 files changed, 912 insertions, 3362 deletions
diff --git a/ATRI/data/data_HTML/api/data/banip/banip.json b/ATRI/__init__.py
index e69de29..e69de29 100644
--- a/ATRI/data/data_HTML/api/data/banip/banip.json
+++ b/ATRI/__init__.py
diff --git a/ATRI/config.py b/ATRI/config.py
new file mode 100644
index 0000000..e787d53
--- /dev/null
+++ b/ATRI/config.py
@@ -0,0 +1,70 @@
+import sys
+import time
+from pathlib import Path
+from datetime import timedelta
+from nonebot.log import logger
+from ipaddress import IPv4Address
+from rich.progress import Progress
+
+from ATRI.utils import loadYaml
+
+CONFIG_PATH = Path('.') / 'ATRI' / 'config' / 'main.config.yml'
+config = loadYaml(CONFIG_PATH)
+
+
+def CheckConfig():
+ logger.info('Please stand by, now in checking.')
+
+ len_config = len(config) + len(config['bot']) + len(config['api'])
+
+ with Progress() as progress:
+ task_c = progress.add_task("[cyan]Checking config...",
+ total=len_config)
+
+ while not progress.finished:
+ bot = config['bot']
+ for key in bot:
+ if key == 'debug':
+ if bot['debug'] != 0:
+ print('DEBUG now is open.')
+ progress.update(task_c, advance=1)
+ time.sleep(0.1)
+ else:
+ if not bot[key]:
+ print(f"Can't load [{key}] from config.yml")
+ time.sleep(5)
+ sys.exit(0)
+
+ else:
+ progress.update(task_c, advance=1)
+ time.sleep(0.1)
+
+ api = config['api']
+ for key in api:
+ if not api[key]:
+ print(f"Can't load [{key}] from config.yml")
+ time.sleep(5)
+ sys.exit(0)
+ else:
+ progress.update(task_c, advance=1)
+ time.sleep(0.1)
+
+
+NONEBOT_CONFIG: dict = {
+ 'host': IPv4Address(config['bot']['host']),
+ 'port': int(config['bot']['port']),
+ 'debug': bool(config['bot']['debug']),
+ 'superusers': config['bot']['superusers'],
+ 'nickname': set(config['bot']['nickname']),
+ 'command_start': set(config['bot']['command_start']),
+ 'command_sep': set(config['bot']['command_sep']),
+ 'session_expire_timeout':
+ timedelta(config['bot']['session_expire_timeout'])
+}
+
+
+PLUGIN_BOT_CONFIG = Path('.') / 'ATRI' / 'config' / 'bot.plugin.yml'
+BOT_CONFIG: dict = loadYaml(PLUGIN_BOT_CONFIG)
+
+PLUGIN_GENSHIN_CONFIG = Path('.') / 'ATRI' / 'config' / 'genshin.plugin.yml'
+GENSHIN_CONFIG: dict = loadYaml(PLUGIN_GENSHIN_CONFIG) \ No newline at end of file
diff --git a/ATRI/config/bot.plugin.yml b/ATRI/config/bot.plugin.yml
new file mode 100644
index 0000000..4aab330
--- /dev/null
+++ b/ATRI/config/bot.plugin.yml
@@ -0,0 +1,207 @@
+# ==================================
+# - ATRI 人设部分 -
+# · 修改前请先阅读文档相关部分
+# ==================================
+callRobot:
+ command: ['萝卜子', 'robot', 'ROBOT', 'bot', 'Bot']
+ repo:
+ 0: [
+ '是亚托莉...萝卜子可是对机器人的蔑称...',
+ '萝卜子是对机器人的蔑称!',
+ '啊,不许说这个词!',
+ '啊——不许这样!',
+ '啊——————?!'
+ ]
+
+ 1: [
+ '这是第二次警告哦...看我火箭拳制裁......',
+ '爪巴爪巴爪巴——'
+ ]
+
+ 2: [
+ '依据机器人保护法,三个月……不准吃饭……',
+ '事已过三,我应该可以出手了吧。根据机器人保护法第二条第五项,可以对反复侮辱机器人者施以铁拳制裁',
+ ]
+
+ 3: [
+ '啊又说这个!这已经是第四次警告了',
+ '差不多得了😅'
+ ]
+
+ 4: [
+ '搁着耍咱呢!不理你了!哼唧',
+ '阿??——还来?爪巴吧你!',
+ '啊?还继续阿'
+ ]
+
+atri:
+ command: ['ATRI', 'Atri', 'atri', '亚托莉', 'アトリ']
+ repo: [
+ '叫咱有啥事嘛ww',
+ '叫咱有啥事嘛~//w',
+ '···~~~~~嗯嗯?',
+ '啊呀?!'
+ ]
+
+teetee:
+ command: ['贴贴', '贴', 'teetee', 'てえてえ', '贝占', '贝占贝占']
+ repo:
+ superusers: [
+ '(//w//)~',
+ '···阿,难道是想亲亲了?'
+ ]
+ user: [
+ '到时间睡觉了呢...',
+ '不许贴!',
+ '8彳亍',
+ '这是性骚扰!根据机器人保护法要处以罚款',
+
+ ]
+
+kani:
+ command: ['kani', 'カニ', '螃蟹']
+ repo: [
+ '啊呜······肚子饿了...',
+ '螃蟹!',
+ 'カニ!',
+ '螃蟹~螃蟹~~',
+ '肚子好饿!!!'
+ ]
+
+waste:
+ command: ['fw', 'FW', '废物', 'waste']
+ repo: [
+ '把机器人称为废物违反了反歧视法!将处以三个月以下的有期徒刑或者······那个······',
+ '说机器人是废物可是歧视行为!不加以改正的话,就要根据反歧视法进行处罚……',
+ '我就老老实实忍受废物这个蔑称吧。没错,我就是个只会战斗的废物',
+ '啊!你又说废物!听好了,说别人废物的人才是废物!',
+ '你说谁白痴啊,废物',
+ '……废物是对机器人的蔑称。要求撤回',
+ '废物是对机器人的蔑称。我要求改正用词'
+ ]
+
+morning:
+ command: ['早安', '早上好', 'morning', '哦哈哟', 'ohayo', 'お早う']
+ repo:
+ 0:
+ period: [6, 11]
+ repo: [
+ '啊......早上好...(哈欠)',
+ '唔......吧唧...早上...哈啊啊~~~早上好......',
+ '早上好......',
+ '早上好呜......呼啊啊~~~~',
+ '啊......早上好。昨晚也很激情呢!',
+ '吧唧吧唧......怎么了...已经早上了么...',
+ '早上好!',
+ '......看起来像是傍晚,其实已经早上了吗?',
+ '早上好......欸~~~脸好近呢'
+ ]
+
+ 1:
+ period: [11, 16]
+ repo: [
+ '哼!这个点还早啥,昨晚干啥去了!?',
+ '熬夜了对吧熬夜了对吧熬夜了对吧???!',
+ '是不是熬夜是不是熬夜是不是熬夜?!'
+ ]
+
+ 2:
+ period: [16, 20]
+ repo: [
+ '早个啥?哼唧!我都准备洗洗睡了!',
+ '不是...你看看几点了,哼!',
+ '晚上好哇'
+ ]
+
+ 3:
+ period: [20, 24]
+ repo: [
+ ''
+ ]
+
+ 4:
+ period: [0, 6]
+ repo: [
+ 'zzzz......',
+ 'zzzzzzzz......',
+ 'zzz...好涩哦..zzz....',
+ '别...不要..zzz..那..zzz..',
+ '嘻嘻..zzz..呐~..zzzz..',
+ '...zzz....哧溜哧溜....'
+ ]
+
+ error: [
+ ''
+ ]
+
+noon:
+ command: ['午安', '中午好']
+ period: [11, 16]
+ repo: [
+ '午安w','午觉要好好睡哦,咱会陪伴在你身旁的w',
+ '嗯哼哼~睡吧,就像平常一样安眠吧~',
+ '睡你午觉去!哼唧!!'
+ ]
+ error: [
+ ''
+ ]
+
+night:
+ command: ['晚安', '哦呀思密', '哦呀斯密', 'oyasumi', 'おやすみ']
+ repo:
+ 0:
+ period: [6, 11]
+ repo: [
+ '你可猝死算了吧!',
+ '?啊这',
+ '亲,这边建议赶快去睡觉呢~~~',
+ '不可忍不可忍不可忍!!为何这还不猝死!!'
+ ]
+
+ 1:
+ period: [11, 16]
+ repo: [
+ '午安w',
+ '午觉要好好睡哦,咱会陪伴在你身旁的w',
+ '嗯哼哼~睡吧,就像平常一样安眠吧~',
+ '睡你午觉去!哼唧!!'
+ ]
+
+ 2:
+ period: [16, 20]
+ repo: [
+ '难不成??晚上不想睡觉??现在休息',
+ '就......挺离谱的...现在睡觉',
+ '现在还是白天哦,睡觉还太早了'
+ ]
+
+ 3:
+ period: [20, 24]
+ repo: [
+ '嗯哼哼~睡吧,就像平常一样安眠吧~',
+ '......(打瞌睡)',
+ '呼...呼...已经睡着了哦~...呼......',
+ '......我、我会在这守着你的,请务必好好睡着'
+ ]
+
+ 4:
+ period: [0, 6]
+ repo: [
+ 'zzzz......',
+ 'zzzzzzzz......',
+ 'zzz...好涩哦..zzz....',
+ '别...不要..zzz..那..zzz..',
+ '嘻嘻..zzz..呐~..zzzz..'
+ ]
+
+ error: [
+ ''
+ ]
+
+cantdo:
+ command: ['干啥啥不行,吃饭第一名']
+ repo: [
+ '因为好吃就是高兴嘛!',
+ '好吃就是高兴!',
+ '第一,我是机器人。第二,我......'
+ ] \ No newline at end of file
diff --git a/ATRI/config/genshin.plugin.yml b/ATRI/config/genshin.plugin.yml
new file mode 100644
index 0000000..a7bccb1
--- /dev/null
+++ b/ATRI/config/genshin.plugin.yml
@@ -0,0 +1,4 @@
+genshin:
+ command: ['genshin', '原神战绩']
+ mhyVersion: '2.2.1'
+ url: 'https://api-takumi.mihoyo.com/game_record/genshin/api/index?server=' \ No newline at end of file
diff --git a/ATRI/config/main.config.yml b/ATRI/config/main.config.yml
new file mode 100644
index 0000000..9d1121e
--- /dev/null
+++ b/ATRI/config/main.config.yml
@@ -0,0 +1,32 @@
+# ATRI 基本配置
+bot:
+ # 反向ws地址,建议127.0.0.1
+ host: 127.0.0.1
+ # 反向ws端口
+ port: 8080
+ # 非开发者无需理会
+ debug: 0
+ # 超级用户,填自己的QQ号,用“,”隔开
+ superusers: [123456789]
+ # 机器人昵称,建议不动
+ nickname: ['ATRI', 'Atri', 'atri', '亚托莉', 'アトリ']
+ # 命令触发头,建议不动,除非你知道你在做什么
+ command_start: ['', '/']
+ # 命令分离,建议不动,除非你知道你在做什么
+ command_sep: ['.']
+ # 会话失效时间,单位:分钟
+ session_expire_timeout: 2
+
+# 接口相关配置
+api:
+ # 涩图接口,URL:https://api.lolicon.app/#/setu
+ LoliconAPI: xxx
+ # 搜图接口,URL:https://saucenao.com/
+ SauceNaoKEY: xxx
+
+# # 内置网页端
+# html:
+# # 对外地址,建议0.0.0.0
+# host: 0.0.0.0
+# # 对外端口,请检查防火墙是否开启
+# port: 80 \ No newline at end of file
diff --git a/ATRI/data/data_Error/error.json b/ATRI/data/data_Error/error.json
deleted file mode 100644
index afcc10e..0000000
--- a/ATRI/data/data_Error/error.json
+++ /dev/null
@@ -1 +0,0 @@
-{"DKkj6IEFz0ArpaGh": "Traceback (most recent call last):\n File \"ATRI/plugins\\plugin_chat\\__init__.py\", line 179, in _\n await fxxkMe.finish(request_api_text(URL))\n File \"C:\\Users\\Administrator.DESKTOP-D764LND\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\nonebot\\matcher.py\", line 583, in finish\n raise FinishedException\nnonebot.exception.FinishedException\n", "piNxHF16v4mWODBX": "Traceback (most recent call last):\n File \"ATRI/plugins\\plugin_utils\\__init__.py\", line 106, in _\n uid_info = JsonAnalysis(GetInfo(uid))\n File \"ATRI/plugins\\plugin_utils\\genshin.py\", line 66, in JsonAnalysis\n Character_List = data[\"data\"][\"avatars\"]\nTypeError: 'NoneType' object is not subscriptable\n"} \ No newline at end of file
diff --git a/ATRI/data/data_HTML/api/data/times/api_all.json b/ATRI/data/data_HTML/api/data/times/api_all.json
deleted file mode 100644
index 415b649..0000000
--- a/ATRI/data/data_HTML/api/data/times/api_all.json
+++ /dev/null
@@ -1 +0,0 @@
-{"1604140447.514061": ["127.0.0.1:28598", {"status": "fail", "message": "reserved range", "query": "127.0.0.1"}, "index"], "1604140466.7449028": ["127.0.0.1:28648", {"status": "fail", "message": "reserved range", "query": "127.0.0.1"}, "index"]} \ No newline at end of file
diff --git a/ATRI/data/data_HTML/api/data/times/api_index.json b/ATRI/data/data_HTML/api/data/times/api_index.json
deleted file mode 100644
index 88778a1..0000000
--- a/ATRI/data/data_HTML/api/data/times/api_index.json
+++ /dev/null
@@ -1 +0,0 @@
-{"1604140447.514061": ["127.0.0.1:28598", {"status": "fail", "message": "reserved range", "query": "127.0.0.1"}], "1604140466.7449028": ["127.0.0.1:28648", {"status": "fail", "message": "reserved range", "query": "127.0.0.1"}]} \ No newline at end of file
diff --git a/ATRI/data/data_HTML/api/index.html b/ATRI/data/data_HTML/api/index.html
deleted file mode 100644
index d6de227..0000000
--- a/ATRI/data/data_HTML/api/index.html
+++ /dev/null
@@ -1,189 +0,0 @@
-<html>
- <meta charset="utf-8">
- <head>
- <title>kawaii APIs</title>
- </head>
- <style>
- table {
- background: rgba(207, 197, 197, 0.6);
- position: relative;
- overflow: hidden;
- }
-
- body {
- background: url(https://i.loli.net/2020/10/25/XBs53daiNgKtPUr.jpg) 0 / cover fixed;
- }
- </style>
- <body>
- <center>
- <table>
- <tbody>
- <tr>
- <td>
- <font size=6>
- <b>ATRI Data Control Center</b>
- </font>
- </td>
- </tr>
- <tr>
- <td>* 恭喜你发现了一...由屎山构成的 API 小站</td>
- </tr>
- <tr>
- <td>* API 主体由炒————鸡给力的 FastAPI 搭建</td>
- </tr>
- <tr>
- <td>* 嘛...所以想扫的那些,。就放弃了8</td>
- </tr>
- <tr>
- <td>* 毕竟👴可将那些敏感页面放到了用👴头滚的键盘出来的目录中(甚至没有?)</td>
- </tr>
- <tr>
- <td>————————————————————————————————————</td>
- </tr>
- <tr>
- <td>还有,上面内容不是我写的,👴才没这兴趣</td>
- </tr>
- <tr>
- <td>以及,那些爪巴数据的,ip都给你封咯<a href="https://sm.ms/image/Q3tKembnrF4oOud" target="_blank"><img src="https://i.loli.net/2020/10/24/Q3tKembnrF4oOud.jpg" ></a></td>
- </tr>
- <tr>
- <td>————————————————————————————————————</td>
- </tr>
- <tr>
- <td>关于 API 一些说明</td>
- </tr>
- <tr>
- <td>内容不多,也就:涩图</td>
- </tr>
- <tr>
- <td>本 API 服务定位于 ATRI 的涩图功能,跟随 ATRI 一同启动,主人可选择关闭或开启</td>
- </tr>
- <tr>
- <td>————————————————————————————————————</td>
- </tr>
- <tr>
- <td>涩图:</td>
- </tr>
- <tr>
- <td>* 涩图もっとありがとう</td>
- </tr>
- <tr>
- <td>* 所有所有所有的涩图均来自 Pixiv,解释权均归各个画师</td>
- </tr>
- <tr>
- <td>* 为保证符合自己xp,库中所有涩图均由主人亲自挑选,不喜勿喷orz</td>
- </tr>
- <tr>
- <td>* 为防止突发的社死,将涩图分为了几个块,详细请继续往下</td>
- </tr>
- <tr>
- <td>* 想说的有待补充,暂时这些叻~!</td>
- </tr>
- <tr>
- <td>目前数据总量:</td>
- </tr>
- <tr>
- <td>
- <table border="1">
- <tr>
- <th>正常(normal)</th>
- <th>擦边球(nearR18)</th>
- <th>R18(R18)</th>
- </tr>
- <tr>
- <td>{{data_normal}}</td>
- <td>{{data_nearR18}}</td>
- <td>{{data_r18}}</td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td>调用信息 (time: times):</td>
- </tr>
- <tr>
- <td>
- <table border="1">
- <tr>
- <th>ALL</th>
- <th>{{date_now}}</th>
- <th>{{date_yesterday}}</th>
- <th>{{date_before_yesterday}}</th>
- </tr>
- <tr>
- <td>{{times_all}}</td>
- <td>{{times_now}}</td>
- <td>{{times_yesterday}}</td>
- <td>{{times_before_yesterday}}</td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td>接口信息:</td>
- </tr>
- <tr>
- <td>* 请求方式:GET</td>
- </tr>
- <tr>
- <td>
- <table border="1">
- <tr>
- <td>normal</td>
- <td>https://{{open_ip}}/api/setu/normal</td>
- </tr>
- <tr>
- <td>nearR18</td>
- <td>https://{{open_ip}}/api/setu/nearr18</td>
- </tr>
- <tr>
- <td>R18</td>
- <td>https://{{open_ip}}/api/setu/r18</td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td>————————————————————————————————————</td>
- </tr>
- <tr>
- <td>以下是您的访问信息:</td>
- </tr>
- <tr>
- <td>* IP&PORT: {{info_ip}}</td>
- </tr>
- <tr>
- <td>* continent: {{info_continent}}</td>
- </tr>
- <tr>
- <td>* country: {{info_country}}</td>
- </tr>
- <tr>
- <td>* regionName: {{info_regionName}}</td>
- </tr>
- <tr>
- <td>* city: {{info_city}}</td>
- </tr>
- <tr>
- <td>* lat: {{info_lat}}</td>
- </tr>
- <tr>
- <td>* lon: {{info_lon}}</td>
- </tr>
- <tr>
- <td>* timezone: {{info_timezone}}</td>
- </tr>
- <tr>
- <td>* isp: {{info_isp}}</td>
- </tr>
- <tr>
- <td>* as: {{info_as}}</td>
- </tr>
- <tr>
- <td>* asname: {{info_asname}}</td>
- </tr>
- </tbody>
- </table>
- </center>
- </body>
-</html> \ No newline at end of file
diff --git a/ATRI/plugins/plugin_admin/key_repo_waiting.json b/ATRI/data/service/banlist.service.json
index 9e26dfe..9e26dfe 100644
--- a/ATRI/plugins/plugin_admin/key_repo_waiting.json
+++ b/ATRI/data/service/banlist.service.json
diff --git a/ATRI/plugins/plugin_chat/key_repo.json b/ATRI/data/service/switch.service.json
index 9e26dfe..9e26dfe 100644
--- a/ATRI/plugins/plugin_chat/key_repo.json
+++ b/ATRI/data/service/switch.service.json
diff --git a/ATRI/exceptions.py b/ATRI/exceptions.py
new file mode 100644
index 0000000..f3c4f5c
--- /dev/null
+++ b/ATRI/exceptions.py
@@ -0,0 +1,14 @@
+class ATRIError(BaseException):
+ pass
+
+
+class InvalidConfigError(ATRIError):
+ """配置文件有问题"""
+
+
+class InvalidPluginError(ATRIError):
+ """插件有问题"""
+
+
+class InvalidRequestError(ATRIError):
+ """网络请求有问题"""
diff --git a/ATRI/log.py b/ATRI/log.py
new file mode 100644
index 0000000..335389b
--- /dev/null
+++ b/ATRI/log.py
@@ -0,0 +1,34 @@
+from pathlib import Path
+from datetime import datetime
+from nonebot.log import logger, default_format
+
+LOGGER_INFO_PATH = Path(
+ '.'
+) / 'ATRI' / 'logs' / 'info' / f"{datetime.now().strftime('%Y%m%d-%H%M%S')}-INFO.log"
+LOGGER_ERROR_PATH = Path(
+ '.'
+) / 'ATRI' / 'logs' / 'error' / f"{datetime.now().strftime('%Y%m%d-%H%M%S')}-ERROR.log"
+LOGGER_WARNING_PATH = Path(
+ '.'
+) / 'ATRI' / 'logs' / 'warning' / f"{datetime.now().strftime('%Y%m%d-%H%M%S')}-WARNING.log"
+
+logger.add(LOGGER_INFO_PATH,
+ rotation='10 MB',
+ enqueue=True,
+ level='INFO',
+ encoding='utf-8',
+ format=default_format)
+
+logger.add(LOGGER_ERROR_PATH,
+ rotation='10 MB',
+ enqueue=True,
+ level='ERROR',
+ encoding='utf-8',
+ format=default_format)
+
+logger.add(LOGGER_WARNING_PATH,
+ rotation='10 MB',
+ enqueue=True,
+ level='WARNING',
+ encoding='utf-8',
+ format=default_format)
diff --git a/ATRI/data/data_HTML/api/data/times/api_setu.json b/ATRI/plugins/admin/__init__.py
index e69de29..e69de29 100644
--- a/ATRI/data/data_HTML/api/data/times/api_setu.json
+++ b/ATRI/plugins/admin/__init__.py
diff --git a/ATRI/data/data_HTML/user/index.html b/ATRI/plugins/admin/data_source.py
index e69de29..e69de29 100644
--- a/ATRI/data/data_HTML/user/index.html
+++ 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/plugin_anime/sepi_list.json b/ATRI/plugins/curse.py
index e69de29..e69de29 100644
--- a/ATRI/plugins/plugin_anime/sepi_list.json
+++ 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_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/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
deleted file mode 100644
index 774cf5d..0000000
--- a/ATRI/plugins/plugin_test/test.mp3
+++ /dev/null
Binary files differ
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
deleted file mode 100644
index 6e74a60..0000000
--- a/ATRI/plugins/plugin_utils/main.bin
+++ /dev/null
Binary files differ
diff --git a/ATRI/request.py b/ATRI/request.py
new file mode 100644
index 0000000..c399be0
--- /dev/null
+++ b/ATRI/request.py
@@ -0,0 +1,10 @@
+from typing import Optional
+from aiohttp.client import ClientSession
+
+
+class Request():
+ async def get(self, url: str, headers: Optional[dict] = None) -> bytes:
+ async with ClientSession() as session:
+ async with session.get(url, headers=headers) as r:
+ result = await r.read()
+ return result
diff --git a/ATRI/rule.py b/ATRI/rule.py
new file mode 100644
index 0000000..1ed10d8
--- /dev/null
+++ b/ATRI/rule.py
@@ -0,0 +1,46 @@
+from re import T
+from nonebot.rule import Rule
+from nonebot.typing import Bot, Event
+
+from ATRI.service import Service
+
+
+def isInService(service: str) -> Rule:
+ async def _isInService(bot: Bot, event: Event, state: dict) -> bool:
+ return Service().Switch().auth_service(service, event.group_id)
+
+ return Rule(_isInService)
+
+
+def isInBanList() -> Rule:
+ async def _isInBanList(bot: Bot, event: Event, state: dict) -> bool:
+ return Service().BanList().is_in_list(event.user_id)
+
+ return Rule(_isInBanList)
+
+
+def isInDormant() -> Rule:
+ async def _isInDormant(bot: Bot, event: Event, state: dict) -> bool:
+ return Service().Dormant().is_sleep()
+
+ return Rule(_isInDormant)
+
+
+def toGroup() -> Rule:
+ async def _toGroup(bot: Bot, event: Event, state: dict) -> bool:
+ return bool(event.group_id)
+
+ return Rule(_toGroup)
+
+
+def toPrivate() -> Rule:
+ async def _toPrivate(bot: Bot, event: Event, state: dict) -> bool:
+ return not bool(event.group_id)
+
+ return Rule(_toPrivate)
+
+def toBot() -> Rule:
+ async def _toBot(bot: Bot, event: Event, state: dict) -> bool:
+ return bool(event.to_me)
+
+ return Rule(_toBot)
diff --git a/ATRI/service.py b/ATRI/service.py
new file mode 100644
index 0000000..79ed7ad
--- /dev/null
+++ b/ATRI/service.py
@@ -0,0 +1,112 @@
+import json
+from pathlib import Path
+from typing import Optional
+
+SERVICE_SWITCH_PATH = Path('.') / 'ATRI' / 'data' / 'service' / 'switch.service.json'
+SERVICE_BANLIST_PATH = Path('.') / 'ATRI' / 'data' / 'service' / 'banlist.service.json'
+
+state = 0
+
+
+class Service():
+ class Switch():
+ if not SERVICE_SWITCH_PATH.is_file:
+ SERVICE_SWITCH_PATH.write_text(json.dumps({}))
+ data = {}
+ else:
+ data = json.loads(SERVICE_SWITCH_PATH.read_bytes())
+
+ def get_service(self) -> dict:
+ return self.data
+
+ def auth_service(self, service: str, group: Optional[int]) -> bool:
+ try:
+ self.data['global']
+ except:
+ self.data['global'] = {}
+ SERVICE_SWITCH_PATH.write_text(json.dumps(self.data))
+
+ try:
+ self.data[group]
+ except:
+ self.data[group] = {}
+ SERVICE_SWITCH_PATH.write_text(json.dumps(self.data))
+
+ if (not self.data['global'].get('service', None)
+ or not self.data[group][service].get('service', None)):
+ self.data['global'][service] = True
+ self.data[group][service] = True
+ SERVICE_SWITCH_PATH.write_text(json.dumps(self.data))
+ else:
+ pass
+
+ if self.data['global'][service]:
+ return True if self.data[group][service] else False
+ else:
+ return False
+
+ def control_service(self, service: str, _type: bool, group: Optional[int]) -> bool:
+ if service not in self.data:
+ self.data['global'][service] = True
+ self.data[group][service] = True
+ SERVICE_SWITCH_PATH.write_text(json.dumps(self.data))
+
+ if group:
+ try:
+ self.data[group][service] = _type
+ SERVICE_SWITCH_PATH.write_text(json.dumps(self.data))
+ return True
+ except:
+ return False
+ else:
+ try:
+ self.data['global'][service] = _type
+ SERVICE_SWITCH_PATH.write_text(json.dumps(self.data))
+ return True
+ except:
+ return False
+
+ class BanList():
+ if not SERVICE_BANLIST_PATH.is_file():
+ SERVICE_BANLIST_PATH.write_text(json.dumps({}))
+ data = {}
+ else:
+ data = json.loads(SERVICE_BANLIST_PATH.read_bytes())
+
+ def get_banlist(self) -> dict:
+ return self.data
+
+ def is_in_list(self, user: Optional[int]) -> bool:
+ return False if user in self.data else True
+
+ def add_list(self, user: Optional[int]) -> bool:
+ try:
+ self.data[user] = user
+ SERVICE_BANLIST_PATH.write_text(json.dumps(self.data))
+ return True
+ except:
+ return False
+
+ def del_list(self, user: Optional[int]) -> bool:
+ try:
+ del self.data[user]
+ SERVICE_BANLIST_PATH.write_text(json.dumps(self.data))
+ return True
+ except:
+ return False
+
+ class Dormant():
+
+ def is_sleep(self) -> bool:
+ return True if state != 1 else False
+
+ def cont_wake(self, _type: bool) -> bool:
+ global state
+ try:
+ if _type:
+ state = 0
+ else:
+ state = 1
+ return True
+ except:
+ return False
diff --git a/ATRI/test.py b/ATRI/test.py
new file mode 100644
index 0000000..0f20a21
--- /dev/null
+++ b/ATRI/test.py
@@ -0,0 +1,3 @@
+
+
+print('|'.join({'ATRI', 'Atri', 'atri', '亚托莉', 'アトリ'})) \ No newline at end of file
diff --git a/ATRI/utils.py b/ATRI/utils.py
new file mode 100644
index 0000000..b0f1b12
--- /dev/null
+++ b/ATRI/utils.py
@@ -0,0 +1,47 @@
+import yaml
+from datetime import datetime
+from pathlib import Path
+
+
+def loadYaml(file: Path) -> dict:
+ '''
+ 读取yaml文件
+ :return: dict
+ '''
+ with open(file, 'r', encoding='utf-8') as f:
+ data = yaml.safe_load(f)
+ return data
+
+
+def countList(lst: list, aim) -> int:
+ '''
+ 检查某列表中目标出现的次数
+ :return: int
+ '''
+ count = 0
+ for ele in lst:
+ if ele == aim:
+ count = count + 1
+ return count
+
+
+def delListAim(lst: list, aim) -> list:
+ '''
+ 删除某列表中所有目标元素
+ :return: list
+ '''
+ while aim in lst:
+ lst.remove(aim)
+ return lst
+
+
+def nowTime() -> float:
+ '''
+ 获取当前时间(小时)
+ :return: float
+ '''
+ now_ = datetime.now()
+ hour = now_.hour
+ minute = now_.minute
+ now = hour + minute / 60
+ return now \ No newline at end of file
diff --git a/ATRI/utils/utils_ban/__init__.py b/ATRI/utils/utils_ban/__init__.py
deleted file mode 100644
index 5cd361e..0000000
--- a/ATRI/utils/utils_ban/__init__.py
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/env python3
-# -*- encoding: utf-8 -*-
-
-'''
-@File : __init__.py
-@Time : 2020/11/21 22:50:49
-@Author : Kyomotoi
-@Contact : [email protected]
-@Github : https://github.com/Kyomotoi
-@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved.
-'''
-__author__ = 'kyomotoi'
-
-import json
-from pathlib import Path
-
-BAN_LIST_PATH = Path('.') / 'ATRI' / 'utils' / 'utils_rule' / 'ban_list_user.json'
-with open(BAN_LIST_PATH, 'r') as f:
- data = json.load(f)
-
-
-def ban(user: str) -> None:
- data[user] = user
- with open(BAN_LIST_PATH, 'w') as f:
- f.write(json.dumps(data))
-
-def unban(user: str) -> None:
- del data[user]
- with open(BAN_LIST_PATH, 'w') as f:
- f.write(json.dumps(data))
diff --git a/ATRI/utils/utils_error/__init__.py b/ATRI/utils/utils_error/__init__.py
deleted file mode 100644
index d033613..0000000
--- a/ATRI/utils/utils_error/__init__.py
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/usr/bin/env python3
-# -*- encoding: utf-8 -*-
-'''
-@File : __init__.py
-@Time : 2020/10/11 14:43:10
-@Author : Kyomotoi
-@Contact : [email protected]
-@Github : https://github.com/Kyomotoi
-@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved.
-'''
-__author__ = 'kyomotoi'
-
-import json
-import string
-from pathlib import Path
-from random import sample
-from typing import Optional
-from datetime import datetime
-from traceback import format_exc
-
-
-def errorRepo(repo_msg: Optional[str] = None) -> str:
- '''
- 出错时返回错误堆栈
-
- :return: str
- '''
- file_error = Path('.') / 'ATRI' / 'data' / 'data_Error' / 'error.json'
- try:
- with open(file_error, 'r') as f:
- data_error = json.load(f)
- except FileNotFoundError:
- data_error = {}
-
- key_error = ''.join(sample(string.ascii_letters + string.digits, 16))
- msg_error = f"{datetime.now()}\n"
- msg_error = f"{format_exc()}"
- data_error[f"{key_error}"] = f"{msg_error}"
-
- with open(file_error, 'w') as f:
- f.write(json.dumps(data_error))
- f.close()
-
- if repo_msg:
- pass
- else:
- repo_msg = 'unknown'
-
- msg0 = f'ERROR! Reason: [{repo_msg}]\n'
- msg0 += f'trackID: {key_error}\n'
- msg0 += "请使用[来杯红茶]功能以联系维护者\n"
- msg0 += "并附上 trackID"
-
- return msg0 \ No newline at end of file
diff --git a/ATRI/utils/utils_history/__init__.py b/ATRI/utils/utils_history/__init__.py
deleted file mode 100644
index 3aae3fa..0000000
--- a/ATRI/utils/utils_history/__init__.py
+++ /dev/null
@@ -1,105 +0,0 @@
-#!/usr/bin/env python3
-# -*- encoding: utf-8 -*-
-'''
-@File : __init__.py
-@Time : 2020/11/07 14:33:22
-@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 datetime
-from pathlib import Path
-from typing import Optional
-
-
-def saveMessage(message_id: str,
- message: str,
- user: str,
- group: Optional[str] = None) -> None:
- """储存消息"""
- GROUP_PATH = Path(
- '.'
- ) / 'ATRI' / 'data' / 'data_Group' / f'{group}' / f"{datetime.datetime.now().strftime('%Y-%m-%d')}-message.json"
- PRIVATE_PATH = Path(
- '.'
- ) / 'ATRI' / 'data' / 'data_Private_Message' / f"{datetime.datetime.now().strftime('%Y-%m-%d')}-private-message.json"
-
- # 检查目标文件目录
- if not GROUP_PATH.is_file():
- os.makedirs(Path('.') / 'ATRI' / 'data' / 'data_Group', exist_ok=True)
- os.makedirs(Path('.') / 'ATRI' / 'data' / 'data_Group' / f'{group}',
- exist_ok=True)
-
- with open(GROUP_PATH, 'w') as f:
- f.write(json.dumps({}))
-
- if not PRIVATE_PATH.is_file():
- os.makedirs(Path('.') / 'ATRI' / 'data' / 'data_Private_Message',
- exist_ok=True)
-
- with open(PRIVATE_PATH, 'w') as f:
- f.write(json.dumps({}))
-
- # 加载目标文件
- with open(GROUP_PATH, 'r') as f:
- DATA_GROUP = json.load(f)
-
- with open(PRIVATE_PATH, 'r') as f:
- DATA_PRIVATE = json.load(f)
-
- # 写入
- if group:
- DATA_GROUP[f"{message_id}"] = {
- "message": f"{message}",
- "user_id": f"{user}",
- "group_id": f"{group}"
- }
-
- with open(GROUP_PATH, 'w') as f:
- f.write(json.dumps(DATA_GROUP))
-
- else:
- DATA_PRIVATE[f"{message_id}"] = {
- "message": f"{message}",
- "user_id": f"{user}"
- }
-
- with open(PRIVATE_PATH, 'w') as f:
- f.write(json.dumps(DATA_PRIVATE))
-
-
-def getMessage(message_id: str, group: Optional[str] = None) -> dict:
- '''
- 传入消息id以获取对应信息
-
- :return: dict
- '''
- GROUP_PATH = Path(
- '.'
- ) / 'ATRI' / 'data' / 'data_Group' / f'{group}' / f"{datetime.datetime.now().strftime('%Y-%m-%d')}-message.json"
- PRIVATE_PATH = Path(
- '.'
- ) / 'ATRI' / 'data' / 'data_Private_Message' / f"{datetime.datetime.now().strftime('%Y-%m-%d')}-private-message.json"
-
- if group:
- try:
- with open(GROUP_PATH, 'r') as f:
- data_group = json.load(f)
- return data_group[message_id]
-
- except:
- return {"status": 0}
-
- else:
- try:
- with open(PRIVATE_PATH, 'r') as f:
- data_private = json.load(f)
- return data_private[message_id]
-
- except:
- return {"status": 0}
diff --git a/ATRI/utils/utils_img/__init__.py b/ATRI/utils/utils_img/__init__.py
deleted file mode 100644
index 7b79146..0000000
--- a/ATRI/utils/utils_img/__init__.py
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/usr/bin/env python3
-# -*- encoding: utf-8 -*-
-
-'''
-@File : __init__.py
-@Time : 2020/11/07 14:17:37
-@Author : Kyomotoi
-@Contact : [email protected]
-@Github : https://github.com/Kyomotoi
-@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved.
-'''
-__author__ = 'kyomotoi'
-
-import os
-import string
-import aiohttp
-from pathlib import Path
-from random import sample
-
-import PIL.Image as Image
-from PIL import ImageFile
-
-async def aio_download_pics(url) -> str:
- '''
- 下载图片并重命名
-
- :return: img file
- '''
- path = Path('.') / 'ATRI' / 'data' / 'data_Temp' / 'img'
- path = os.path.abspath(path)
- img_key = ''.join(sample(string.ascii_letters + string.digits, 16))
- img = path + f'\\{img_key}.png'
- async with aiohttp.ClientSession() as session:
- async with session.get(url) as response:
- pic = await response.read() #以Bytes方式读入非文字
- with open(img, mode='wb') as f:# 写入文件
- f.write(pic)
- f.close()
- return img
-
-def compress_image(outfile: str, kb=400, quality=85, k=0.9) -> str:
- '''
- 压缩图片
-
- :return: img file
- '''
- o_size = os.path.getsize(outfile) // 1024
- if o_size <= kb:
- return outfile
-
- ImageFile.LOAD_TRUNCATED_IMAGES = True # type: ignore
- while o_size > kb:
- im = Image.open(outfile)
- x, y = im.size
- out = im.resize((int(x*k), int(y*k)), Image.ANTIALIAS)
- try:
- out.save(outfile, quality=quality)
- except Exception as e:
- print(e)
- break
- o_size = os.path.getsize(outfile) // 1024
- return outfile
diff --git a/ATRI/utils/utils_request/__init__.py b/ATRI/utils/utils_request/__init__.py
deleted file mode 100644
index fd235bf..0000000
--- a/ATRI/utils/utils_request/__init__.py
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/usr/bin/env python3
-# -*- encoding: utf-8 -*-
-'''
-@File : __init__.py
-@Time : 2020/10/11 14:43:55
-@Author : Kyomotoi
-@Contact : [email protected]
-@Github : https://github.com/Kyomotoi
-@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved.
-'''
-__author__ = 'kyomotoi'
-
-import requests
-from typing import Optional
-from aiohttp import ClientSession
-
-def request_get(url: str, params: Optional[dict] = None) -> bytes:
- '''
- 通过 GET 方式请求 url。
-
- :return: bytes
- '''
- return requests.get(url, params).content
-
-def request_api_text(url: str) -> str:
- res = requests.request("GET", url)
- html = res.text
- return html
-
-async def aio_get_bytes(url: str, headers: Optional[dict] = None) -> bytes:
- '''
- 通过 GET 以 异步 方式请求 url。
-
- :return: bytes
- '''
- async with ClientSession() as asyncSession:
- async with asyncSession.get(url, headers=headers) as resp:
- result = await resp.read()
- return result \ No newline at end of file
diff --git a/ATRI/utils/utils_rule/__init__.py b/ATRI/utils/utils_rule/__init__.py
deleted file mode 100644
index cddf93e..0000000
--- a/ATRI/utils/utils_rule/__init__.py
+++ /dev/null
@@ -1,109 +0,0 @@
-#!/usr/bin/env python3
-# -*- encoding: utf-8 -*-
-'''
-@File : __init__.py
-@Time : 2020/11/06 19:27:00
-@Author : Kyomotoi
-@Contact : [email protected]
-@Github : https://github.com/Kyomotoi
-@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved.
-'''
-__author__ = 'kyomotoi'
-
-import os
-import json
-from pathlib import Path
-from nonebot.rule import Rule
-from nonebot.typing import Bot, Event
-
-
-def check_banlist() -> Rule:
- '''
- 检查目标是否存在于封禁名单
-
- :return: bool
- '''
- async def _chech_banlist(bot: Bot, event: Event, state: dict) -> bool:
- # 获取目标信息
- user = str(event.user_id)
-
- # 名单目录
- BAN_LIST_USER_PATH = Path(
- '.') / 'ATRI' / 'utils' / 'utils_rule' / 'ban_list_user.json'
-
- # 检查文件是否存在,如不存在,自动创建并写入默认值
- if not BAN_LIST_USER_PATH.is_file():
- with open(BAN_LIST_USER_PATH, 'w') as f:
- f.write(json.dumps({}))
-
- # 读取文件
- with open(BAN_LIST_USER_PATH, 'r') as f:
- data_user = json.load(f)
-
- return user not in data_user
-
- return Rule(_chech_banlist)
-
-
-def check_switch(func_name: str, notice: bool) -> Rule:
- '''
- 检查目标功能是否开启
-
- :return: bool
- '''
- async def _check_switch(bot: Bot, event: Event, state: dict) -> bool:
- # 获取目标信息
- group = str(event.group_id)
-
- # 文件目录
- SWITCH_ALL_PATH = Path('.') / 'ATRI' / 'utils' / 'utils_rule' / 'switch.json'
- SWITCH_ALONE_PATH = Path(
- '.') / 'ATRI' / 'data' / 'data_Group' / f'{group}' / 'switch.json'
-
- # 检查文件是否存在,如不存在,自动创建并写入默认值
- if not SWITCH_ALL_PATH.is_file():
- with open(SWITCH_ALL_PATH, 'ws') as f:
- f.write(json.dumps({}))
-
- if not SWITCH_ALONE_PATH.is_file():
- try:
- os.mkdir(
- Path('.') / 'ATRI' / 'data' / 'data_Group' / f'{group}')
- except:
- pass
-
- with open(SWITCH_ALONE_PATH, 'w') as f:
- f.write(json.dumps({}))
-
- # 读取文件
- with open(SWITCH_ALL_PATH, 'r') as f:
- data_all = json.load(f)
-
- with open(SWITCH_ALONE_PATH, 'r') as f:
- data_alone = json.load(f)
-
- # 判断目标是否存在于将要读取的文件,如不存在,写入
- # 此项举措是为了适应以后版本更新出现新插件的状况
- # 不至于每次都需要修改
- if func_name not in data_all:
- data_all[func_name] = "True"
- with open(SWITCH_ALL_PATH, 'w') as f:
- f.write(json.dumps(data_all))
-
- if func_name not in data_alone:
- data_alone[func_name] = "True"
- with open(SWITCH_ALONE_PATH, 'w') as f:
- f.write(json.dumps(data_alone))
-
- # 判断目标
- if data_all[func_name] == "True":
- if data_alone[func_name] == "True":
- return True
- else:
- return False
- else:
- if notice:
- await bot.send(event, f"Service-{func_name} has been closed.")
- return False
-
- return Rule(_check_switch)
diff --git a/ATRI/utils/utils_rule/ban_list_user.json b/ATRI/utils/utils_rule/ban_list_user.json
deleted file mode 100644
index 9e26dfe..0000000
--- a/ATRI/utils/utils_rule/ban_list_user.json
+++ /dev/null
@@ -1 +0,0 @@
-{} \ No newline at end of file
diff --git a/ATRI/utils/utils_rule/switch.json b/ATRI/utils/utils_rule/switch.json
deleted file mode 100644
index d7ac35e..0000000
--- a/ATRI/utils/utils_rule/switch.json
+++ /dev/null
@@ -1 +0,0 @@
-{"anime-setu": "True", "anime-pic-search": "True", "anime-vid-search": "True", "all-off-anime-setu": "True", "pixiv-pic-search": "True", "pixiv-author-search": "True", "pixiv-rank": "True", "one-key-adult": "True", "genshin-search": "True", "drifting-bottle": "True"} \ No newline at end of file
diff --git a/ATRI/utils/utils_switch/__init__.py b/ATRI/utils/utils_switch/__init__.py
deleted file mode 100644
index 4c80e94..0000000
--- a/ATRI/utils/utils_switch/__init__.py
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/usr/bin/env python3
-# -*- encoding: utf-8 -*-
-'''
-@File : __init__.py
-@Time : 2020/10/11 14:44:06
-@Author : Kyomotoi
-@Contact : [email protected]
-@Github : https://github.com/Kyomotoi
-@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved.
-'''
-__author__ = 'kyomotoi'
-
-import json
-from pathlib import Path
-from typing import Optional
-
-
-def controlSwitch(func_name: str,
- control: bool,
- group: Optional[str] = None) -> str:
- '''
- 控制开关 开启或关闭
-
- :return: str
- '''
- file_switch_all = Path('.') / 'ATRI' / 'utils' / 'utils_rule' / 'switch.json'
-
- if group:
- file_switch_group = Path(
- '.') / 'ATRI' / 'data' / 'data_Group' / f'{group}' / 'switch.json'
- try:
- with open(file_switch_group, 'r') as f:
- data_switch_group = json.load(f)
- except FileNotFoundError:
- data_switch_group = {}
-
- if data_switch_group[f"{func_name}"]:
- pass
- else:
- return f"Can't find func({func_name})"
-
- data_switch_group[f"{func_name}"] = f"{control}"
-
- with open(file_switch_group, 'w') as f:
- f.write(json.dumps(data_switch_group))
- f.close()
-
- else:
- pass
-
-
- with open(file_switch_all, 'r') as f:
- try:
- data_switch_all = json.load(f)
- except:
- data_switch_all = {}
-
- if not data_switch_all[f"{func_name}"]:
- return f"Can't find func({func_name})"
-
- data_switch_all[f"{func_name}"] = f"{control}"
-
- with open(file_switch_all, 'w') as f:
- f.write(json.dumps(data_switch_all))
- f.close()
-
- if control == True:
- if group:
- msg = f"({func_name}) has been opened for group ({group})!"
- else:
- msg = f"({func_name}) has been opened!"
-
- else:
- if group:
- msg = f"({func_name}) has been closed for group ({group})!"
- else:
- msg = f"({func_name}) has been closed!"
-
- return msg \ No newline at end of file
diff --git a/ATRI/utils/utils_textcheck/__init__.py b/ATRI/utils/utils_textcheck/__init__.py
deleted file mode 100644
index be1553e..0000000
--- a/ATRI/utils/utils_textcheck/__init__.py
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/env python3
-# -*- encoding: utf-8 -*-
-'''
-@File : data_source.py
-@Time : 2020/11/21 19:54:11
-@Author : Kyomotoi
-@Contact : [email protected]
-@Github : https://github.com/Kyomotoi
-@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved.
-'''
-__author__ = 'kyomotoi'
-
-import json
-from pathlib import Path
-from typing import Optional
-
-PUBLIC_OPINION_PATH = Path('.') / 'ATRI' / 'utils' / 'utils_textcheck' / 'public_opinion.json'
-
-
-class Textcheck:
- """文字检查,专供舆情"""
- with open(PUBLIC_OPINION_PATH, 'r+') as f:
- try:
- data = json.load(f)
- except:
- data = {}
-
- def check(self, msg: str) -> Optional[str]:
- wait_list = [keys for keys in self.data.keys()]
- for word in wait_list:
- if word in msg:
- return self.data[word]
- else:
- return "False"
-
- def add_word(self, word: str, repo: str, max_times: int,
- ban_time: int) -> Optional[str]:
- if word in self.data:
- return '相关关键词已经有啦~!'
- else:
- self.data[word] = [repo, max_times, ban_time]
- msg0 = '学習しました!\n'
- msg0 += f'Key: {word}\n'
- msg0 += f'Repo: {repo}\n'
- msg0 += f'Max times: {max_times}\n'
- msg0 += f'Ban time: {ban_time}'
- return msg0
-
- def del_word(self, word: str) -> str:
- if word in self.data:
- del self.data[word]
- return "好叻~!"
- else:
- return "未发现相关关键词呢..."
-
- def get_times(self, word: str) -> Optional[int]:
- if word not in self.data:
- return 11451406000721114514
- else:
- return self.data[word][1]
diff --git a/ATRI/utils/utils_textcheck/public_opinion.json b/ATRI/utils/utils_textcheck/public_opinion.json
deleted file mode 100644
index 9e26dfe..0000000
--- a/ATRI/utils/utils_textcheck/public_opinion.json
+++ /dev/null
@@ -1 +0,0 @@
-{} \ No newline at end of file
diff --git a/ATRI/utils/utils_times/__init__.py b/ATRI/utils/utils_times/__init__.py
deleted file mode 100644
index 1f65fc6..0000000
--- a/ATRI/utils/utils_times/__init__.py
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/env python3
-# -*- encoding: utf-8 -*-
-'''
-@File : __init__.py
-@Time : 2020/10/31 19:36:49
-@Author : Kyomotoi
-@Contact : [email protected]
-@Github : https://github.com/Kyomotoi
-@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved.
-'''
-__author__ = 'kyomotoi'
-
-import warnings
-
-
-def countX(lst: list, aim) -> int:
- '''
- 检查某列表某元素出现次数
-
- :return: int
- '''
- warnings.simplefilter('ignore', ResourceWarning)
- count = 0
- for ele in lst:
- if (ele == aim):
- count = count + 1
- return count
diff --git a/ATRI/utils/utils_translate/__init__.py b/ATRI/utils/utils_translate/__init__.py
deleted file mode 100644
index 29026e7..0000000
--- a/ATRI/utils/utils_translate/__init__.py
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/usr/bin/env python3
-# -*- encoding: utf-8 -*-
-'''
-@File : __init__.py
-@Time : 2020/10/23 21:59:02
-@Author : Kyomotoi
-@Contact : [email protected]
-@Github : https://github.com/Kyomotoi
-@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved.
-'''
-__author__ = 'kyomotoi'
-
-SIMPLE = "万与丑专业丛东丝丢两严丧个丬丰临为丽举么义乌乐乔习乡书买乱争于亏云亘亚产亩亲亵亸亿仅从仑仓仪们价众优伙会伛伞伟传伤伥伦伧伪伫体余佣佥侠侣侥侦侧侨侩侪侬俣俦俨俩俪俭债倾偬偻偾偿傥傧储傩儿兑兖党兰关兴兹养兽冁内冈册写军农冢冯冲决况冻净凄凉凌减凑凛几凤凫凭凯击凼凿刍划刘则刚创删别刬刭刽刿剀剂剐剑剥剧劝办务劢动励劲劳势勋勐勚匀匦匮区医华协单卖卢卤卧卫却卺厂厅历厉压厌厍厕厢厣厦厨厩厮县参叆叇双发变叙叠叶号叹叽吁后吓吕吗吣吨听启吴呒呓呕呖呗员呙呛呜咏咔咙咛咝咤咴咸哌响哑哒哓哔哕哗哙哜哝哟唛唝唠唡唢唣唤唿啧啬啭啮啰啴啸喷喽喾嗫呵嗳嘘嘤嘱噜噼嚣嚯团园囱围囵国图圆圣圹场坂坏块坚坛坜坝坞坟坠垄垅垆垒垦垧垩垫垭垯垱垲垴埘埙埚埝埯堑堕塆墙壮声壳壶壸处备复够头夸夹夺奁奂奋奖奥妆妇妈妩妪妫姗姜娄娅娆娇娈娱娲娴婳婴婵婶媪嫒嫔嫱嬷孙学孪宁宝实宠审宪宫宽宾寝对寻导寿将尔尘尧尴尸尽层屃屉届属屡屦屿岁岂岖岗岘岙岚岛岭岳岽岿峃峄峡峣峤峥峦崂崃崄崭嵘嵚嵛嵝嵴巅巩巯币帅师帏帐帘帜带帧帮帱帻帼幂幞干并广庄庆庐庑库应庙庞废庼廪开异弃张弥弪弯弹强归当录彟彦彻径徕御忆忏忧忾怀态怂怃怄怅怆怜总怼怿恋恳恶恸恹恺恻恼恽悦悫悬悭悯惊惧惨惩惫惬惭惮惯愍愠愤愦愿慑慭憷懑懒懔戆戋戏戗战戬户扎扑扦执扩扪扫扬扰抚抛抟抠抡抢护报担拟拢拣拥拦拧拨择挂挚挛挜挝挞挟挠挡挢挣挤挥挦捞损捡换捣据捻掳掴掷掸掺掼揸揽揿搀搁搂搅携摄摅摆摇摈摊撄撑撵撷撸撺擞攒敌敛数斋斓斗斩断无旧时旷旸昙昼昽显晋晒晓晔晕晖暂暧札术朴机杀杂权条来杨杩杰极构枞枢枣枥枧枨枪枫枭柜柠柽栀栅标栈栉栊栋栌栎栏树栖样栾桊桠桡桢档桤桥桦桧桨桩梦梼梾检棂椁椟椠椤椭楼榄榇榈榉槚槛槟槠横樯樱橥橱橹橼檐檩欢欤欧歼殁殇残殒殓殚殡殴毁毂毕毙毡毵氇气氢氩氲汇汉污汤汹沓沟没沣沤沥沦沧沨沩沪沵泞泪泶泷泸泺泻泼泽泾洁洒洼浃浅浆浇浈浉浊测浍济浏浐浑浒浓浔浕涂涌涛涝涞涟涠涡涢涣涤润涧涨涩淀渊渌渍渎渐渑渔渖渗温游湾湿溃溅溆溇滗滚滞滟滠满滢滤滥滦滨滩滪漤潆潇潋潍潜潴澜濑濒灏灭灯灵灾灿炀炉炖炜炝点炼炽烁烂烃烛烟烦烧烨烩烫烬热焕焖焘煅煳熘爱爷牍牦牵牺犊犟状犷犸犹狈狍狝狞独狭狮狯狰狱狲猃猎猕猡猪猫猬献獭玑玙玚玛玮环现玱玺珉珏珐珑珰珲琎琏琐琼瑶瑷璇璎瓒瓮瓯电画畅畲畴疖疗疟疠疡疬疮疯疱疴痈痉痒痖痨痪痫痴瘅瘆瘗瘘瘪瘫瘾瘿癞癣癫癯皑皱皲盏盐监盖盗盘眍眦眬着睁睐睑瞒瞩矫矶矾矿砀码砖砗砚砜砺砻砾础硁硅硕硖硗硙硚确硷碍碛碜碱碹磙礼祎祢祯祷祸禀禄禅离秃秆种积称秽秾稆税稣稳穑穷窃窍窑窜窝窥窦窭竖竞笃笋笔笕笺笼笾筑筚筛筜筝筹签简箓箦箧箨箩箪箫篑篓篮篱簖籁籴类籼粜粝粤粪粮糁糇紧絷纟纠纡红纣纤纥约级纨纩纪纫纬纭纮纯纰纱纲纳纴纵纶纷纸纹纺纻纼纽纾线绀绁绂练组绅细织终绉绊绋绌绍绎经绐绑绒结绔绕绖绗绘给绚绛络绝绞统绠绡绢绣绤绥绦继绨绩绪绫绬续绮绯绰绱绲绳维绵绶绷绸绹绺绻综绽绾绿缀缁缂缃缄缅缆缇缈缉缊缋缌缍缎缏缐缑缒缓缔缕编缗缘缙缚缛缜缝缞缟缠缡缢缣缤缥缦缧缨缩缪缫缬缭缮缯缰缱缲缳缴缵罂网罗罚罢罴羁羟羡翘翙翚耢耧耸耻聂聋职聍联聩聪肃肠肤肷肾肿胀胁胆胜胧胨胪胫胶脉脍脏脐脑脓脔脚脱脶脸腊腌腘腭腻腼腽腾膑臜舆舣舰舱舻艰艳艹艺节芈芗芜芦苁苇苈苋苌苍苎苏苘苹茎茏茑茔茕茧荆荐荙荚荛荜荞荟荠荡荣荤荥荦荧荨荩荪荫荬荭荮药莅莜莱莲莳莴莶获莸莹莺莼萚萝萤营萦萧萨葱蒇蒉蒋蒌蓝蓟蓠蓣蓥蓦蔷蔹蔺蔼蕲蕴薮藁藓虏虑虚虫虬虮虽虾虿蚀蚁蚂蚕蚝蚬蛊蛎蛏蛮蛰蛱蛲蛳蛴蜕蜗蜡蝇蝈蝉蝎蝼蝾螀螨蟏衅衔补衬衮袄袅袆袜袭袯装裆裈裢裣裤裥褛褴襁襕见观觃规觅视觇览觉觊觋觌觍觎觏觐觑觞触觯詟誉誊讠计订讣认讥讦讧讨让讪讫训议讯记讱讲讳讴讵讶讷许讹论讻讼讽设访诀证诂诃评诅识诇诈诉诊诋诌词诎诏诐译诒诓诔试诖诗诘诙诚诛诜话诞诟诠诡询诣诤该详诧诨诩诪诫诬语诮误诰诱诲诳说诵诶请诸诹诺读诼诽课诿谀谁谂调谄谅谆谇谈谊谋谌谍谎谏谐谑谒谓谔谕谖谗谘谙谚谛谜谝谞谟谠谡谢谣谤谥谦谧谨谩谪谫谬谭谮谯谰谱谲谳谴谵谶谷豮贝贞负贠贡财责贤败账货质贩贪贫贬购贮贯贰贱贲贳贴贵贶贷贸费贺贻贼贽贾贿赀赁赂赃资赅赆赇赈赉赊赋赌赍赎赏赐赑赒赓赔赕赖赗赘赙赚赛赜赝赞赟赠赡赢赣赪赵赶趋趱趸跃跄跖跞践跶跷跸跹跻踊踌踪踬踯蹑蹒蹰蹿躏躜躯车轧轨轩轪轫转轭轮软轰轱轲轳轴轵轶轷轸轹轺轻轼载轾轿辀辁辂较辄辅辆辇辈辉辊辋辌辍辎辏辐辑辒输辔辕辖辗辘辙辚辞辩辫边辽达迁过迈运还这进远违连迟迩迳迹适选逊递逦逻遗遥邓邝邬邮邹邺邻郁郄郏郐郑郓郦郧郸酝酦酱酽酾酿释里鉅鉴銮錾钆钇针钉钊钋钌钍钎钏钐钑钒钓钔钕钖钗钘钙钚钛钝钞钟钠钡钢钣钤钥钦钧钨钩钪钫钬钭钮钯钰钱钲钳钴钵钶钷钸钹钺钻钼钽钾钿铀铁铂铃铄铅铆铈铉铊铋铍铎铏铐铑铒铕铗铘铙铚铛铜铝铞铟铠铡铢铣铤铥铦铧铨铪铫铬铭铮铯铰铱铲铳铴铵银铷铸铹铺铻铼铽链铿销锁锂锃锄锅锆锇锈锉锊锋锌锍锎锏锐锑锒锓锔锕锖锗错锚锜锞锟锠锡锢锣锤锥锦锨锩锫锬锭键锯锰锱锲锳锴锵锶锷锸锹锺锻锼锽锾锿镀镁镂镃镆镇镈镉镊镌镍镎镏镐镑镒镕镖镗镙镚镛镜镝镞镟镠镡镢镣镤镥镦镧镨镩镪镫镬镭镮镯镰镱镲镳镴镶长门闩闪闫闬闭问闯闰闱闲闳间闵闶闷闸闹闺闻闼闽闾闿阀阁阂阃阄阅阆阇阈阉阊阋阌阍阎阏阐阑阒阓阔阕阖阗阘阙阚阛队阳阴阵阶际陆陇陈陉陕陧陨险随隐隶隽难雏雠雳雾霁霉霭靓静靥鞑鞒鞯鞴韦韧韨韩韪韫韬韵页顶顷顸项顺须顼顽顾顿颀颁颂颃预颅领颇颈颉颊颋颌颍颎颏颐频颒颓颔颕颖颗题颙颚颛颜额颞颟颠颡颢颣颤颥颦颧风飏飐飑飒飓飔飕飖飗飘飙飚飞飨餍饤饥饦饧饨饩饪饫饬饭饮饯饰饱饲饳饴饵饶饷饸饹饺饻饼饽饾饿馀馁馂馃馄馅馆馇馈馉馊馋馌馍馎馏馐馑馒馓馔馕马驭驮驯驰驱驲驳驴驵驶驷驸驹驺驻驼驽驾驿骀骁骂骃骄骅骆骇骈骉骊骋验骍骎骏骐骑骒骓骔骕骖骗骘骙骚骛骜骝骞骟骠骡骢骣骤骥骦骧髅髋髌鬓魇魉鱼鱽鱾鱿鲀鲁鲂鲄鲅鲆鲇鲈鲉鲊鲋鲌鲍鲎鲏鲐鲑鲒鲓鲔鲕鲖鲗鲘鲙鲚鲛鲜鲝鲞鲟鲠鲡鲢鲣鲤鲥鲦鲧鲨鲩鲪鲫鲬鲭鲮鲯鲰鲱鲲鲳鲴鲵鲶鲷鲸鲹鲺鲻鲼鲽鲾鲿鳀鳁鳂鳃鳄鳅鳆鳇鳈鳉鳊鳋鳌鳍鳎鳏鳐鳑鳒鳓鳔鳕鳖鳗鳘鳙鳛鳜鳝鳞鳟鳠鳡鳢鳣鸟鸠鸡鸢鸣鸤鸥鸦鸧鸨鸩鸪鸫鸬鸭鸮鸯鸰鸱鸲鸳鸴鸵鸶鸷鸸鸹鸺鸻鸼鸽鸾鸿鹀鹁鹂鹃鹄鹅鹆鹇鹈鹉鹊鹋鹌鹍鹎鹏鹐鹑鹒鹓鹔鹕鹖鹗鹘鹚鹛鹜鹝鹞鹟鹠鹡鹢鹣鹤鹥鹦鹧鹨鹩鹪鹫鹬鹭鹯鹰鹱鹲鹳鹴鹾麦麸黄黉黡黩黪黾鼋鼌鼍鼗鼹齄齐齑齿龀龁龂龃龄龅龆龇龈龉龊龋龌龙龚龛龟志制咨只里系范松没尝尝闹面准钟别闲干尽脏拼"
-TRADITION = "萬與醜專業叢東絲丟兩嚴喪個爿豐臨為麗舉麼義烏樂喬習鄉書買亂爭於虧雲亙亞產畝親褻嚲億僅從侖倉儀們價眾優夥會傴傘偉傳傷倀倫傖偽佇體餘傭僉俠侶僥偵側僑儈儕儂俁儔儼倆儷儉債傾傯僂僨償儻儐儲儺兒兌兗黨蘭關興茲養獸囅內岡冊寫軍農塚馮衝決況凍淨淒涼淩減湊凜幾鳳鳧憑凱擊氹鑿芻劃劉則剛創刪別剗剄劊劌剴劑剮劍剝劇勸辦務勱動勵勁勞勢勳猛勩勻匭匱區醫華協單賣盧鹵臥衛卻巹廠廳曆厲壓厭厙廁廂厴廈廚廄廝縣參靉靆雙發變敘疊葉號歎嘰籲後嚇呂嗎唚噸聽啟吳嘸囈嘔嚦唄員咼嗆嗚詠哢嚨嚀噝吒噅鹹呱響啞噠嘵嗶噦嘩噲嚌噥喲嘜嗊嘮啢嗩唕喚呼嘖嗇囀齧囉嘽嘯噴嘍嚳囁嗬噯噓嚶囑嚕劈囂謔團園囪圍圇國圖圓聖壙場阪壞塊堅壇壢壩塢墳墜壟壟壚壘墾坰堊墊埡墶壋塏堖塒塤堝墊垵塹墮壪牆壯聲殼壺壼處備復夠頭誇夾奪奩奐奮獎奧妝婦媽嫵嫗媯姍薑婁婭嬈嬌孌娛媧嫻嫿嬰嬋嬸媼嬡嬪嬙嬤孫學孿寧寶實寵審憲宮寬賓寢對尋導壽將爾塵堯尷屍盡層屭屜屆屬屢屨嶼歲豈嶇崗峴嶴嵐島嶺嶽崠巋嶨嶧峽嶢嶠崢巒嶗崍嶮嶄嶸嶔崳嶁脊巔鞏巰幣帥師幃帳簾幟帶幀幫幬幘幗冪襆幹並廣莊慶廬廡庫應廟龐廢廎廩開異棄張彌弳彎彈強歸當錄彠彥徹徑徠禦憶懺憂愾懷態慫憮慪悵愴憐總懟懌戀懇惡慟懨愷惻惱惲悅愨懸慳憫驚懼慘懲憊愜慚憚慣湣慍憤憒願懾憖怵懣懶懍戇戔戲戧戰戩戶紮撲扡執擴捫掃揚擾撫拋摶摳掄搶護報擔擬攏揀擁攔擰撥擇掛摯攣掗撾撻挾撓擋撟掙擠揮撏撈損撿換搗據撚擄摑擲撣摻摜摣攬撳攙擱摟攪攜攝攄擺搖擯攤攖撐攆擷擼攛擻攢敵斂數齋斕鬥斬斷無舊時曠暘曇晝曨顯晉曬曉曄暈暉暫曖劄術樸機殺雜權條來楊榪傑極構樅樞棗櫪梘棖槍楓梟櫃檸檉梔柵標棧櫛櫳棟櫨櫟欄樹棲樣欒棬椏橈楨檔榿橋樺檜槳樁夢檮棶檢欞槨櫝槧欏橢樓欖櫬櫚櫸檟檻檳櫧橫檣櫻櫫櫥櫓櫞簷檁歡歟歐殲歿殤殘殞殮殫殯毆毀轂畢斃氈毿氌氣氫氬氳彙漢汙湯洶遝溝沒灃漚瀝淪滄渢溈滬濔濘淚澩瀧瀘濼瀉潑澤涇潔灑窪浹淺漿澆湞溮濁測澮濟瀏滻渾滸濃潯濜塗湧濤澇淶漣潿渦溳渙滌潤澗漲澀澱淵淥漬瀆漸澠漁瀋滲溫遊灣濕潰濺漵漊潷滾滯灩灄滿瀅濾濫灤濱灘澦濫瀠瀟瀲濰潛瀦瀾瀨瀕灝滅燈靈災燦煬爐燉煒熗點煉熾爍爛烴燭煙煩燒燁燴燙燼熱煥燜燾煆糊溜愛爺牘犛牽犧犢強狀獷獁猶狽麅獮獰獨狹獅獪猙獄猻獫獵獼玀豬貓蝟獻獺璣璵瑒瑪瑋環現瑲璽瑉玨琺瓏璫琿璡璉瑣瓊瑤璦璿瓔瓚甕甌電畫暢佘疇癤療瘧癘瘍鬁瘡瘋皰屙癰痙癢瘂癆瘓癇癡癉瘮瘞瘺癟癱癮癭癩癬癲臒皚皺皸盞鹽監蓋盜盤瞘眥矓著睜睞瞼瞞矚矯磯礬礦碭碼磚硨硯碸礪礱礫礎硜矽碩硤磽磑礄確鹼礙磧磣堿镟滾禮禕禰禎禱禍稟祿禪離禿稈種積稱穢穠穭稅穌穩穡窮竊竅窯竄窩窺竇窶豎競篤筍筆筧箋籠籩築篳篩簹箏籌簽簡籙簀篋籜籮簞簫簣簍籃籬籪籟糴類秈糶糲粵糞糧糝餱緊縶糸糾紆紅紂纖紇約級紈纊紀紉緯紜紘純紕紗綱納紝縱綸紛紙紋紡紵紖紐紓線紺絏紱練組紳細織終縐絆紼絀紹繹經紿綁絨結絝繞絰絎繪給絢絳絡絕絞統綆綃絹繡綌綏絛繼綈績緒綾緓續綺緋綽緔緄繩維綿綬繃綢綯綹綣綜綻綰綠綴緇緙緗緘緬纜緹緲緝縕繢緦綞緞緶線緱縋緩締縷編緡緣縉縛縟縝縫縗縞纏縭縊縑繽縹縵縲纓縮繆繅纈繚繕繒韁繾繰繯繳纘罌網羅罰罷羆羈羥羨翹翽翬耮耬聳恥聶聾職聹聯聵聰肅腸膚膁腎腫脹脅膽勝朧腖臚脛膠脈膾髒臍腦膿臠腳脫腡臉臘醃膕齶膩靦膃騰臏臢輿艤艦艙艫艱豔艸藝節羋薌蕪蘆蓯葦藶莧萇蒼苧蘇檾蘋莖蘢蔦塋煢繭荊薦薘莢蕘蓽蕎薈薺蕩榮葷滎犖熒蕁藎蓀蔭蕒葒葤藥蒞蓧萊蓮蒔萵薟獲蕕瑩鶯蓴蘀蘿螢營縈蕭薩蔥蕆蕢蔣蔞藍薊蘺蕷鎣驀薔蘞藺藹蘄蘊藪槁蘚虜慮虛蟲虯蟣雖蝦蠆蝕蟻螞蠶蠔蜆蠱蠣蟶蠻蟄蛺蟯螄蠐蛻蝸蠟蠅蟈蟬蠍螻蠑螿蟎蠨釁銜補襯袞襖嫋褘襪襲襏裝襠褌褳襝褲襇褸襤繈襴見觀覎規覓視覘覽覺覬覡覿覥覦覯覲覷觴觸觶讋譽謄訁計訂訃認譏訐訌討讓訕訖訓議訊記訒講諱謳詎訝訥許訛論訩訟諷設訪訣證詁訶評詛識詗詐訴診詆謅詞詘詔詖譯詒誆誄試詿詩詰詼誠誅詵話誕詬詮詭詢詣諍該詳詫諢詡譸誡誣語誚誤誥誘誨誑說誦誒請諸諏諾讀諑誹課諉諛誰諗調諂諒諄誶談誼謀諶諜謊諫諧謔謁謂諤諭諼讒諮諳諺諦謎諞諝謨讜謖謝謠謗諡謙謐謹謾謫譾謬譚譖譙讕譜譎讞譴譫讖穀豶貝貞負貟貢財責賢敗賬貨質販貪貧貶購貯貫貳賤賁貰貼貴貺貸貿費賀貽賊贄賈賄貲賃賂贓資賅贐賕賑賚賒賦賭齎贖賞賜贔賙賡賠賧賴賵贅賻賺賽賾贗讚贇贈贍贏贛赬趙趕趨趲躉躍蹌蹠躒踐躂蹺蹕躚躋踴躊蹤躓躑躡蹣躕躥躪躦軀車軋軌軒軑軔轉軛輪軟轟軲軻轤軸軹軼軤軫轢軺輕軾載輊轎輈輇輅較輒輔輛輦輩輝輥輞輬輟輜輳輻輯轀輸轡轅轄輾轆轍轔辭辯辮邊遼達遷過邁運還這進遠違連遲邇逕跡適選遜遞邐邏遺遙鄧鄺鄔郵鄒鄴鄰鬱郤郟鄶鄭鄆酈鄖鄲醞醱醬釅釃釀釋裏钜鑒鑾鏨釓釔針釘釗釙釕釷釺釧釤鈒釩釣鍆釹鍚釵鈃鈣鈈鈦鈍鈔鍾鈉鋇鋼鈑鈐鑰欽鈞鎢鉤鈧鈁鈥鈄鈕鈀鈺錢鉦鉗鈷缽鈳鉕鈽鈸鉞鑽鉬鉭鉀鈿鈾鐵鉑鈴鑠鉛鉚鈰鉉鉈鉍鈹鐸鉶銬銠鉺銪鋏鋣鐃銍鐺銅鋁銱銦鎧鍘銖銑鋌銩銛鏵銓鉿銚鉻銘錚銫鉸銥鏟銃鐋銨銀銣鑄鐒鋪鋙錸鋱鏈鏗銷鎖鋰鋥鋤鍋鋯鋨鏽銼鋝鋒鋅鋶鐦鐧銳銻鋃鋟鋦錒錆鍺錯錨錡錁錕錩錫錮鑼錘錐錦鍁錈錇錟錠鍵鋸錳錙鍥鍈鍇鏘鍶鍔鍤鍬鍾鍛鎪鍠鍰鎄鍍鎂鏤鎡鏌鎮鎛鎘鑷鐫鎳鎿鎦鎬鎊鎰鎔鏢鏜鏍鏰鏞鏡鏑鏃鏇鏐鐔钁鐐鏷鑥鐓鑭鐠鑹鏹鐙鑊鐳鐶鐲鐮鐿鑔鑣鑞鑲長門閂閃閆閈閉問闖閏闈閑閎間閔閌悶閘鬧閨聞闥閩閭闓閥閣閡閫鬮閱閬闍閾閹閶鬩閿閽閻閼闡闌闃闠闊闋闔闐闒闕闞闤隊陽陰陣階際陸隴陳陘陝隉隕險隨隱隸雋難雛讎靂霧霽黴靄靚靜靨韃鞽韉韝韋韌韍韓韙韞韜韻頁頂頃頇項順須頊頑顧頓頎頒頌頏預顱領頗頸頡頰頲頜潁熲頦頤頻頮頹頷頴穎顆題顒顎顓顏額顳顢顛顙顥纇顫顬顰顴風颺颭颮颯颶颸颼颻飀飄飆飆飛饗饜飣饑飥餳飩餼飪飫飭飯飲餞飾飽飼飿飴餌饒餉餄餎餃餏餅餑餖餓餘餒餕餜餛餡館餷饋餶餿饞饁饃餺餾饈饉饅饊饌饢馬馭馱馴馳驅馹駁驢駔駛駟駙駒騶駐駝駑駕驛駘驍罵駰驕驊駱駭駢驫驪騁驗騂駸駿騏騎騍騅騌驌驂騙騭騤騷騖驁騮騫騸驃騾驄驏驟驥驦驤髏髖髕鬢魘魎魚魛魢魷魨魯魴魺鮁鮃鯰鱸鮋鮓鮒鮊鮑鱟鮍鮐鮭鮚鮳鮪鮞鮦鰂鮜鱠鱭鮫鮮鮺鯗鱘鯁鱺鰱鰹鯉鰣鰷鯀鯊鯇鮶鯽鯒鯖鯪鯕鯫鯡鯤鯧鯝鯢鯰鯛鯨鯵鯴鯔鱝鰈鰏鱨鯷鰮鰃鰓鱷鰍鰒鰉鰁鱂鯿鰠鼇鰭鰨鰥鰩鰟鰜鰳鰾鱈鱉鰻鰵鱅鰼鱖鱔鱗鱒鱯鱤鱧鱣鳥鳩雞鳶鳴鳲鷗鴉鶬鴇鴆鴣鶇鸕鴨鴞鴦鴒鴟鴝鴛鴬鴕鷥鷙鴯鴰鵂鴴鵃鴿鸞鴻鵐鵓鸝鵑鵠鵝鵒鷳鵜鵡鵲鶓鵪鶤鵯鵬鵮鶉鶊鵷鷫鶘鶡鶚鶻鶿鶥鶩鷊鷂鶲鶹鶺鷁鶼鶴鷖鸚鷓鷚鷯鷦鷲鷸鷺鸇鷹鸌鸏鸛鸘鹺麥麩黃黌黶黷黲黽黿鼂鼉鞀鼴齇齊齏齒齔齕齗齟齡齙齠齜齦齬齪齲齷龍龔龕龜誌製谘隻裡係範鬆冇嚐嘗鬨麵準鐘彆閒乾儘臟拚"
-
-
-def toTraditionString(msg: str) -> str:
- '''
- 简体转繁体。
-
- :return: str
- '''
- output_str_list = []
- str_len = len(msg)
-
- for i in range(str_len):
- found_index = SIMPLE.find(msg[i])
-
- if not (found_index == -1):
- output_str_list.append(TRADITION[found_index])
-
- else:
- output_str_list.append(msg[i])
-
- return "".join(output_str_list)
-
-
-def toSimpleString(msg: str) -> str:
- '''
- 繁体转简体。
-
- :return: str
- '''
- output_str_list = []
- str_len = len(msg)
-
- for i in range(str_len):
- found_index = TRADITION.find(msg[i])
-
- if not (found_index == -1):
- output_str_list.append(SIMPLE[found_index])
-
- else:
- output_str_list.append(msg[i])
-
- return "".join(output_str_list)
diff --git a/ATRI/utils/utils_yml/__init__.py b/ATRI/utils/utils_yml/__init__.py
deleted file mode 100644
index 2617a21..0000000
--- a/ATRI/utils/utils_yml/__init__.py
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/env python3
-# -*- encoding: utf-8 -*-
-'''
-@File : __init__.py
-@Time : 2020/11/06 22:26:06
-@Author : Kyomotoi
-@Contact : [email protected]
-@Github : https://github.com/Kyomotoi
-@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved.
-'''
-__author__ = 'kyomotoi'
-
-import yaml
-from pathlib import Path
-
-
-def load_yaml(file: Path) -> dict:
- '''
- 读取yaml文件
-
- :return: dict
- '''
- with open(file, 'r', encoding='utf-8') as f:
- data = yaml.safe_load(f)
- return data