feat(bridge): /quiet и /loud команды для управления PreToolUse прогресс-лентой
- /quiet → создаёт /tmp/cc-tg-quiet, pretool-hook сразу выходит, Stop hook продолжает работать (финальные ответы летят). - /loud → удаляет flag, прогресс-лента возобновляется. - /ping без изменений. На стенде bridge перезапущен, setWebhook 200. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
59983acabd
commit
8ff0a56144
|
|
@ -92,6 +92,34 @@ async def cmd_ping(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||||
await update.message.reply_text(f"pong — webhook mode, tmux session «{TMUX_SESSION}»")
|
await update.message.reply_text(f"pong — webhook mode, tmux session «{TMUX_SESSION}»")
|
||||||
|
|
||||||
|
|
||||||
|
QUIET_FLAG = "/tmp/cc-tg-quiet"
|
||||||
|
|
||||||
|
|
||||||
|
async def cmd_quiet(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||||
|
"""Заткнуть PreToolUse прогресс-ленту (Stop hook продолжает работать)."""
|
||||||
|
if not _allowed(update, context):
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
open(QUIET_FLAG, "w").close()
|
||||||
|
await update.message.reply_text("🔕 Прогресс-лента отключена. Включить — /loud")
|
||||||
|
except Exception as exc: # noqa: BLE001
|
||||||
|
await update.message.reply_text(f"⚠️ {exc}")
|
||||||
|
|
||||||
|
|
||||||
|
async def cmd_loud(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||||
|
"""Включить обратно PreToolUse прогресс-ленту."""
|
||||||
|
if not _allowed(update, context):
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
os.unlink(QUIET_FLAG)
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
|
except Exception as exc: # noqa: BLE001
|
||||||
|
await update.message.reply_text(f"⚠️ {exc}")
|
||||||
|
return
|
||||||
|
await update.message.reply_text("🔔 Прогресс-лента включена.")
|
||||||
|
|
||||||
|
|
||||||
async def handle_message(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
async def handle_message(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||||
if not _allowed(update, context):
|
if not _allowed(update, context):
|
||||||
return
|
return
|
||||||
|
|
@ -130,6 +158,8 @@ def main() -> int:
|
||||||
application = ApplicationBuilder().token(token).build()
|
application = ApplicationBuilder().token(token).build()
|
||||||
application.bot_data["chat_id"] = chat_id
|
application.bot_data["chat_id"] = chat_id
|
||||||
application.add_handler(CommandHandler("ping", cmd_ping))
|
application.add_handler(CommandHandler("ping", cmd_ping))
|
||||||
|
application.add_handler(CommandHandler("quiet", cmd_quiet))
|
||||||
|
application.add_handler(CommandHandler("loud", cmd_loud))
|
||||||
application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, handle_message))
|
application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, handle_message))
|
||||||
|
|
||||||
logger.info("starting webhook listener on %s:%d → %s", LISTEN_HOST, LISTEN_PORT, webhook_url)
|
logger.info("starting webhook listener on %s:%d → %s", LISTEN_HOST, LISTEN_PORT, webhook_url)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue