Files
post_bot/handlers/add_group.py
Choi A.K. d17f0f5507
Some checks failed
continuous-integration/drone/push Build is failing
async refactor & docker deploy environment
2025-09-05 12:04:58 +09:00

20 lines
677 B
Python

from telegram import Update
from telegram.ext import ContextTypes
from db import AsyncSessionLocal
from models import Group
async def add_group(update: Update, context: ContextTypes.DEFAULT_TYPE):
args = context.args or []
if update.message is None:
return
if len(args) < 2:
await update.message.reply_text('Используйте: /add_group <название> <ссылка>')
return
name, link = args[0], args[1]
session = AsyncSessionLocal()
group = Group(name=name, link=link)
session.add(group)
session.commit()
session.close()
await update.message.reply_text(f'Группа "{name}" добавлена.')