async refactor & docker deploy environment
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2025-09-05 12:04:58 +09:00
parent 0d3bcdfc64
commit d17f0f5507
15 changed files with 361 additions and 187 deletions

View File

@@ -1,6 +1,6 @@
from telegram import Update
from telegram.ext import CommandHandler, ContextTypes
from db import SessionLocal
from db import AsyncSessionLocal
from models import Button
async def edit_button(update: Update, context: ContextTypes.DEFAULT_TYPE):
@@ -9,14 +9,18 @@ async def edit_button(update: Update, context: ContextTypes.DEFAULT_TYPE):
await update.message.reply_text('Используйте: /edit_button <название> <новоеазвание> <новая_ссылка>')
return
name, new_name, new_url = args[0], args[1], args[2]
session = SessionLocal()
button = session.query(Button).filter_by(name=name).first()
if not button:
await update.message.reply_text('Кнопка не найдена.')
session.close()
return
button.name = new_name
button.url = new_url
session.commit()
session.close()
await update.message.reply_text(f'Кнопка "{name}" изменена.')
session = AsyncSessionLocal()
try:
result = await session.execute(Button.__table__.select().where(Button.name == name))
button = result.scalar_one_or_none()
if not button:
if update.message:
await update.message.reply_text('Кнопка не найдена.')
return
button.name = new_name
button.url = new_url
await session.commit()
if update.message:
await update.message.reply_text(f'Кнопка "{name}" изменена.')
finally:
await session.close()