async refactor & docker deploy environment
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
from telegram import Update
|
||||
from telegram.ext import ContextTypes
|
||||
from db import SessionLocal
|
||||
from db import AsyncSessionLocal
|
||||
from models import Channel
|
||||
|
||||
async def add_channel(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
args = context.args
|
||||
args = context.args or []
|
||||
if update.message is None:
|
||||
return
|
||||
if len(args) < 2:
|
||||
await update.message.reply_text('Используйте: /add_channel <название> <ссылка>')
|
||||
return
|
||||
name, link = args[0], args[1]
|
||||
session = SessionLocal()
|
||||
channel = Channel(name=name, link=link)
|
||||
session.add(channel)
|
||||
session.commit()
|
||||
session.close()
|
||||
async with AsyncSessionLocal() as session:
|
||||
channel = Channel(name=name, link=link)
|
||||
session.add(channel)
|
||||
await session.commit()
|
||||
await update.message.reply_text(f'Канал "{name}" добавлен.')
|
||||
|
||||
Reference in New Issue
Block a user