summaryrefslogtreecommitdiff
path: root/ATRI/plugins/setu/__init__.py
diff options
context:
space:
mode:
author0w0 <0w0@imki.moe>2022-12-29 16:38:27 +0800
committerGitHub <noreply@github.com>2022-12-29 16:38:27 +0800
commitc0e5f0398bd4c3c55378cff303f31ff968822346 (patch)
treed90bc810150d859c76e64f6e71d8524478014f31 /ATRI/plugins/setu/__init__.py
parent3d857da2ae1984c6abf286b55888d6d3e4c5d823 (diff)
parentbb13b38f862d859007d1d37941f5b5c9d5f38cbc (diff)
downloadATRI-c0e5f0398bd4c3c55378cff303f31ff968822346.tar.gz
ATRI-c0e5f0398bd4c3c55378cff303f31ff968822346.tar.bz2
ATRI-c0e5f0398bd4c3c55378cff303f31ff968822346.zip
Merge branch 'main' into main
Diffstat (limited to 'ATRI/plugins/setu/__init__.py')
-rw-r--r--ATRI/plugins/setu/__init__.py37
1 files changed, 17 insertions, 20 deletions
diff --git a/ATRI/plugins/setu/__init__.py b/ATRI/plugins/setu/__init__.py
index 1dea9b4..edb6532 100644
--- a/ATRI/plugins/setu/__init__.py
+++ b/ATRI/plugins/setu/__init__.py
@@ -29,17 +29,17 @@ async def _():
async def _random_setu(bot: Bot, event: MessageEvent):
loop = asyncio.get_running_loop()
- repo, se = await Setu.random_setu()
- await bot.send(event, repo)
+ setu, setu_data = await Setu.new()
+ setu_info = f"Title: {setu_data.title}\nPid: {setu_data.pid}"
+ await bot.send(event, setu_info)
try:
- msg_1 = await bot.send(event, Message(se))
+ msg_1 = await bot.send(event, setu)
except Exception:
- await random_setu.finish("hso(发不出")
+ await random_setu.finish("hso (发不出")
- event_id = msg_1["message_id"]
- loop.create_task(Setu.async_recall(bot, event_id))
- loop.close()
+ msg_id = msg_1["message_id"]
+ loop.call_later(60, lambda: loop.create_task(bot.delete_msg(message_id=msg_id)))
@random_setu.got("r_rush_after_think", prompt="看完不来点感想么-w-")
@@ -54,27 +54,24 @@ async def _(think: str = ArgPlainText("r_rush_after_think")):
tag_setu = plugin.on_regex(r"来[张点丶份](.*?)的[涩色🐍]图", "根据提供的tag查找涩图,冷却2分钟")
-@tag_setu.handle([Cooldown(120, prompt="慢...慢一..点❤")])
+@tag_setu.handle([Cooldown(120, prompt="")])
async def _tag_setu(bot: Bot, event: MessageEvent):
loop = asyncio.get_running_loop()
msg = str(event.get_message()).strip()
pattern = r"来[张点丶份](.*?)的[涩色🐍]图"
tag = re.findall(pattern, msg)[0]
- repo, se = await Setu.tag_setu(tag)
- if not plugin:
- await tag_setu.finish(repo)
-
- await bot.send(event, repo)
+ setu, setu_data = await Setu.new(tag)
+ setu_info = f"Title: {setu_data.title}\nPid: {setu_data.pid}"
+ await bot.send(event, setu_info)
try:
- msg_1 = await bot.send(event, Message(se))
+ msg_1 = await bot.send(event, setu)
except Exception:
- await random_setu.finish("hso(发不出")
+ await random_setu.finish("hso (发不出")
- event_id = msg_1["message_id"]
- loop.create_task(Setu.async_recall(bot, event_id))
- loop.close()
+ msg_id = msg_1["message_id"]
+ loop.call_later(60, lambda: loop.create_task(bot.delete_msg(message_id=msg_id)))
@tag_setu.got("t_rush_after_think", prompt="看完不来点感想么-w-")
@@ -101,7 +98,7 @@ async def _setu_catcher(bot: Bot, event: MessageEvent):
hso = list()
for i in args:
try:
- data = await Setu.detecter(i, _catcher_max_file_size)
+ data = await Setu(i).detecter(_catcher_max_file_size)
except Exception:
return
if data > 0.7:
@@ -140,7 +137,7 @@ async def _deal_check(bot: Bot, event: MessageEvent):
if not args:
await nsfw_checker.reject("请发送图片而不是其他东西!!")
- hso = await Setu.detecter(args[0], _catcher_max_file_size)
+ hso = await Setu(args[0]).detecter(_catcher_max_file_size)
if not hso:
await nsfw_checker.finish("图太小了!不测!")