summaryrefslogtreecommitdiff
path: root/ATRI
diff options
context:
space:
mode:
Diffstat (limited to 'ATRI')
-rw-r--r--ATRI/__init__.py11
-rw-r--r--ATRI/data/data_IDcard/main.binbin0 -> 3992353 bytes
-rw-r--r--ATRI/plugins/plugin_admin/__init__.py20
-rw-r--r--ATRI/plugins/plugin_anime/__init__.py114
-rw-r--r--ATRI/plugins/plugin_anime/body.py11
-rw-r--r--ATRI/plugins/plugin_chat/__init__.py92
-rw-r--r--ATRI/plugins/plugin_pixiv/__init__.py203
-rw-r--r--ATRI/plugins/plugin_rich/__init__.py12
-rw-r--r--ATRI/plugins/plugin_rich/body.py11
-rw-r--r--ATRI/plugins/plugin_status/__init__.py11
-rw-r--r--ATRI/plugins/plugin_test/__init__.py47
-rw-r--r--ATRI/plugins/plugin_test/test.mp3bin0 -> 4029360 bytes
-rw-r--r--ATRI/plugins/plugin_utils/__init__.py88
13 files changed, 587 insertions, 33 deletions
diff --git a/ATRI/__init__.py b/ATRI/__init__.py
index 4fe81ba..fd5b8f6 100644
--- a/ATRI/__init__.py
+++ b/ATRI/__init__.py
@@ -1,5 +1,14 @@
#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
+# -*- 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
diff --git a/ATRI/data/data_IDcard/main.bin b/ATRI/data/data_IDcard/main.bin
new file mode 100644
index 0000000..6e74a60
--- /dev/null
+++ b/ATRI/data/data_IDcard/main.bin
Binary files differ
diff --git a/ATRI/plugins/plugin_admin/__init__.py b/ATRI/plugins/plugin_admin/__init__.py
index 3a7175c..3a3c259 100644
--- a/ATRI/plugins/plugin_admin/__init__.py
+++ b/ATRI/plugins/plugin_admin/__init__.py
@@ -1,5 +1,14 @@
#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
+# -*- encoding: utf-8 -*-
+'''
+@File : __init__.py
+@Time : 2020/10/11 14:37:53
+@Author : Kyomotoi
+@Contact : [email protected]
+@Github : https://github.com/Kyomotoi
+@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved.
+'''
+__author__ = 'kyomotoi'
import re
@@ -36,14 +45,15 @@ async def _(bot: Bot, event: Event, state: dict) -> None:
msg0 += "└Service:\n"
msg0 += " ├anime-setu\n"
msg0 += " ├anime-pic-search\n"
- msg0 += " └anime-vid-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)
- print(func, funct)
-
- print(type(master[0]), type(user))
if "all-on" in func:
if int(user) in master:
diff --git a/ATRI/plugins/plugin_anime/__init__.py b/ATRI/plugins/plugin_anime/__init__.py
index 7abf59d..c15fc14 100644
--- a/ATRI/plugins/plugin_anime/__init__.py
+++ b/ATRI/plugins/plugin_anime/__init__.py
@@ -1,5 +1,14 @@
#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
+# -*- encoding: utf-8 -*-
+'''
+@File : __init__.py
+@Time : 2020/10/11 14:38:14
+@Author : Kyomotoi
+@Contact : [email protected]
+@Github : https://github.com/Kyomotoi
+@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved.
+'''
+__author__ = 'kyomotoi'
import re
import json
@@ -8,8 +17,9 @@ from pathlib import Path
from random import randint
from nonebot.log import logger
-from nonebot.adapters.cqhttp import Bot, Event
+from nonebot import scheduler
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
@@ -17,6 +27,7 @@ from utils.utils_error import errorRepo
from utils.utils_history import getMessage
from utils.utils_switch import checkSwitch
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
@@ -229,19 +240,13 @@ setu_type = 1 # setu-type: 1(local), 2(url: https://api.lolicon.app/#/setu) def
setu = on_regex(r"来[点丶张份副个幅][涩色瑟][图圖]|[涩色瑟][图圖]来|[涩色瑟][图圖][gkd|GKD|搞快点]|[gkd|GKD|搞快点][涩色瑟][图圖]")
@setu.handle() # type: ignore
-async def _(bot: Bot, event: Event, state: dict) -> None:
+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):
- await bot.send_msg(
- user_id=int(user),
- group_id=int(group),
- message="别急!正在找图!"
- )
-
res = randint(1,5)
if setu_type == 1:
@@ -258,8 +263,8 @@ async def _(bot: Bot, event: Event, state: dict) -> None:
msg0 = f"setu info:\n"
msg0 += f"Title: {title}\n"
msg0 += f"Pid: {pid}\n"
- msg0 += f"{img}"
-
+ msg0 += f"[CQ:image,file=file:///{compress_image(await aio_download_pics(img))}]"
+
if 1 <= res < 5:
await setu.finish(msg0)
@@ -270,9 +275,9 @@ async def _(bot: Bot, event: Event, state: dict) -> None:
message="我找到涩图了!但我发给主人了\nο(=•ω<=)ρ⌒☆"
)
- await bot.send_msg(
+ await bot.send_private_msg(
user_id=ATRI.config_SUPERUSERS,
- message=f"主人,从群{group}来的涩图!热乎着!\nTitle: {title}\nPid: {pid}\n{img}"
+ message=f"主人,从群{group}来的涩图!热乎着!\nTitle: {title}\nPid: {pid}\n[CQ:image,file=file:///{compress_image(await aio_download_pics(img))}]"
)
else:
@@ -282,18 +287,33 @@ async def _(bot: Bot, event: Event, state: dict) -> None:
"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:"
- msg0 += f'Title: {data["data"][0]["title"]}' # type: ignore
- msg0 += f'Pid: {data["data"][0]["pid"]}' # type: ignore
- msg0 += f'{data["data"][0]["url"]}' # type: ignore
+ 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"]))}]'
- await setu.finish(msg0)
-
+ if 1 <= res < 5:
+ await setu.finish(msg0)
+
+ elif res == 5:
+ await bot.send_msg(
+ user_id=int(user),
+ group_id=int(group),
+ message="我找到涩图了!但我发给主人了\nο(=•ω<=)ρ⌒☆"
+ )
+
+ 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"]))}]'
+ )
+
else:
await setu.finish(f"Service-{plugin_name_2} has been closed.")
@@ -326,3 +346,59 @@ async def _(bot: Bot, event: Event, state: dict) -> None:
await setuType.finish("请检查类型是否输入正确嗷!")
await setuType.finish("Type conversion completed!")
+
+
+# @scheduler.scheduled_job(
+# "cron",
+# minute=45,
+# bot=Bot,
+# event=Event,
+# state=dict
+# )
+# async def _(bot: Bot, event: Event, state: dict) -> None:
+# group = str(event.group_id)
+
+# if banList(group=group):
+# if checkSwitch(plugin_name_2, group):
+# # group_list = await bot.get_group_list()
+# # group = sample(group_list, 1)
+# # group = group['group_id']
+
+# 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))}]"
+
+# await setu.finish(msg0)
+
+# 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"]))}]'
+
+# await setu.finish(msg0)
diff --git a/ATRI/plugins/plugin_anime/body.py b/ATRI/plugins/plugin_anime/body.py
index 02c57bb..00ee4ec 100644
--- a/ATRI/plugins/plugin_anime/body.py
+++ b/ATRI/plugins/plugin_anime/body.py
@@ -1,5 +1,14 @@
#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
+# -*- encoding: utf-8 -*-
+'''
+@File : body.py
+@Time : 2020/10/11 14:38:23
+@Author : Kyomotoi
+@Contact : [email protected]
+@Github : https://github.com/Kyomotoi
+@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved.
+'''
+__author__ = 'kyomotoi'
import json
diff --git a/ATRI/plugins/plugin_chat/__init__.py b/ATRI/plugins/plugin_chat/__init__.py
index 6fd7099..fc2a6e2 100644
--- a/ATRI/plugins/plugin_chat/__init__.py
+++ b/ATRI/plugins/plugin_chat/__init__.py
@@ -1,13 +1,27 @@
#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
+# -*- encoding: utf-8 -*-
+'''
+@File : __init__.py
+@Time : 2020/10/11 14:38:38
+@Author : Kyomotoi
+@Contact : [email protected]
+@Github : https://github.com/Kyomotoi
+@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved.
+'''
+__author__ = 'kyomotoi'
+
+from random import choice
from nonebot.log import logger
-from nonebot.plugin import on_message
+from nonebot.rule import to_me
from nonebot.adapters.cqhttp import Bot, Event
+from nonebot.plugin import on_command, on_message, on_notice
+from utils.utils_banList import banList
from utils.utils_history import saveMessage
+# 收集 bot 所在群的聊天记录
MessageSave = on_message()
@MessageSave.handle() # type: ignore
@@ -22,4 +36,76 @@ async def _(bot: Bot, event: Event, state: dict) -> None:
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") \ No newline at end of file
+ logger.opt(colors=True).info(f"[<yellow>{group}</yellow>]-U: (<blue>{user}</blue>) | Message: (<green>{message}</green>) Saved successfully")
+
+
+# Call bot
+callMe = on_message()
+
[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 "ATRI" == msg or "亚托莉" == msg or "アトリ" == msg:
+ await callMe.finish("叫我有啥事吗w")
+
+ elif "萝卜子" in msg:
+ await bot.send(event, "萝卜子是对咱的蔑称!!")
+
+ else:
+ pass
+
+
+
+# 戳 一 戳
+pokehah = on_command("戳一戳", rule=to_me())
+
[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",
+ "我爪巴爪巴,球球别再戳了",
+ "你戳你🐎呢?!",
+ "那...那里...那里不能戳...绝对...",
+ "(。´・ω・)ん?",
+ "有事恁叫我,别天天一个劲戳戳戳!",
+ "欸很烦欸!你戳🔨呢",
+ "?"
+ ])
+
+ 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"])
+
+poke = on_notice(poke_, block=True)
+poke.handle()(_poke)
+
+
+groupEvent = on_notice()
+
[email protected]() # type: ignore
+async def _(bot: Bot, event: Event, state: dict) -> None:
+ group = str(event.group_id)
+ print(event.raw_event)
+
+ 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")
+
+ elif event.raw_event["notice_type"] == "group_decrease":
+ await groupEvent.finish(f'[{event.raw_event["operator_id"]}] 离开了我们...')
diff --git a/ATRI/plugins/plugin_pixiv/__init__.py b/ATRI/plugins/plugin_pixiv/__init__.py
new file mode 100644
index 0000000..5826b49
--- /dev/null
+++ b/ATRI/plugins/plugin_pixiv/__init__.py
@@ -0,0 +1,203 @@
+#!/usr/bin/env python3
+# -*- encoding: utf-8 -*-
+'''
+@File : __init__.py
+@Time : 2020/10/11 14:38:49
+@Author : Kyomotoi
+@Contact : [email protected]
+@Github : https://github.com/Kyomotoi
+@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved.
+'''
+__author__ = 'kyomotoi'
+
+import re
+import json
+
+from nonebot.plugin import on_command
+from nonebot.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
+
+
+plugin_name_0 = "pixiv-pic-search"
+pixivSearchIMG = on_command('p站搜图')
+
[email protected]() # type: ignore
+async def _(bot: Bot, event: Event, state: dict) -> None:
+ user = str(event.user_id)
+ group = str(event.group_id)
+
+ state["user"] = user
+ state["group"] = group
+
+ if banList(user, group):
+ if checkSwitch(plugin_name_0, group):
+ pid = str(event.message).strip()
+
+ if pid:
+ state["pid"] = pid
+ else:
+ await pixivSearchIMG.finish(f"Service-{plugin_name_0} has been closed.")
+
[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)
+
+ if len(pid):
+ pass
+ else:
+ await pixivSearchIMG.reject("请发送纯阿拉伯数字的pid")
+
+ await bot.send_msg(
+ user_id=state["user"],
+ group_id=state["group"],
+ message="别急!在搜索了!"
+ )
+
+ URL = f"https://api.imjad.cn/pixiv/v1/?type=illust&id={pid}"
+ data = {}
+
+ try:
+ 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"
+ msg0 += f'Title {data["response"][0]["title"]}\n'
+ msg0 += f'W&H: {data["response"][0]["width"]}x{data["response"][0]["height"]}\n'
+ msg0 += f'Tags: {data["response"][0]["tags"]}\n'
+ msg0 += f'Account Name: {data["response"][0]["user"]["account"]}\n'
+ msg0 += f'Author Name: {data["response"][0]["user"]["name"]}\n'
+ msg0 += f'Link: https://www.pixiv.net/users/{data["response"][0]["user"]["id"]}\n'
+ msg0 += f'IMG: https://pixiv.cat/{pid}.jpg'
+
+ await pixivSearchIMG.finish(msg0)
+
+
+plugin_name_1 = "pixiv-author-search"
+pixivSearchAuthor = on_command("p站画师")
+
[email protected]() # type: ignore
+async def _(bot: Bot, event: Event, state: dict) -> None:
+ user = str(event.user_id)
+ group = str(event.group_id)
+
+ state["user"] = user
+ state["group"] = group
+
+ if banList(user, group):
+ if checkSwitch(plugin_name_1, group):
+ author_id = str(event.message).strip()
+
+ 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
+async def _(bot: Bot, event: Event, state: dict) -> None:
+ author_id = state["author_id"]
+ author_id = re.findall(r"\d+", author_id)
+
+ if len(author_id):
+ pass
+ else:
+ await pixivSearchAuthor.reject("请发送纯阿拉伯数字的画师id")
+
+ await bot.send_msg(
+ user_id=state["user"],
+ group_id=state["group"],
+ message=f"别急!在搜索了!\n将展示画师[{author_id}]的前三项作品"
+ )
+
+ URL = f"https://api.imjad.cn/pixiv/v1/?type=member_illust&id={author_id}"
+ data = {}
+
+ try:
+ data = json.loads(request_get(URL))
+ except:
+ await pixivSearchAuthor.finish(errorRepo("请求网络失败"))
+
+ 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
+ )
+
+ t = 0
+
+ for i in result:
+ t += 1
+ msg = f"\n---------------\n"
+ 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站排行榜")
+
[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_msg(
+ user_id=int(user),
+ group_id=int(group),
+ message="正在获取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
diff --git a/ATRI/plugins/plugin_rich/__init__.py b/ATRI/plugins/plugin_rich/__init__.py
index 2639188..99026a8 100644
--- a/ATRI/plugins/plugin_rich/__init__.py
+++ b/ATRI/plugins/plugin_rich/__init__.py
@@ -1,10 +1,18 @@
#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
+# -*- encoding: utf-8 -*-
+'''
+@File : __init__.py
+@Time : 2020/10/11 14:40:34
+@Author : Kyomotoi
+@Contact : [email protected]
+@Github : https://github.com/Kyomotoi
+@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved.
+'''
+__author__ = 'kyomotoi'
import re
import json
import requests
-from datetime import datetime
from nonebot.log import logger
from nonebot.plugin import on_message
diff --git a/ATRI/plugins/plugin_rich/body.py b/ATRI/plugins/plugin_rich/body.py
index 2c743c0..ae3d99b 100644
--- a/ATRI/plugins/plugin_rich/body.py
+++ b/ATRI/plugins/plugin_rich/body.py
@@ -1,5 +1,14 @@
#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
+# -*- encoding: utf-8 -*-
+'''
+@File : body.py
+@Time : 2020/10/11 14:40:43
+@Author : Kyomotoi
+@Contact : [email protected]
+@Github : https://github.com/Kyomotoi
+@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved.
+'''
+__author__ = 'kyomotoi'
table='fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF'
tr={}
diff --git a/ATRI/plugins/plugin_status/__init__.py b/ATRI/plugins/plugin_status/__init__.py
index ddd9e60..d51e2e9 100644
--- a/ATRI/plugins/plugin_status/__init__.py
+++ b/ATRI/plugins/plugin_status/__init__.py
@@ -1,5 +1,14 @@
#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
+# -*- encoding: utf-8 -*-
+'''
+@File : __init__.py
+@Time : 2020/10/11 14:40:55
+@Author : Kyomotoi
+@Contact : [email protected]
+@Github : https://github.com/Kyomotoi
+@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved.
+'''
+__author__ = 'kyomotoi'
import psutil
import sqlite3
diff --git a/ATRI/plugins/plugin_test/__init__.py b/ATRI/plugins/plugin_test/__init__.py
new file mode 100644
index 0000000..5a6fe96
--- /dev/null
+++ b/ATRI/plugins/plugin_test/__init__.py
@@ -0,0 +1,47 @@
+# !/usr/bin/env python3
+# -*- encoding: utf-8 -*-
+'''
+@File : __init__.py
+@Time : 2020/10/11 14:35:26
+@Author : Kyomotoi
+@Contact : [email protected]
+@Github : https://github.com/Kyomotoi
+@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved.
+@Desc : None
+'''
+__author__ = 'kyomotoi'
+
+import os
+from pathlib import Path
+from random import sample
+
+import nonebot
+from nonebot.plugin import on_command
+from nonebot.permission import SUPERUSER
+from nonebot.adapters.cqhttp import Bot, Event
+
+
+# 此目录下均为功能测试!
+
+
+testRecord = on_command('测试语音', permission=SUPERUSER)
+
[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')}]")
+
+
+testGroupList = on_command('获取群列表', permission=SUPERUSER)
+
[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
+async def _(bot: Bot, event: Event, state: dict) -> None:
+ test_bot = nonebot.get_bots()
+ print(test_bot, type(test_bot.keys())) \ No newline at end of file
diff --git a/ATRI/plugins/plugin_test/test.mp3 b/ATRI/plugins/plugin_test/test.mp3
new file mode 100644
index 0000000..774cf5d
--- /dev/null
+++ b/ATRI/plugins/plugin_test/test.mp3
Binary files differ
diff --git a/ATRI/plugins/plugin_utils/__init__.py b/ATRI/plugins/plugin_utils/__init__.py
new file mode 100644
index 0000000..54abdeb
--- /dev/null
+++ b/ATRI/plugins/plugin_utils/__init__.py
@@ -0,0 +1,88 @@
+#!/usr/bin/env python3
+# -*- encoding: utf-8 -*-
+'''
+@File : __init__.py
+@Time : 2020/10/17 21:16:59
+@Author : Kyomotoi
+@Contact : [email protected]
+@Github : https://github.com/Kyomotoi
+@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved.
+@Docs : Thanks for mnixry idea! fork from https://github.com/mnixry/coolQPythonBot
+'''
+__author__ = 'kyomotoi'
+
+import os
+import json
+import random
+from pathlib import Path
+from time import strftime
+from zipfile import PyZipFile
+from typing import Tuple, Dict, List
+from datetime import datetime, timedelta
+
+from nonebot.plugin import on_command
+from nonebot.adapters.cqhttp import Bot, Event
+
+from utils.utils_banList import banList
+
+
+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:
+ name = json.loads(f.read().decode())
+ with zipFile.open("area.json", "r") as f:
+ 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
+
+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)]
+ )
+ 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)
+ fullCode += str(checkSum(fullCode))
+ return fullCode
+
+
+plugin_name = "one-key-adult"
+generateID = on_command("我要转大人,一天打25小时游戏")
+
[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)