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():