add ruff linter and refactor all code
This commit is contained in:
@@ -1,16 +1,20 @@
|
||||
import asyncio
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from aiogram import Dispatcher, Bot, F
|
||||
import environs
|
||||
from aiogram import Bot, Dispatcher, F
|
||||
from aiogram.client.default import DefaultBotProperties
|
||||
from aiogram.enums import ParseMode
|
||||
from aiogram.filters import Command
|
||||
from aiogram.types import Message
|
||||
import environs
|
||||
|
||||
from additional_functions import (
|
||||
on_notification,
|
||||
set_group,
|
||||
timetable_day,
|
||||
timetable_for_day,
|
||||
)
|
||||
from DB import UseDB
|
||||
from additional_functions import (on_notification, set_group, timetable_for_day,
|
||||
timetable_day)
|
||||
from use_database import detect_group_to_update
|
||||
|
||||
env = environs.Env()
|
||||
@@ -20,7 +24,7 @@ dp = Dispatcher()
|
||||
|
||||
|
||||
@dp.message(Command("start"))
|
||||
async def start_handler(msg: Message):
|
||||
async def command_start(msg: Message):
|
||||
await msg.answer(
|
||||
"Приветствую!\nЭтот бот предназначен для просмотра расписания занятий "
|
||||
"для любой группы СибГУ, включая сегодня, завтра и послезавтра.\n"
|
||||
@@ -35,7 +39,7 @@ async def start_handler(msg: Message):
|
||||
|
||||
|
||||
@dp.message(Command("set_group"))
|
||||
async def start_handler(msg: Message):
|
||||
async def command_set_group(msg: Message):
|
||||
if len(msg.text.split()) == 2:
|
||||
await set_group(msg)
|
||||
else:
|
||||
@@ -46,7 +50,7 @@ async def start_handler(msg: Message):
|
||||
|
||||
|
||||
@dp.message(Command("on_notification"))
|
||||
async def start_handler(msg: Message):
|
||||
async def command_on_notification(msg: Message):
|
||||
if len(msg.text.split()) == 2:
|
||||
await on_notification(msg)
|
||||
else:
|
||||
@@ -58,19 +62,19 @@ async def start_handler(msg: Message):
|
||||
|
||||
@dp.message(F.text == "сегодня")
|
||||
@dp.message(Command("today"))
|
||||
async def start_handler(msg: Message):
|
||||
async def command_today(msg: Message):
|
||||
await timetable_for_day(msg)
|
||||
|
||||
|
||||
@dp.message(F.text == "завтра")
|
||||
@dp.message(Command("tomorrow"))
|
||||
async def start_handler(msg: Message):
|
||||
async def command_tomorrow(msg: Message):
|
||||
await timetable_for_day(msg, 1)
|
||||
|
||||
|
||||
@dp.message(F.text == "послезавтра")
|
||||
@dp.message(Command("the_day_after_tomorrow"))
|
||||
async def start_handler(msg: Message):
|
||||
async def command_the_day_after_tomorrow(msg: Message):
|
||||
await timetable_for_day(msg, 2)
|
||||
|
||||
|
||||
@@ -107,5 +111,6 @@ async def main() -> None:
|
||||
_ = asyncio.create_task(update_data())
|
||||
await dp.start_polling(bot)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
|
||||
Reference in New Issue
Block a user