0.6.1 Официальный шаблон, который позволяет управлять всем, что необходимо
This commit is contained in:
22
Test/old_files/__init__.py
Normal file
22
Test/old_files/__init__.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# BotCode/routers/old_files/__init__.py
|
||||
# Инициализация старого пакета old_files, для хранения старых функций
|
||||
|
||||
from aiogram import Router
|
||||
from .media_func import router as media_old_router
|
||||
from .regular_handlers import router as regular_router
|
||||
|
||||
|
||||
# Объявление роутера и настройка экспорта
|
||||
__all__ = ("router",)
|
||||
router = Router(name="old_files_router")
|
||||
|
||||
|
||||
# Список подключаемых роутеров сверху-вниз
|
||||
router.include_routers(
|
||||
regular_router,
|
||||
media_old_router,
|
||||
)
|
||||
|
||||
|
||||
# Список подключаемых роутеров сверху-вниз
|
||||
router.include_routers()
|
||||
55
Test/old_files/media_func.py
Normal file
55
Test/old_files/media_func.py
Normal file
@@ -0,0 +1,55 @@
|
||||
# BotCode/routers/old_files/media_func.py
|
||||
# Некоторые функции для работы с медиа-сообщениями
|
||||
|
||||
from re import Match
|
||||
from aiogram import Router, F, types
|
||||
from magic_filter import RegexpMode
|
||||
from BotLibrary import *
|
||||
|
||||
# Настройка экспорта модулей и роутера
|
||||
__all__ = ("router",)
|
||||
router = Router(name="media_func")
|
||||
|
||||
|
||||
# @router.message(F.photo, ~F.caption)
|
||||
async def handle_photo_wo_caption(message: types_msg.Message):
|
||||
caption = f"Простите, я не могу это увидеть. Вы можете описать что это?"
|
||||
await message.reply_photo(
|
||||
photo=message.photo[-1].file_id,
|
||||
caption=caption,
|
||||
)
|
||||
return caption
|
||||
|
||||
|
||||
# @router.message(F.photo, F.caption.contains("please"))
|
||||
async def handle_photo_with_please_caption(message: types_msg.Message):
|
||||
text = f"Простите, я не могу это увидеть."
|
||||
await message.reply(text)
|
||||
return text
|
||||
|
||||
|
||||
# @router.message(any_media_filter, ~F.caption)
|
||||
async def handle_any_media_wo_caption(message: types_msg.Message):
|
||||
if message.document:
|
||||
await message.reply_document(
|
||||
document=message.document.file_id,
|
||||
)
|
||||
return f"Перессылка документа"
|
||||
|
||||
elif message.video:
|
||||
await message.reply_video(
|
||||
video=message.video.file_id,
|
||||
)
|
||||
return f"Перессылка видео"
|
||||
|
||||
else:
|
||||
text = f"Я не могу это увидеть."
|
||||
await message.reply(text)
|
||||
return text
|
||||
|
||||
|
||||
# @router.message(any_media_filter, F.caption)
|
||||
async def handle_any_media_w_caption(message: types_msg.Message):
|
||||
text = f"Что-то на медиа. Твой текст: {message.caption!r}"
|
||||
await message.reply(text)
|
||||
return text
|
||||
29
Test/old_files/regular_handlers.py
Normal file
29
Test/old_files/regular_handlers.py
Normal file
@@ -0,0 +1,29 @@
|
||||
# BotCode/routers/old_files/regular_handlers.py
|
||||
# Регулярная функция, выдает тебе сообщение на код при сообщении с числами
|
||||
|
||||
from aiogram import F, types, Router
|
||||
from magic_filter import RegexpMode
|
||||
from re import Match
|
||||
|
||||
from BotLibrary import logginger
|
||||
import configs
|
||||
|
||||
# Настройка экспорта модулей и роутера
|
||||
__all__ = ("router",)
|
||||
router = Router(name="regular_handlers")
|
||||
|
||||
|
||||
# Хэндлер на циферный код (регулярная функция)
|
||||
@router.message(
|
||||
F.from_user.id.in_(configs.ListId.adm_list_id),
|
||||
F.text.regexp(r"(\d+)", mode=RegexpMode.MATCH).as_("code"),
|
||||
)
|
||||
async def handle_code(message: types.Message, code: Match[str]):
|
||||
# Вывод сообщения
|
||||
text = f"Ваш код: {code.group()}"
|
||||
await message.reply(text)
|
||||
|
||||
# Включение логирования в файл
|
||||
await logginger(message)
|
||||
|
||||
return text
|
||||
Reference in New Issue
Block a user