@@ -37,9 +37,13 @@ async def setup_start(update: Update, context: ContextTypes.DEFAULT_TYPE):
3737 kb .append ([InlineKeyboardButton ("❌ 关闭菜单" , callback_data = "close_setup" )])
3838
3939 # 如果之前有卡住的会话,提示重启
40- prefix = "♻️ 已重启配置,旧菜单可忽略。\n \n " if context .user_data .get ("setup_active" ) else ""
40+ prefix = "♻️ 已重启配置,旧菜单可忽略。\n " if context .user_data .get ("setup_active" ) else ""
4141 context .user_data ["setup_active" ] = True
42- await reply_func (f"{ prefix } 🛠 **选择配置群组:**" , reply_markup = InlineKeyboardMarkup (kb ))
42+ await reply_func (
43+ f"{ prefix } 🛠 **选择配置群组:**\n "
44+ "⌛ 未操作将于 3 分钟后自动关闭。" ,
45+ reply_markup = InlineKeyboardMarkup (kb )
46+ )
4347 return STATE_MENU
4448
4549async def setup_menu_callback (update : Update , context : ContextTypes .DEFAULT_TYPE ):
@@ -131,7 +135,8 @@ def limit_str(v): return "♾️无限" if v == -2 else f"{v}次"
131135 f"早报 { ic (info ['sub_news' ])} ID:{ val (info ['topic_news' ])} \n "
132136 f"分析 { ic (info ['sub_analysis' ])} ID:{ val (info ['topic_analysis' ])} \n "
133137 f"战绩 { ic (info ['sub_marketing' ])} ID:{ val (info ['topic_marketing' ])} \n "
134- f"信号 { ic (info ['sub_signal' ])} ID:{ val (info ['topic_signal' ])} "
138+ f"信号 { ic (info ['sub_signal' ])} ID:{ val (info ['topic_signal' ])} \n \n "
139+ f"⌛ 未操作将于 3 分钟后自动关闭,需继续请重新 /setup。"
135140 )
136141
137142 kb = [
@@ -237,3 +242,14 @@ async def input_nav_callback(update: Update, context: ContextTypes.DEFAULT_TYPE)
237242 conversation_timeout = 180 ,
238243 allow_reentry = True
239244)
245+
246+ # Timeout 回退:会话超时后提醒用户
247+ async def _on_timeout (update : Update , context : ContextTypes .DEFAULT_TYPE ):
248+ context .user_data .pop ("setup_active" , None )
249+ if update and update .effective_chat :
250+ try :
251+ await update .effective_chat .send_message ("⌛ 配置已超时自动关闭,请重新发送 /setup 进入配置。" )
252+ except Exception :
253+ pass
254+
255+ setup_handler ._conversation_timeout = _on_timeout # type: ignore
0 commit comments