python_bot/handlers/sendalarm.py
Pavel_Durov 345168aa80
All checks were successful
continuous-integration/drone/push Build is passing
test
2023-07-13 19:38:51 +03:00

29 lines
979 B
Python

from create_bot import dp, bot
from aiogram import types, Dispatcher
from sqdb import user, session
@dp.message_handler(commands=['sendall'])
async def sendall(message: types.Message):
print('команда прошла')
if message.chat.type == 'private':
if message.from_user.id == 226765676:
text = message.text[9:]
try:
chats_id = -1001355646177
try:
await bot.send_message(chats_id, text)
except:
print('вероятно бота нет в чате')
await bot.send_message(message.from_user.id, 'Сообщение успешно отправлено во все чаты')
except:
session.rollback()
print('eror sendall')
finally: session.close_all()
# def register_handlers_test(dp: Dispatcher):
# dp.register_message_handler(send_welcome)