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