matplobbot-shared 0.1.35__tar.gz → 0.1.36__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of matplobbot-shared might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: matplobbot-shared
3
- Version: 0.1.35
3
+ Version: 0.1.36
4
4
  Summary: Shared library for the Matplobbot ecosystem (database, services, i18n).
5
5
  Author: Ackrome
6
6
  Author-email: ivansergeyevich@gmail.com
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: matplobbot-shared
3
- Version: 0.1.35
3
+ Version: 0.1.36
4
4
  Summary: Shared library for the Matplobbot ecosystem (database, services, i18n).
5
5
  Author: Ackrome
6
6
  Author-email: ivansergeyevich@gmail.com
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="matplobbot-shared",
5
- version="0.1.35", # Let's use the version from your requirements.txt
5
+ version="0.1.36", # Let's use the version from your requirements.txt
6
6
  packages=find_packages(include=['shared_lib', 'shared_lib.*']),
7
7
  description="Shared library for the Matplobbot ecosystem (database, services, i18n).",
8
8
  author="Ackrome",
@@ -108,16 +108,12 @@ async def init_db():
108
108
  entity_id TEXT NOT NULL,
109
109
  entity_name TEXT NOT NULL,
110
110
  notification_time TIME NOT NULL,
111
- last_schedule_hash TEXT,
112
111
  is_active BOOLEAN DEFAULT TRUE,
112
+ last_schedule_hash TEXT, -- Added here for consistency
113
113
  UNIQUE(user_id, entity_type, entity_id)
114
114
  )
115
115
  ''')
116
116
  # Add the last_schedule_hash column if it doesn't exist, for backward compatibility
117
- await connection.execute('''
118
- ALTER TABLE user_schedule_subscriptions
119
- ADD COLUMN IF NOT EXISTS last_schedule_hash TEXT;
120
- ''')
121
117
  logger.info("Database tables initialized.")
122
118
 
123
119
  async def log_user_action(user_id: int, username: str | None, full_name: str, avatar_pic_url: str | None, action_type: str, action_details: str | None):
@@ -5,6 +5,7 @@ from datetime import datetime, date, time
5
5
  from collections import defaultdict
6
6
  from ics import Calendar, Event
7
7
  from zoneinfo import ZoneInfo
8
+ from aiogram.utils.markdown import escape_md
8
9
 
9
10
  from shared_lib.i18n import translator
10
11
 
@@ -40,19 +41,26 @@ def format_schedule(schedule_data: List[Dict[str, Any]], lang: str, entity_name:
40
41
 
41
42
  formatted_lessons = []
42
43
  for lesson in sorted(lessons, key=lambda x: x['beginLesson']):
44
+ # Escape all dynamic parts to prevent markdown parsing errors
45
+ discipline = escape_md(lesson['discipline'])
46
+ kind_of_work = escape_md(names_shorter[lesson['kindOfWork']])
47
+ lecturer = escape_md(lesson['lecturer_title'].replace('_',' '))
48
+ lecturer_email = escape_md(lesson.get('lecturerEmail', 'Почта не указана'))
49
+ group = escape_md(lesson.get('group', 'Группа не указана'))
50
+
43
51
  lesson_details = [
44
52
  f"`{lesson['beginLesson']} - {lesson['endLesson']} | {lesson['auditorium']}`",
45
- f"{lesson['discipline']} | {names_shorter[lesson['kindOfWork']]}"
53
+ f"{discipline} | {kind_of_work}"
46
54
  ]
47
55
 
48
56
  if entity_type == 'group':
49
- lesson_details.append(f"{lesson['lecturer_title'].replace('_',' ')}\n{lesson.get('lecturerEmail', 'Почта не указана')}")
57
+ lesson_details.append(f"{lecturer}\n{lecturer_email}")
50
58
  elif entity_type == 'person': # Lecturer
51
- lesson_details.append(f" {lesson.get('group', 'Группа не указана')}")
59
+ lesson_details.append(f" {group}")
52
60
  elif entity_type == 'auditorium':
53
- lesson_details.append(f"{lesson.get('group', 'Группа не указана')} | {lesson['lecturer_title'].replace('_',' ')}\n{lesson.get('lecturerEmail', 'Почта не указана')}")
61
+ lesson_details.append(f"{group} | {lecturer}\n{lecturer_email}")
54
62
  else: # Fallback to a generic format
55
- lesson_details.append(f"{lesson['lecturer_title'].replace('_',' ')}")
63
+ lesson_details.append(f"{lecturer}")
56
64
 
57
65
  formatted_lessons.append("\n".join(lesson_details))
58
66