|
|
|
@ -1,7 +1,6 @@
|
|
|
|
|
"""Главный модуль программы.""" |
|
|
|
|
import logging |
|
|
|
|
from aiogram import Bot, Dispatcher, executor, types |
|
|
|
|
from aiogram.utils.exceptions import MessageToDeleteNotFound |
|
|
|
|
import asyncio |
|
|
|
|
from datetime import timedelta |
|
|
|
|
from models import Messages_to_delete, Base |
|
|
|
@ -21,8 +20,9 @@ dp = Dispatcher(bot)
|
|
|
|
|
async def send_welcome(message: types.Message): |
|
|
|
|
"""Справка по командам.""" |
|
|
|
|
await message.reply( |
|
|
|
|
"Бот для взаимодействия с группой\n\n" "/q - для отправки вопроса\n", |
|
|
|
|
services.get_static("static/help_msg.txt"), |
|
|
|
|
reply=False, |
|
|
|
|
parse_mode="Markdown", |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -74,6 +74,29 @@ async def send_question(message: types.Message) -> None:
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dp.message_handler(commands=["p"]) |
|
|
|
|
@services.auth |
|
|
|
|
async def send_post(message: types.Message) -> None: |
|
|
|
|
"""Отправить в чат пост. |
|
|
|
|
|
|
|
|
|
Через бота можно отправить вопрос, который будет удален через |
|
|
|
|
DELAY_TIME_POST минут. |
|
|
|
|
""" |
|
|
|
|
deletion_time = message.date + timedelta(minutes=settings.DELAY_TIME_POST) |
|
|
|
|
out_text = f"{message.text[3:]}\n\nБудет удалено в *{deletion_time}*" |
|
|
|
|
|
|
|
|
|
result = await bot.send_message( |
|
|
|
|
chat_id=settings.CHAT_ID, |
|
|
|
|
text=out_text, |
|
|
|
|
disable_notification=True, |
|
|
|
|
parse_mode="Markdown", |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
await services._clean_up( |
|
|
|
|
message_id=result.message_id, delay_min=settings.DELAY_TIME_Q, bot=bot |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dp.message_handler(commands=["get_invite"]) |
|
|
|
|
@services.only_admins |
|
|
|
|
async def get_invite(message: types.Message) -> None: |
|
|
|
@ -154,11 +177,13 @@ async def wlc(message: types.Message) -> None:
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dp.message_handler(commands=["info"]) |
|
|
|
|
@dp.message_handler(commands=["info", "version"]) |
|
|
|
|
@services.only_admins |
|
|
|
|
async def get_info(message: types.Message) -> None: |
|
|
|
|
"""Вовзращает версию бота.""" |
|
|
|
|
msg = f"Версия бота: *{settings.VERSION}*" |
|
|
|
|
msg = f"Версия бота: *{settings.VERSION}*\n" |
|
|
|
|
msg += f"Время жизни постов: *{settings.DELAY_TIME_POST} минут*\n" |
|
|
|
|
msg += f"Время жизни вопросов: *{settings.DELAY_TIME_Q} минут*\n" |
|
|
|
|
await message.reply( |
|
|
|
|
msg, |
|
|
|
|
reply=False, |
|
|
|
|