From ab69bb48640c72d9c667236de3ca8540187d5ad0 Mon Sep 17 00:00:00 2001 From: mango Date: Wed, 25 Feb 2026 17:49:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8F=96=E6=B6=88=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=8A=82=E7=82=B9=EF=BC=8C=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E5=8F=AA=E6=9B=B4=E6=96=B0=E7=8A=B6=E6=80=81=EF=BC=9B=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E5=8A=A0=E4=B8=93=E7=BA=BF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot.py | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/bot.py b/bot.py index fdbe0a8..e8c915f 100644 --- a/bot.py +++ b/bot.py @@ -251,6 +251,7 @@ async def cb_menu(update: Update, context: ContextTypes.DEFAULT_TYPE): if not results: await send_del(q.message, '📭 暂无订阅') else: + results.append('\n⚠️ _检测从服务器发起,专线节点可能显示不通但实际可用_') await send_del(q.message, '📊 *检测结果*\n\n' + '\n'.join(results), parse_mode='Markdown') elif action == 'menu_pick_multi': @@ -919,32 +920,18 @@ 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 from default subs only, check group nodes but don't delete""" - import httpx + """Every 6h: check all nodes, update alive status only (no auto-delete)""" await asyncio.sleep(60) while True: data = load_data() - # 默认分组:检测并删除不可用 - if data['subs']: - dead = [] - for s in list(data['subs']): - ok = await check_node(s['link'], s['type']) - if not ok: - dead.append(s) - data['subs'].remove(s) - if dead: - save_data(data) - names = '\n'.join(f"• [{s['type']}] {s['name']}" for s in dead) - msg = f'🗑 自动清理 — 已删除 {len(dead)} 个不可用节点:\n\n{names}' - for gid in data.get('groups', []): - try: - async with httpx.AsyncClient() as c: - await c.post(f'https://api.telegram.org/bot{bot_token}/sendMessage', - json={'chat_id': gid, 'text': msg}) - except: pass - log.info(f'Auto cleanup: removed {len(dead)} dead nodes') - # 订阅分组:只更新存活状态,不删除 changed = False + # 默认分组:只更新状态 + for s in data['subs']: + ok = await check_node(s['link'], s['type']) + if s.get('alive', True) != ok: + s['alive'] = ok + changed = True + # 订阅分组:只更新状态 for sg in data.get('sub_groups', []): for s in sg.get('nodes', []): ok = await check_node(s['link'], s['type']) @@ -953,6 +940,7 @@ async def auto_cleanup(bot_token): changed = True if changed: save_data(data) + log.info('Auto check: updated node status') await asyncio.sleep(21600) def run_cleanup():