diff options
author | Kyomotoi <[email protected]> | 2022-02-06 11:29:17 +0800 |
---|---|---|
committer | Kyomotoi <[email protected]> | 2022-02-06 11:29:44 +0800 |
commit | e1f2f0e3d108ce752c1601cecef49217ed4aff7b (patch) | |
tree | 823949845b1c2d5a592d9f6135d83e5b6dedb098 | |
parent | 28cc7c5d25f8b6d8ddd1f7729b5126e2cfc7aee8 (diff) | |
download | ATRI-e1f2f0e3d108ce752c1601cecef49217ed4aff7b.tar.gz ATRI-e1f2f0e3d108ce752c1601cecef49217ed4aff7b.tar.bz2 ATRI-e1f2f0e3d108ce752c1601cecef49217ed4aff7b.zip |
🚸💡 改善涩图体验
-rw-r--r-- | ATRI/plugins/setu/__init__.py | 35 | ||||
-rw-r--r-- | ATRI/plugins/wife/__init__.py | 13 |
2 files changed, 23 insertions, 25 deletions
diff --git a/ATRI/plugins/setu/__init__.py b/ATRI/plugins/setu/__init__.py index 2f44222..009b23d 100644 --- a/ATRI/plugins/setu/__init__.py +++ b/ATRI/plugins/setu/__init__.py @@ -13,34 +13,28 @@ from ATRI.utils.apscheduler import scheduler from .data_source import Setu -loop = asyncio.get_event_loop() - - random_setu = Setu().on_command("来张涩图", "来张随机涩图,冷却2分钟", aliases={"涩图来", "来点涩图", "来份涩图"}) -@random_setu.handle([Cooldown(120)]) +@random_setu.handle() async def _random_setu( - bot: Bot, event: MessageEvent, matcher: Matcher, args: Message = CommandArg() -): + bot: Bot, event: MessageEvent +): + loop = asyncio.get_running_loop() + repo, setu = await Setu().random_setu() await bot.send(event, repo) - msg_1 = dict() try: msg_1 = await bot.send(event, Message(setu)) except Exception: await random_setu.finish("hso(发不出") - msg = args.extract_plain_text() - if msg: - matcher.set_arg("r_rush_after_think", args) - event_id = msg_1["message_id"] loop.create_task(Setu().async_recall(bot, event_id)) -@random_setu.got("r_rush_after_think") +@random_setu.got("r_rush_after_think", prompt="看完不来点感想么-w-", parameterless=[Cooldown(120)]) async def _(think: str = ArgPlainText("r_rush_after_think")): is_repo = will_think(think) if not is_repo: @@ -52,11 +46,13 @@ async def _(think: str = ArgPlainText("r_rush_after_think")): tag_setu = Setu().on_regex(r"来[张点丶份](.*?)的[涩色🐍]图", "根据提供的tag查找涩图,冷却2分钟") -@tag_setu.handle([Cooldown(120)]) +@tag_setu.handle([Cooldown(5, prompt="慢...慢一..点❤")]) async def _tag_setu( - bot: Bot, event: MessageEvent, matcher: Matcher, args: Message = CommandArg() -): - msg = str(event.message).strip() + bot: Bot, event: MessageEvent +): + loop = asyncio.get_running_loop() + + msg = str(event.get_message()).strip() pattern = r"来[张点丶份](.*?)的[涩色🐍]图" tag = re.findall(pattern, msg)[0] repo, setu = await Setu().tag_setu(tag) @@ -65,21 +61,16 @@ async def _tag_setu( await bot.send(event, repo) - msg_1 = dict() try: msg_1 = await bot.send(event, Message(setu)) except Exception: await random_setu.finish("hso(发不出") - msg = args.extract_plain_text() - if msg: - matcher.set_arg("r_rush_after_think", args) - event_id = msg_1["message_id"] loop.create_task(Setu().async_recall(bot, event_id)) -@tag_setu.got("t_rush_after_think") +@tag_setu.got("t_rush_after_think", prompt="看完不来点感想么-w-", parameterless=[Cooldown(120)]) async def _(think: str = ArgPlainText("t_rush_after_think")): is_repo = will_think(think) if not is_repo: diff --git a/ATRI/plugins/wife/__init__.py b/ATRI/plugins/wife/__init__.py index ff0f354..bebc885 100644 --- a/ATRI/plugins/wife/__init__.py +++ b/ATRI/plugins/wife/__init__.py @@ -87,28 +87,33 @@ async def _get_wife(bot: Bot, event: GroupMessageEvent): await bot.send(event, repo_0) await asyncio.sleep(10) + # 获取群成员列表 prep_list = await bot.get_group_member_list(group_id=group_id) prep_list = [prep.get("user_id", 114514) for prep in prep_list] + # 随机抽取群友 lucky_user = choice(prep_list) lucky_user_info: dict = await bot.get_group_member_info( group_id=group_id, user_id=lucky_user ) + + # 获取幸运群友信息 lucky_user_card = lucky_user_info["card"] if not lucky_user_card: lucky_user_card = lucky_user_info["nickname"] lucky_user_sex = lucky_user_info["sex"] + # 存储配对信息 data[str(lucky_user)] = MarryInfo( - name=req_user_card, sex=is_nick, wife=user_id + name=req_user_card, sex=req_user_sex, wife=user_id ).dict() data[user_id] = MarryInfo( name=lucky_user_card, sex=lucky_user_sex, wife=str(lucky_user) ).dict() Wife().save_marry_list(data) - repo_1 = f"好欸!{lucky_user_card}成为了{req_user_card}的{is_nick}" + repo_1 = f"好欸!{lucky_user_card}({lucky_user}) 成为了 {req_user_card}({user_id}) 的 {is_nick}" await get_wife.finish(repo_1) @@ -124,9 +129,11 @@ async def _call_wife(event: MessageEvent): return wife = data[user_id].get("name", "ignore") + wife_id = data[user_id].get("wife", "114514") + sex = data[user_id].get("sex", "male") is_nick = "老公" if sex == "male" else "老婆" - repo = f"你已经有{is_nick}啦!是{wife}噢~" + repo = f"你已经有{is_nick}啦!是 {wife}({wife_id}) 噢~" await call_wife.finish(repo) |