From daf2e1e7764389fddb70e78bae74de9b32920217 Mon Sep 17 00:00:00 2001 From: mango Date: Wed, 25 Feb 2026 17:24:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=A3=80=E6=B5=8B=E5=AD=98=E6=B4=BB?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=88=86=E7=BB=84=E8=8A=82=E7=82=B9=EF=BC=8C?= =?UTF-8?q?=E5=88=86=E7=BB=84=E8=8A=82=E7=82=B9=E4=B8=8D=E8=A2=AB=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=B8=85=E7=90=86=E8=AF=AF=E5=88=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot.py | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/bot.py b/bot.py index 159345b..6031129 100644 --- a/bot.py +++ b/bot.py @@ -175,14 +175,28 @@ async def cb_menu(update: Update, context: ContextTypes.DEFAULT_TYPE): elif action == 'menu_check': msg = await send_del(q.message, 'šŸ” 检测中...', delay=120) results = [] - for s in data['subs']: - ok = await check_node(s['link'], s['type']) - s['alive'] = ok - results.append(f"{'🟢' if ok else 'šŸ”“'} [{s['type']}] {s['name']}") + # ę£€ęµ‹é»˜č®¤åˆ†ē»„ + if data['subs']: + results.append('šŸ“¦ *é»˜č®¤åˆ†ē»„*') + for s in data['subs']: + ok = await check_node(s['link'], s['type']) + s['alive'] = ok + results.append(f"{'🟢' if ok else 'šŸ”“'} [{s['type']}] {s['name']}") + # ę£€ęµ‹ę‰€ęœ‰č®¢é˜…åˆ†ē»„ + for sg in data.get('sub_groups', []): + if not sg.get('nodes'): continue + results.append(f"\nšŸ“ *{sg['name']}*") + for s in sg['nodes']: + ok = await check_node(s['link'], s['type']) + s['alive'] = ok + results.append(f"{'🟢' if ok else 'šŸ”“'} [{s['type']}] {s['name']}") save_data(data) try: await msg.delete() except: pass - await send_del(q.message, 'šŸ“Š *ę£€ęµ‹ē»“ęžœ*\n\n' + '\n'.join(results), parse_mode='Markdown') + if not results: + await send_del(q.message, 'šŸ“­ ęš‚ę— č®¢é˜…') + else: + await send_del(q.message, 'šŸ“Š *ę£€ęµ‹ē»“ęžœ*\n\n' + '\n'.join(results), parse_mode='Markdown') elif action == 'menu_pick_multi': alive = [s for s in data['subs'] if s.get('alive', True)] @@ -763,11 +777,12 @@ async def cb_subgroups(update: Update, context: ContextTypes.DEFAULT_TYPE): except: pass async def auto_cleanup(bot_token): - """Every 6h: check nodes, auto-delete dead ones, notify group""" + """Every 6h: check nodes, auto-delete dead ones from default subs only, check group nodes but don't delete""" import httpx await asyncio.sleep(60) while True: data = load_data() + # é»˜č®¤åˆ†ē»„ļ¼šę£€ęµ‹å¹¶åˆ é™¤äøåÆē”Ø if data['subs']: dead = [] for s in list(data['subs']): @@ -786,6 +801,16 @@ async def auto_cleanup(bot_token): json={'chat_id': gid, 'text': msg}) except: pass log.info(f'Auto cleanup: removed {len(dead)} dead nodes') + # č®¢é˜…åˆ†ē»„ļ¼šåŖę›“ę–°å­˜ę“»ēŠ¶ę€ļ¼Œäøåˆ é™¤ + changed = False + for sg in data.get('sub_groups', []): + for s in sg.get('nodes', []): + ok = await check_node(s['link'], s['type']) + if s.get('alive', True) != ok: + s['alive'] = ok + changed = True + if changed: + save_data(data) await asyncio.sleep(21600) def run_cleanup():