Add restart confirmation from watchdog alerts
This commit is contained in:
@@ -150,3 +150,57 @@ async def logs_options(cb: CallbackQuery):
|
||||
return
|
||||
|
||||
await cb.answer("Bad request")
|
||||
|
||||
|
||||
@dp.callback_query(F.data.startswith("wdrestart:"))
|
||||
async def watchdog_restart_request(cb: CallbackQuery):
|
||||
if cb.from_user.id != ADMIN_ID:
|
||||
return
|
||||
|
||||
_, alias = cb.data.split(":", 1)
|
||||
if alias not in DOCKER_MAP:
|
||||
await cb.answer("Container not found")
|
||||
return
|
||||
|
||||
kb = InlineKeyboardMarkup(
|
||||
inline_keyboard=[[
|
||||
InlineKeyboardButton(
|
||||
text="✅ Confirm restart",
|
||||
callback_data=f"wdconfirm:{alias}"
|
||||
),
|
||||
InlineKeyboardButton(
|
||||
text="✖ Cancel",
|
||||
callback_data="wdcancel"
|
||||
),
|
||||
]]
|
||||
)
|
||||
await cb.message.answer(
|
||||
f"⚠️ Confirm restart `{alias}`?",
|
||||
reply_markup=kb,
|
||||
parse_mode="Markdown",
|
||||
)
|
||||
await cb.answer()
|
||||
|
||||
|
||||
@dp.callback_query(F.data == "wdcancel")
|
||||
async def watchdog_restart_cancel(cb: CallbackQuery):
|
||||
await cb.answer("Cancelled")
|
||||
|
||||
|
||||
@dp.callback_query(F.data.startswith("wdconfirm:"))
|
||||
async def watchdog_restart_confirm(cb: CallbackQuery):
|
||||
if cb.from_user.id != ADMIN_ID:
|
||||
return
|
||||
|
||||
_, alias = cb.data.split(":", 1)
|
||||
real = DOCKER_MAP.get(alias)
|
||||
if not real:
|
||||
await cb.answer("Container not found")
|
||||
return
|
||||
|
||||
await cb.answer("Restarting…")
|
||||
rc, out = await docker_cmd(["restart", real])
|
||||
await cb.message.answer(
|
||||
f"🔄 **{alias} restarted**\n```{out}```",
|
||||
parse_mode="Markdown",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user