From 606e185c1ce2515f0375e8a6b2b3c3faeb943bae Mon Sep 17 00:00:00 2001 From: grassblock Date: Mon, 8 Sep 2025 16:47:52 +0800 Subject: [PATCH] feat: stardew valley mod lookup --- adapters/tg.py | 3 ++- core/simple.py | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/adapters/tg.py b/adapters/tg.py index 756167c..8180326 100644 --- a/adapters/tg.py +++ b/adapters/tg.py @@ -22,7 +22,7 @@ from core.promote import handle_promote_command from core.repeater import MessageRepeater from core.report_links import report_broken_links from core.simple import handle_start_command, handle_baka, dummy_handler, handle_info_command, handle_ping_command, \ - handle_tips_command, handle_about_command + handle_tips_command, handle_about_command, handle_nexusmods_id from core.actions import handle_actions, handle_reverse_actions from core.stats import handle_stats_command from core.middleware.stats import MessageStatsMiddleware @@ -77,6 +77,7 @@ class TelegramAdapter: handle_unpin_channel_message) # repeater 模块 repeater_router.message(F.chat.type.in_({'group', 'supergroup'}))(MessageRepeater().handle_message) + router.message(F.text.regexp(r'(n|N) ?网尾号 ?[0-9]*'))(handle_nexusmods_id) router.message(F.text == '我是笨蛋')(handle_baka) router.inline_query()(handle_inline_query) # 捕获所有其他消息 diff --git a/core/simple.py b/core/simple.py index df43c71..e6a9b45 100644 --- a/core/simple.py +++ b/core/simple.py @@ -88,6 +88,11 @@ async def handle_about_command(message: Message) -> None: response += f"也就大概花了 {minutes} 分 {seconds} 秒..." await about_message.edit_text(response) +async def handle_nexusmods_id(message: Message) -> None: + """输入n网尾号xxxx之后主动返回星露谷物语的对应mod""" + nexusmods_id = message.text.replace(" ","").replace("N网尾号","").replace("n网尾号","") + await message.reply(f"https://www.nexusmods.com/stardewvalley/mods/{nexusmods_id}") + async def dummy_handler(message: Message) -> None: """A handler to catch all other messages""" pass \ No newline at end of file