Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/bot/handlers/group/enable.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ async def enable(message: Message, user: Student, telegram_groups: TelegramGroup
post_info=not telegram_group.post_info
)
)
await message.reply("Сповіщення увімкнено" if telegram_group.post_info else "Сповіщення вимкнено")
await message.reply(
"Сповіщення увімкнено"
if (not telegram_group or telegram_group.post_info)
else "Сповіщення вимкнено"
)
except ResponseException as e:
logging.error(e)
14 changes: 8 additions & 6 deletions app/bot/handlers/group/tomorrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@
from app.utils.date_service import DateService


async def tomorrow(message: Message, telegram_groups: TelegramGroupsByTelegramId) -> None:
async def tomorrow(
message: Message, telegram_groups: TelegramGroupsByTelegramId
) -> None:
for telegram_group in telegram_groups.telegram_groups:
async with ScheduleAPI() as schedule_api:
general_events = await schedule_api.get_general_group_events_by_day(
telegram_group.group.id,
day=(DateService.get_current_weekday() + 2) % 7,
week=DateService.get_week_by_day(DateService.get_current_day() + 1)
telegram_group.group.id, day=DateService.get_current_day() + 1
)

if not general_events.events:
await message.reply(f"У групи {telegram_group.group.code} пар немає")
else:
await message.reply(
await EVENT_LIST.render_async(group=telegram_group.group.code, events=general_events.events),
disable_web_page_preview=True
await EVENT_LIST.render_async(
group=telegram_group.group.code, events=general_events.events
),
disable_web_page_preview=True,
)
6 changes: 5 additions & 1 deletion app/bot/handlers/private/enable.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ async def enable(message: Message) -> None:
post_info=not telegram_group.post_info
)
)
await message.reply("Сповіщення увімкнено" if telegram_group.post_info else "Сповіщення вимкнено")
await message.reply(
"Сповіщення увімкнено"
if (not telegram_group or telegram_group.post_info)
else "Сповіщення вимкнено"
)
except ResponseException as e:
logging.error(e)
7 changes: 2 additions & 5 deletions app/bot/handlers/private/tomorrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ async def tomorrow(message: Message) -> None:
user = await user_api.get_user_by_telegram_id(message.from_user.id) # type: ignore[union-attr]
async with ScheduleAPI() as schedule_api:
general_events = await schedule_api.get_general_group_events_by_day(
user.group.id,
user_id=user.id,
day=(DateService.get_current_weekday() + 2) % 7,
week=DateService.get_week_by_day(DateService.get_current_day() + 1)
user.group.id, user_id=user.id, day=DateService.get_current_day() + 1
)

if not general_events.events:
Expand All @@ -23,5 +20,5 @@ async def tomorrow(message: Message) -> None:

await message.answer(
await EVENT_LIST.render_async(events=general_events.events),
disable_web_page_preview=True
disable_web_page_preview=True,
)
4 changes: 2 additions & 2 deletions app/services/base_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from types import TracebackType
from typing import Dict, Optional, Self, Type
from typing import Dict, Optional, Type

import aiohttp
from pydantic import AnyUrl
Expand Down Expand Up @@ -27,7 +27,7 @@ def base_url(self) -> URL:
def path(self) -> str:
return self.base_url.path + self._path

async def __aenter__(self) -> Self:
async def __aenter__(self): # type: ignore
return self

async def __aexit__(
Expand Down
4 changes: 2 additions & 2 deletions app/services/exceptions/response_exception.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime
from typing import Any, Dict, Self
from typing import Any, Dict

from pydantic import BaseModel
from pydantic.dataclasses import dataclass
Expand All @@ -23,7 +23,7 @@ def __str__(self) -> str:
return self.message

@classmethod
def from_json(cls, json: Dict[str, Any]) -> Self:
def from_json(cls, json: Dict[str, Any]): # type: ignore
return cls(
**ResponseExceptionData
.model_validate(json)
Expand Down
Loading