Initial commit
This commit is contained in:
8
handlers/__init__.py
Normal file
8
handlers/__init__.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from handlers.ban_words import router as rban_words
|
||||
from handlers.commands import router as rcommands
|
||||
from handlers.come_back import router as rcome_back
|
||||
from handlers.message import router as rmessage
|
||||
from handlers.group import router as rgroup
|
||||
from handlers.ban_media import router as rban_media
|
||||
|
||||
routers = [rcommands, rban_words, rcome_back, rmessage, rgroup, rban_media]
|
BIN
handlers/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
handlers/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
handlers/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
handlers/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
handlers/__pycache__/ban_media.cpython-311.pyc
Normal file
BIN
handlers/__pycache__/ban_media.cpython-311.pyc
Normal file
Binary file not shown.
BIN
handlers/__pycache__/ban_words.cpython-311.pyc
Normal file
BIN
handlers/__pycache__/ban_words.cpython-311.pyc
Normal file
Binary file not shown.
BIN
handlers/__pycache__/come_back.cpython-311.pyc
Normal file
BIN
handlers/__pycache__/come_back.cpython-311.pyc
Normal file
Binary file not shown.
BIN
handlers/__pycache__/commands.cpython-310.pyc
Normal file
BIN
handlers/__pycache__/commands.cpython-310.pyc
Normal file
Binary file not shown.
BIN
handlers/__pycache__/commands.cpython-311.pyc
Normal file
BIN
handlers/__pycache__/commands.cpython-311.pyc
Normal file
Binary file not shown.
BIN
handlers/__pycache__/group.cpython-311.pyc
Normal file
BIN
handlers/__pycache__/group.cpython-311.pyc
Normal file
Binary file not shown.
BIN
handlers/__pycache__/message.cpython-311.pyc
Normal file
BIN
handlers/__pycache__/message.cpython-311.pyc
Normal file
Binary file not shown.
66
handlers/ban_media.py
Normal file
66
handlers/ban_media.py
Normal file
@@ -0,0 +1,66 @@
|
||||
from aiogram import Router, F
|
||||
from aiogram.fsm.context import FSMContext
|
||||
from aiogram.types import CallbackQuery
|
||||
|
||||
from templates import commands as tcommands
|
||||
from utils.db import Postgres, Redis
|
||||
|
||||
router = Router()
|
||||
|
||||
|
||||
@router.callback_query(F.data.startswith('enable_ban_media_'))
|
||||
async def enable_ban_media_btn(call: CallbackQuery, state: FSMContext):
|
||||
"""
|
||||
Ловит кнопку Включить
|
||||
:param call: CallbackQuery
|
||||
:param state: FSMContext
|
||||
:return:
|
||||
"""
|
||||
state_data = await state.get_data()
|
||||
p = Postgres()
|
||||
r = Redis()
|
||||
|
||||
await p.update_data(
|
||||
table_name='ban_media',
|
||||
new_data={call.data[17:]: True},
|
||||
query_filter={}
|
||||
)
|
||||
await r.update_dict(
|
||||
key='ban_media',
|
||||
value={call.data[17:]: 'yes'}
|
||||
)
|
||||
print('new redis data', {call.data[17:]: 'yes'})
|
||||
|
||||
await state_data['last_msg'].edit_text(
|
||||
text=tcommands.start_text,
|
||||
reply_markup=await tcommands.start_ikb()
|
||||
)
|
||||
|
||||
|
||||
@router.callback_query(F.data.startswith('disable_ban_media_'))
|
||||
async def disable_ban_media_btn(call: CallbackQuery, state: FSMContext):
|
||||
"""
|
||||
Ловит кнопку Выключить
|
||||
:param call: CallbackQuery
|
||||
:param state: FSMContext
|
||||
:return:
|
||||
"""
|
||||
state_data = await state.get_data()
|
||||
p = Postgres()
|
||||
r = Redis()
|
||||
|
||||
await p.update_data(
|
||||
table_name='ban_media',
|
||||
new_data={call.data[18:]: False},
|
||||
query_filter={}
|
||||
)
|
||||
await r.update_dict(
|
||||
key='ban_media',
|
||||
value={call.data[18:]: ''}
|
||||
)
|
||||
print('new redis data', {call.data[18:]: ''})
|
||||
|
||||
await state_data['last_msg'].edit_text(
|
||||
text=tcommands.start_text,
|
||||
reply_markup=await tcommands.start_ikb()
|
||||
)
|
134
handlers/ban_words.py
Normal file
134
handlers/ban_words.py
Normal file
@@ -0,0 +1,134 @@
|
||||
import logging
|
||||
|
||||
from aiogram import Router, F
|
||||
from aiogram.fsm.context import FSMContext
|
||||
from aiogram.types import CallbackQuery, FSInputFile, Message
|
||||
|
||||
from templates import ban_words as tban_words
|
||||
from templates import commands as tcommands
|
||||
from utils.defs import delete_msg, create_xlsx
|
||||
from utils.db import Redis, Postgres
|
||||
|
||||
router = Router()
|
||||
|
||||
|
||||
@router.callback_query(F.data == 'ban_words')
|
||||
async def ban_words_btn(call: CallbackQuery, state: FSMContext):
|
||||
"""
|
||||
Ловит кнопку 🚫 Стоп слова
|
||||
:param call: CallbackQuery
|
||||
:param state: FSMContext
|
||||
:return:
|
||||
"""
|
||||
state_data = await state.get_data()
|
||||
|
||||
document_path = await create_xlsx()
|
||||
|
||||
last_msg = await call.message.answer_document(
|
||||
document=FSInputFile(document_path),
|
||||
reply_markup=tban_words.actions_ikb()
|
||||
)
|
||||
|
||||
await delete_msg(
|
||||
msg=state_data.get('last_msg')
|
||||
)
|
||||
await state.update_data(
|
||||
last_msg=last_msg
|
||||
)
|
||||
|
||||
|
||||
@router.callback_query(F.data.startswith('ban_words_action_'))
|
||||
async def ban_words_action_btn(call: CallbackQuery, state: FSMContext):
|
||||
"""
|
||||
Ловит кнопки ➕ Добавить ➖ Удалить
|
||||
:param call: CallbackQuery
|
||||
:param state: FSMContext
|
||||
:return:
|
||||
"""
|
||||
state_data = await state.get_data()
|
||||
|
||||
last_msg = await call.message.answer(
|
||||
text=tban_words.send_words_text,
|
||||
reply_markup=tban_words.send_words_ikb()
|
||||
)
|
||||
|
||||
await state.update_data(
|
||||
last_msg=last_msg,
|
||||
ban_words_action=call.data[17:]
|
||||
)
|
||||
|
||||
await state.set_state(
|
||||
state=tban_words.SendState.words
|
||||
)
|
||||
|
||||
await delete_msg(
|
||||
msg=state_data.get('last_msg')
|
||||
)
|
||||
|
||||
|
||||
@router.message(tban_words.SendState.words, F.text)
|
||||
async def get_words(msg: Message, state: FSMContext):
|
||||
"""
|
||||
Ловит новое сообщение
|
||||
:param msg: Message
|
||||
:param state: FSMContext
|
||||
:return:
|
||||
"""
|
||||
state_data = await state.get_data()
|
||||
words = msg.text.split('\n')
|
||||
|
||||
r = Redis()
|
||||
p = Postgres()
|
||||
|
||||
redis_ban_words = await r.get_list(
|
||||
key='ban_words'
|
||||
)
|
||||
|
||||
if state_data['ban_words_action'] == 'add':
|
||||
msg_text = tban_words.success_text.format(
|
||||
action='добавлены'
|
||||
)
|
||||
for word in words:
|
||||
await p.create_row(
|
||||
table_name='ban_words',
|
||||
data_to_insert={'word': word.lower()}
|
||||
)
|
||||
redis_ban_words.append(word.lower())
|
||||
|
||||
else:
|
||||
msg_text = tban_words.success_text.format(
|
||||
action='удалены'
|
||||
)
|
||||
not_deleted = []
|
||||
for word in words:
|
||||
try:
|
||||
await p.query(
|
||||
query_text=f"DELETE FROM ban_words WHERE LOWER(word)='{word.lower()}'"
|
||||
)
|
||||
redis_ban_words.remove(word.lower())
|
||||
except Exception as e:
|
||||
logging.error(f'get_words {e}')
|
||||
not_deleted.append(word)
|
||||
|
||||
if not_deleted:
|
||||
msg_text = tban_words.not_success_remove_text.format(
|
||||
words='\n'.join(not_deleted)
|
||||
)
|
||||
|
||||
await state_data['last_msg'].edit_text(
|
||||
text=msg_text,
|
||||
reply_markup=await tcommands.start_ikb()
|
||||
)
|
||||
await msg.delete()
|
||||
|
||||
await r.delete_key(
|
||||
'ban_words'
|
||||
)
|
||||
await r.update_list(
|
||||
'ban_words',
|
||||
*redis_ban_words
|
||||
)
|
||||
|
||||
await state.set_state(
|
||||
state=None
|
||||
)
|
115
handlers/come_back.py
Normal file
115
handlers/come_back.py
Normal file
@@ -0,0 +1,115 @@
|
||||
from aiogram import Router, F
|
||||
from aiogram.types import CallbackQuery
|
||||
from aiogram.fsm.context import FSMContext
|
||||
|
||||
from handlers.ban_words import ban_words_btn
|
||||
from templates import message as tmessage
|
||||
from templates import commands as tcommands
|
||||
from handlers.message import message_btn
|
||||
from utils.defs import delete_msg
|
||||
|
||||
router = Router()
|
||||
|
||||
|
||||
@router.callback_query(F.data == 'come_back_buttons')
|
||||
async def come_back_buttons_btn(call: CallbackQuery, state: FSMContext):
|
||||
"""
|
||||
Ловит кнопку ⬅️ Назад
|
||||
:param call: CallbackQuery
|
||||
:param state: FSMContext
|
||||
:return:
|
||||
"""
|
||||
state_data = await state.get_data()
|
||||
|
||||
await state_data['last_msg'].edit_text(
|
||||
text=tmessage.send_buttons_text,
|
||||
reply_markup=tmessage.send_buttons_ikb()
|
||||
)
|
||||
|
||||
await delete_msg(
|
||||
msg=state_data.get('preview_msg')
|
||||
)
|
||||
|
||||
state_data['edited_message_data']['buttons'] = []
|
||||
await state.update_data(
|
||||
edited_message_data=state_data['edited_message_data']
|
||||
)
|
||||
|
||||
await state.set_state(
|
||||
state=tmessage.SendState.buttons
|
||||
)
|
||||
|
||||
|
||||
@router.callback_query(F.data == 'come_back_message')
|
||||
async def come_back_message_btn(call: CallbackQuery, state: FSMContext):
|
||||
"""
|
||||
Ловит кнопку ⬅️ Назад
|
||||
:param call: CallbackQuery
|
||||
:param state: FSMContext
|
||||
:return:
|
||||
"""
|
||||
state_data = await state.get_data()
|
||||
|
||||
await state_data['last_msg'].edit_text(
|
||||
text=tmessage.send_message_text,
|
||||
reply_markup=tmessage.send_message_ikb()
|
||||
)
|
||||
|
||||
await state.set_state(
|
||||
state=tmessage.SendState.message
|
||||
)
|
||||
|
||||
|
||||
@router.callback_query(F.data == 'come_back_preview')
|
||||
async def come_back_preview_btn(call: CallbackQuery, state: FSMContext):
|
||||
"""
|
||||
Ловит кнопку ⬅️ Назад
|
||||
:param call: CallbackQuery
|
||||
:param state: FSMContext
|
||||
:return:
|
||||
"""
|
||||
await message_btn(
|
||||
call=call,
|
||||
state=state
|
||||
)
|
||||
|
||||
|
||||
@router.callback_query(F.data == 'come_back_menu')
|
||||
async def come_back_preview_btn(call: CallbackQuery, state: FSMContext):
|
||||
"""
|
||||
Ловит кнопку ⬅️ Назад
|
||||
:param call: CallbackQuery
|
||||
:param state: FSMContext
|
||||
:return:
|
||||
"""
|
||||
state_data = await state.get_data()
|
||||
|
||||
last_msg = await call.message.answer(
|
||||
text=tcommands.start_text,
|
||||
reply_markup=await tcommands.start_ikb()
|
||||
)
|
||||
|
||||
await state.update_data(
|
||||
last_msg=last_msg
|
||||
)
|
||||
|
||||
await delete_msg(
|
||||
msg=state_data.get('preview_msg')
|
||||
)
|
||||
await delete_msg(
|
||||
msg=state_data.get('last_msg')
|
||||
)
|
||||
|
||||
|
||||
@router.callback_query(F.data == 'come_back_ban_words')
|
||||
async def come_back_ban_words_btn(call: CallbackQuery, state: FSMContext):
|
||||
"""
|
||||
Ловит кнопку ⬅️ Назад
|
||||
:param call: CallbackQuery
|
||||
:param state: FSMContext
|
||||
:return:
|
||||
"""
|
||||
await ban_words_btn(
|
||||
call=call,
|
||||
state=state
|
||||
)
|
39
handlers/commands.py
Normal file
39
handlers/commands.py
Normal file
@@ -0,0 +1,39 @@
|
||||
from aiogram import Router
|
||||
from aiogram.types import Message, BotCommandScopeChat
|
||||
from aiogram.filters import Command
|
||||
from aiogram.fsm.context import FSMContext
|
||||
|
||||
from core import bot
|
||||
from templates import commands as tcommands
|
||||
from config import ADMINS, commands
|
||||
|
||||
router = Router()
|
||||
|
||||
|
||||
@router.message(Command("start"))
|
||||
async def start_command(msg: Message, state: FSMContext):
|
||||
"""
|
||||
Ловит команду /start
|
||||
:param msg: Message
|
||||
:param state: FSMContext
|
||||
:return:
|
||||
"""
|
||||
await msg.delete()
|
||||
if not msg.from_user.id in ADMINS:
|
||||
return
|
||||
|
||||
last_msg = await msg.answer(
|
||||
text=tcommands.start_text,
|
||||
reply_markup=await tcommands.start_ikb()
|
||||
)
|
||||
|
||||
await state.update_data(
|
||||
last_msg=last_msg
|
||||
)
|
||||
|
||||
await bot.set_my_commands(
|
||||
commands=commands,
|
||||
scope=BotCommandScopeChat(
|
||||
chat_id=msg.from_user.id
|
||||
)
|
||||
)
|
92
handlers/group.py
Normal file
92
handlers/group.py
Normal file
@@ -0,0 +1,92 @@
|
||||
|
||||
from aiogram import Router, F
|
||||
from aiogram.fsm.context import FSMContext
|
||||
from aiogram.types import Message
|
||||
|
||||
from templates.message import send_preview
|
||||
from utils.db import Redis, Postgres
|
||||
from utils.defs import delete_msg
|
||||
|
||||
router = Router()
|
||||
|
||||
|
||||
@router.message(F.chat.func(lambda chat: chat.type in ('group', 'supergroup')))
|
||||
async def get_all_messages(msg: Message, state: FSMContext):
|
||||
"""
|
||||
Ловит все сообщения в чате
|
||||
:param msg: Message
|
||||
:param state: FSMContext
|
||||
:return:
|
||||
"""
|
||||
ban = False
|
||||
|
||||
msg_text = msg.text
|
||||
if not msg_text:
|
||||
msg_text = msg.caption
|
||||
|
||||
r = Redis()
|
||||
p = Postgres()
|
||||
|
||||
if msg_text:
|
||||
ban_words = await r.get_list(
|
||||
key='ban_words'
|
||||
)
|
||||
if not ban_words:
|
||||
ban_words = await p.get_data(
|
||||
table_name='ban_words'
|
||||
)
|
||||
ban_words = [word['word'] for word in ban_words]
|
||||
await r.delete_key(
|
||||
'ban_words'
|
||||
)
|
||||
await r.update_list(
|
||||
'ban_words',
|
||||
*ban_words
|
||||
)
|
||||
|
||||
for ban_word in ban_words:
|
||||
if ban_word in msg_text.lower():
|
||||
ban = True
|
||||
|
||||
else:
|
||||
ban_media = await r.get_dict(
|
||||
key='ban_media'
|
||||
)
|
||||
print(ban_media)
|
||||
if not ban_media.get('video') or ban_media.get('photo'):
|
||||
postgres_ban_media = await p.get_data(
|
||||
table_name='ban_media'
|
||||
)
|
||||
ban_media = {}
|
||||
for key, value in postgres_ban_media[0].items():
|
||||
ban_media[key] = 'yes' if value else ''
|
||||
|
||||
await r.update_dict(
|
||||
'ban_media',
|
||||
value=ban_media
|
||||
)
|
||||
|
||||
if ban_media.get('video') and msg.video:
|
||||
ban = True
|
||||
if ban_media.get('photo') and msg.photo:
|
||||
ban = True
|
||||
|
||||
if ban:
|
||||
await delete_msg(
|
||||
msg=msg
|
||||
)
|
||||
message_data = await p.get_data(
|
||||
table_name='message'
|
||||
)
|
||||
|
||||
if msg.from_user.username:
|
||||
username = f'@{msg.from_user.username}'
|
||||
else:
|
||||
username = msg.from_user.full_name
|
||||
|
||||
if message_data[0]['included']:
|
||||
await send_preview(
|
||||
chat_id=msg.chat.id,
|
||||
message_data=message_data[0],
|
||||
username=username
|
||||
)
|
252
handlers/message.py
Normal file
252
handlers/message.py
Normal file
@@ -0,0 +1,252 @@
|
||||
import json
|
||||
|
||||
from aiogram import Router, F
|
||||
from aiogram.fsm.context import FSMContext
|
||||
from aiogram.types import CallbackQuery, Message
|
||||
|
||||
from templates import commands as tcommands
|
||||
from templates import message as tmessage
|
||||
from utils.db import Postgres
|
||||
from utils.defs import delete_msg
|
||||
|
||||
router = Router()
|
||||
|
||||
|
||||
@router.callback_query(F.data == 'message')
|
||||
async def message_btn(call: CallbackQuery, state: FSMContext):
|
||||
"""
|
||||
Ловит кнопку 💬 Стоп сообщение
|
||||
:param call: CallbackQuery
|
||||
:param state: FSMContext
|
||||
:return:
|
||||
"""
|
||||
state_data = await state.get_data()
|
||||
p = Postgres()
|
||||
message_data = await p.get_data(
|
||||
table_name='message'
|
||||
)
|
||||
|
||||
preview_msg = await tmessage.send_preview(
|
||||
message_data=message_data[0],
|
||||
chat_id=call.from_user.id
|
||||
)
|
||||
|
||||
last_msg = await call.message.answer(
|
||||
text=tmessage.actions_text.format(
|
||||
include='Да' if message_data[0]['included'] else 'Нет'
|
||||
),
|
||||
reply_markup=tmessage.actions_ikb(
|
||||
included=message_data[0]['included']
|
||||
)
|
||||
)
|
||||
await delete_msg(
|
||||
msg=state_data.get('last_msg')
|
||||
)
|
||||
await state.update_data(
|
||||
preview_msg=preview_msg,
|
||||
last_msg=last_msg
|
||||
)
|
||||
|
||||
|
||||
@router.callback_query(F.data == 'edit_message')
|
||||
async def edit_message_btn(call: CallbackQuery, state: FSMContext):
|
||||
"""
|
||||
Ловит кнопку 📝 Редактировать
|
||||
:param call: CallbackQuery
|
||||
:param state: FSMContext
|
||||
:return:
|
||||
"""
|
||||
state_data = await state.get_data()
|
||||
|
||||
await state_data['last_msg'].edit_text(
|
||||
text=tmessage.send_message_text,
|
||||
reply_markup=tmessage.send_message_ikb()
|
||||
)
|
||||
await state.set_state(
|
||||
state=tmessage.SendState.message
|
||||
)
|
||||
await delete_msg(
|
||||
msg=state_data.get('preview_msg')
|
||||
)
|
||||
|
||||
await state.update_data(
|
||||
edited_message_data={
|
||||
'text': '',
|
||||
'buttons': [],
|
||||
'media': ''
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@router.message(tmessage.SendState.message, F.content_type.in_({'text', 'photo'}))
|
||||
async def get_edit_message(msg: Message, state: FSMContext):
|
||||
"""
|
||||
Ловит новое сообщение
|
||||
:param msg: Message
|
||||
:param state: FSMContext
|
||||
:return:
|
||||
"""
|
||||
state_data = await state.get_data()
|
||||
|
||||
await state_data['last_msg'].edit_text(
|
||||
text=tmessage.send_buttons_text,
|
||||
reply_markup=tmessage.send_buttons_ikb()
|
||||
)
|
||||
await msg.delete()
|
||||
|
||||
await state.set_state(
|
||||
state=tmessage.SendState.buttons
|
||||
)
|
||||
|
||||
if msg.photo:
|
||||
state_data['edited_message_data']['text'] = msg.caption
|
||||
state_data['edited_message_data']['media'] = msg.photo[-1].file_id
|
||||
else:
|
||||
state_data['edited_message_data']['text'] = msg.text
|
||||
state_data['edited_message_data']['media'] = None
|
||||
|
||||
await state.update_data(
|
||||
edited_message_data=state_data['edited_message_data']
|
||||
)
|
||||
|
||||
|
||||
@router.message(tmessage.SendState.buttons, F.text)
|
||||
async def get_edit_buttons(msg: Message, state: FSMContext):
|
||||
"""
|
||||
Ловит новое url кнопки к сообщению
|
||||
:param msg: Message
|
||||
:param state: FSMContext
|
||||
:return:
|
||||
"""
|
||||
state_data = await state.get_data()
|
||||
buttons = tmessage.build_url_ikb(msg.text)
|
||||
|
||||
await msg.delete()
|
||||
|
||||
if not buttons:
|
||||
await state_data['last_msg'].edit_text(
|
||||
text=tmessage.incorrect_data_text + '\n\n' + tmessage.send_buttons_text,
|
||||
reply_markup=tmessage.send_buttons_ikb()
|
||||
)
|
||||
return
|
||||
|
||||
await delete_msg(
|
||||
msg=state_data.get('last_msg')
|
||||
)
|
||||
|
||||
state_data['edited_message_data']['buttons'] = buttons
|
||||
|
||||
preview_msg = await tmessage.send_preview(
|
||||
message_data=state_data['edited_message_data'],
|
||||
chat_id=msg.from_user.id
|
||||
)
|
||||
last_msg = await msg.answer(
|
||||
text=tmessage.check_data_text,
|
||||
reply_markup=tmessage.check_data_ikb()
|
||||
)
|
||||
|
||||
await state.update_data(
|
||||
edited_message_data=state_data['edited_message_data'],
|
||||
preview_msg=preview_msg,
|
||||
last_msg=last_msg
|
||||
)
|
||||
await state.set_state(
|
||||
state=None
|
||||
)
|
||||
|
||||
|
||||
@router.callback_query(F.data == 'pass_buttons')
|
||||
async def pass_buttons_btn(call: CallbackQuery, state: FSMContext):
|
||||
"""
|
||||
Ловит кнопку ➡️ Пропустить
|
||||
:param call: CallbackQuery
|
||||
:param state: FSMContext
|
||||
:return:
|
||||
"""
|
||||
state_data = await state.get_data()
|
||||
|
||||
await delete_msg(
|
||||
msg=state_data.get('last_msg')
|
||||
)
|
||||
|
||||
preview_msg = await tmessage.send_preview(
|
||||
message_data=state_data['edited_message_data'],
|
||||
chat_id=call.from_user.id
|
||||
)
|
||||
|
||||
last_msg = await call.message.answer(
|
||||
text=tmessage.check_data_text,
|
||||
reply_markup=tmessage.check_data_ikb()
|
||||
)
|
||||
|
||||
await state.update_data(
|
||||
preview_msg=preview_msg,
|
||||
last_msg=last_msg
|
||||
)
|
||||
|
||||
await state.set_state(
|
||||
state=None
|
||||
)
|
||||
|
||||
|
||||
@router.callback_query(F.data == 'publish_message')
|
||||
async def publish_message_btn(call: CallbackQuery, state: FSMContext):
|
||||
"""
|
||||
Ловит кнопку ✅ Опубликовать
|
||||
:param call: CallbackQuery
|
||||
:param state: FSMContext
|
||||
:return:
|
||||
"""
|
||||
state_data = await state.get_data()
|
||||
|
||||
state_data['edited_message_data']['buttons'] = json.dumps(
|
||||
state_data['edited_message_data']['buttons']
|
||||
)
|
||||
|
||||
p = Postgres()
|
||||
await p.update_data(
|
||||
table_name='message',
|
||||
new_data=state_data['edited_message_data'],
|
||||
query_filter={}
|
||||
)
|
||||
|
||||
await state_data['last_msg'].edit_text(
|
||||
text=tmessage.publish_message_text,
|
||||
reply_markup=await tcommands.start_ikb()
|
||||
)
|
||||
|
||||
await delete_msg(
|
||||
msg=state_data.get('preview_msg')
|
||||
)
|
||||
|
||||
|
||||
@router.callback_query(F.data.startswith('included_message_'))
|
||||
async def included_message_btn(call: CallbackQuery, state: FSMContext):
|
||||
"""
|
||||
Ловит кнопку 📝 Редактировать
|
||||
:param call: CallbackQuery
|
||||
:param state: FSMContext
|
||||
:return:
|
||||
"""
|
||||
state_data = await state.get_data()
|
||||
|
||||
if call.data[17:] == 'true':
|
||||
included = True
|
||||
else:
|
||||
included = False
|
||||
|
||||
await state_data['last_msg'].edit_text(
|
||||
text=tmessage.actions_text.format(
|
||||
include='Да' if included else 'Нет'
|
||||
),
|
||||
reply_markup=tmessage.actions_ikb(
|
||||
included=included
|
||||
)
|
||||
)
|
||||
|
||||
p = Postgres()
|
||||
await p.update_data(
|
||||
table_name='message',
|
||||
new_data={'included': included},
|
||||
query_filter={}
|
||||
)
|
Reference in New Issue
Block a user