This commit is contained in:
djimbo
2022-09-24 20:38:34 +03:00
parent 359b9717ec
commit 9213a80cb9
16 changed files with 77 additions and 49 deletions
+3 -3
View File
@@ -7,7 +7,7 @@ from tgbot.routers.user import user_menu
from tgbot.utils.misc.bot_filters import IsAdmin
# Регистрация роутеров
# Регистрация всех роутеров
def register_all_routers(dp: Dispatcher):
# Подключение фильтров
main_errors.router.message.filter(F.chat.type == "private")
@@ -18,7 +18,7 @@ def register_all_routers(dp: Dispatcher):
admin_menu.router.message.filter(F.chat.type == "private", IsAdmin())
# Инициализация обязательных роутеров
# Подключение обязательных роутеров
dp.include_router(main_errors.router)
dp.include_router(main_start.router)
@@ -26,5 +26,5 @@ def register_all_routers(dp: Dispatcher):
dp.include_router(user_menu.router) # Юзер хендлер
dp.include_router(admin_menu.router) # Админ хендлер
# Инициализация обязательных роутеров
# Подключение обязательных роутеров
dp.include_router(main_missed.router)
+17 -6
View File
@@ -2,19 +2,18 @@
from aiogram import Router, Bot
from aiogram.types import FSInputFile, Message
from tgbot.data.config import PATH_DATABASE, PATH_LOGS
from tgbot.data.config import PATH_DATABASE, PATH_LOGS
from tgbot.keyboards.inline_misc import admin_inl
from tgbot.keyboards.reply_misc import admin_rep
from tgbot.utils.const_functions import get_date
from tgbot.utils.misc.bot_models import FSM, RS
from tgbot.utils.misc.bot_models import FSM, AS
router = Router()
# Кнопка - Admin Inline
@router.message(text="Admin Inline")
async def admin_button_inline(message: Message, bot: Bot, state: FSM, rSession: RS, my_user):
async def admin_button_inline(message: Message, bot: Bot, state: FSM, aSession: AS, my_user):
await state.clear()
await message.answer("Click Button - Admin Inline", reply_markup=admin_inl)
@@ -22,7 +21,7 @@ async def admin_button_inline(message: Message, bot: Bot, state: FSM, rSession:
# Кнопка - Admin Reply
@router.message(text="Admin Reply")
async def admin_button_reply(message: Message, bot: Bot, state: FSM, rSession: RS, my_user):
async def admin_button_reply(message: Message, bot: Bot, state: FSM, aSession: AS, my_user):
await state.clear()
await message.answer("Click Button - Admin Reply", reply_markup=admin_rep)
@@ -30,7 +29,7 @@ async def admin_button_reply(message: Message, bot: Bot, state: FSM, rSession: R
# Получение Базы Данных
@router.message(commands=['db', 'database'])
async def admin_database(message: Message, bot: Bot, state: FSM, rSession: RS, my_user):
async def admin_database(message: Message, bot: Bot, state: FSM, aSession: AS, my_user):
await state.clear()
await message.answer_document(FSInputFile(PATH_DATABASE),
@@ -40,7 +39,19 @@ async def admin_database(message: Message, bot: Bot, state: FSM, rSession: RS, m
# Получение логов
@router.message(commands=['log', 'logs'])
async def admin_log(message: Message, bot: Bot, state: FSM, rSession: RS, my_user):
async def admin_log(message: Message, bot: Bot, state: FSM, aSession: AS, my_user):
await state.clear()
await message.answer_document(FSInputFile(PATH_LOGS), caption=f"<code>🕰 {get_date()}</code>")
# Очистить логи
@router.message(text_contains=['log', '_', 'clean'])
@router.message(text_contains=['log', '_', 'clear'])
async def admin_log_clear(message: Message, bot: Bot, state: FSM, aSession: AS, my_user):
await state.clear()
with open(PATH_LOGS, "w") as file:
file.write(f"{get_date()} | LOGS WAS CLEAR")
await message.answer("<b>🖨 Логи были успешно очищены</b>")
+6 -3
View File
@@ -13,9 +13,12 @@ router = Router()
@router.errors()
async def processing_errors(update: Update, exception: TelegramAPIError, bot: Bot):
print(f"-Exception | {exception}")
await send_admins(bot, f"<b>❌ Ошибка\n\n"
f"<b>Exception: <code>{exception}</code>\n\n"
f"Update: <code>{update.dict()}</code></b>")
await send_admins(
bot,
f"<b>❌ Ошибка\n\n"
f"<b>Exception: <code>{exception}</code>\n\n"
f"Update: <code>{update.dict()}</code></b>"
)
bot_logger.exception(
f"Exception: {exception}\n"
+1 -1
View File
@@ -10,7 +10,7 @@ router = Router()
# Колбэк с удалением сообщения
@router.callback_query(text="close_this")
async def processing_callback_remove(call: CallbackQuery, state: FSM):
async def processing_callback_close(call: CallbackQuery, state: FSM):
await call.message.delete()
+2 -2
View File
@@ -3,14 +3,14 @@ from aiogram import Router, Bot
from aiogram.types import Message
from tgbot.keyboards.reply_main import menu_frep
from tgbot.utils.misc.bot_models import FSM, RS
from tgbot.utils.misc.bot_models import FSM, AS
router = Router()
# Открытие главного меню
@router.message(text_startswith=["⬅ Главное меню", "/start"])
async def main_start(message: Message, bot: Bot, state: FSM, rSession: RS, my_user):
async def main_start(message: Message, bot: Bot, state: FSM, aSession: AS, my_user):
await state.clear()
await message.answer("🔸 Бот готов к использованию.\n"
+4 -4
View File
@@ -5,14 +5,14 @@ from aiogram.types import Message
from tgbot.keyboards.inline_main import menu_finl
from tgbot.keyboards.inline_misc import user_inl
from tgbot.keyboards.reply_misc import user_rep
from tgbot.utils.misc.bot_models import FSM, RS
from tgbot.utils.misc.bot_models import FSM, AS
router = Router()
# Кнопка - User Inline
@router.message(text="User Inline")
async def user_button_inline(message: Message, bot: Bot, state: FSM, rSession: RS, my_user):
async def user_button_inline(message: Message, bot: Bot, state: FSM, aSession: AS, my_user):
await state.clear()
await message.answer("Click Button - User Inline", reply_markup=user_inl)
@@ -20,7 +20,7 @@ async def user_button_inline(message: Message, bot: Bot, state: FSM, rSession: R
# Кнопка - User Reply
@router.message(text="User Reply")
async def user_button_reply(message: Message, bot: Bot, state: FSM, rSession: RS, my_user):
async def user_button_reply(message: Message, bot: Bot, state: FSM, aSession: AS, my_user):
await state.clear()
await message.answer("Click Button - User Reply", reply_markup=user_rep)
@@ -28,7 +28,7 @@ async def user_button_reply(message: Message, bot: Bot, state: FSM, rSession: RS
# Команда - /inline
@router.message(commands="inline")
async def user_command_inline(message: Message, bot: Bot, state: FSM, rSession: RS, my_user):
async def user_command_inline(message: Message, bot: Bot, state: FSM, aSession: AS, my_user):
await state.clear()
await message.answer("Click command - /inline", reply_markup=menu_finl(message.from_user.id))