security, audit, fom features
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2025-09-06 05:03:45 +09:00
parent df9d8b295d
commit 9793648ee3
11 changed files with 144 additions and 22 deletions

View File

@@ -1,6 +1,6 @@
from telegram import Update
from telegram.ext import CommandHandler, ContextTypes
from db import AsyncSessionLocal
from db import AsyncSessionLocal, log_action
from models import Button
async def del_button(update: Update, context: ContextTypes.DEFAULT_TYPE):
@@ -10,9 +10,8 @@ async def del_button(update: Update, context: ContextTypes.DEFAULT_TYPE):
await update.message.reply_text('Используйте: /del_button <название>')
return
name = args[0]
session = AsyncSessionLocal()
try:
from sqlalchemy import select
from sqlalchemy import select
async with AsyncSessionLocal() as session:
result = await session.execute(select(Button).where(Button.name == name))
button = result.scalar_one_or_none()
if not button:
@@ -21,7 +20,7 @@ async def del_button(update: Update, context: ContextTypes.DEFAULT_TYPE):
return
await session.delete(button)
await session.commit()
user_id = update.effective_user.id if update.effective_user else None
await log_action(user_id, "del_button", f"name={name}")
if update.message:
await update.message.reply_text(f'Кнопка "{name}" удалена.')
finally:
await session.close()
await update.message.reply_text(f'Кнопка \"{name}\" удалена.')