mirror of
https://github.com/Redume/StarBoard.git
synced 2025-04-07 04:05:28 +01:00
feat: setup channel for forward message
This commit is contained in:
parent
414afd966a
commit
1872544b5a
1 changed files with 24 additions and 0 deletions
24
commands/set_channel.py
Normal file
24
commands/set_channel.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
from aiogram import Router
|
||||
from aiogram.filters import Command
|
||||
from aiogram.types import Message
|
||||
|
||||
from database.database import pg_con
|
||||
|
||||
router = Router()
|
||||
|
||||
@router.message(Command('set_channel'))
|
||||
async def set_channel(message: Message):
|
||||
print(message)
|
||||
args = message.text.split()
|
||||
|
||||
if len(args) < 2:
|
||||
return message.reply('Отсутствует ID канала (формат BOT API)')
|
||||
|
||||
conn = await pg_con()
|
||||
|
||||
data = await conn.fetchrow('SELECT channel_id FROM chat WHERE chat_id = $1', message.chat.id)
|
||||
|
||||
if data[0] == args[1]:
|
||||
return message.reply('Такой ID канала уже установлен')
|
||||
|
||||
await conn.execute('UPDATE chat SET channel_id = $1 WHERE chat_id = $2 ', args[1], message.chat.id)
|
Loading…
Add table
Reference in a new issue