add testfucn
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Pavel_Duron 2022-12-09 19:20:50 +10:00
parent 17bb367a3a
commit aefe9f6a09
3 changed files with 33 additions and 1 deletions

5
bot.py
View File

@ -1,17 +1,20 @@
from create_bot import dp from create_bot import dp
import logging import logging
from aiogram import executor from aiogram import executor
from handlers import pipisa, time_new_year, start_help from handlers import pipisa, time_new_year, start_help
from othersq import sendnot
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG)
pipisa.register_handlers_pipisa(dp) pipisa.register_handlers_pipisa(dp)
time_new_year.register_handlers_time(dp) time_new_year.register_handlers_time(dp)
start_help.register_handlers_StartHelp(dp) start_help.register_handlers_StartHelp(dp)
sendnot.register_handlers_sendnotal(dp)

1
othersq/__init__.py Normal file
View File

@ -0,0 +1 @@
from othersq import sendnot

28
othersq/sendnot.py Normal file
View File

@ -0,0 +1,28 @@
from aiogram import types, Dispatcher
from sqdb import session, user
from create_bot import bot, dp
@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 = session.query(user.chat_id).distinct()
for row in chats_id:
try:
await bot.send_message(row[0], text)
except:
print('вероятно бота нет в чате')
await bot.send_message(message.from_user.id, 'Сообщение успешно отправлено во все чаты')
except:
session.rollback()
print('eror sendall')
finally: session.close_all()
def register_handlers_sendnotal(dp: Dispatcher):
dp.register_message_handler(sendall)