forked from PyAr/PyCamp_Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
32 lines (23 loc) · 826 Bytes
/
utils.py
File metadata and controls
32 lines (23 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from pycamp_bot.models import Pycamp
def escape_markdown(string):
# See: https://core.telegram.org/bots/api#markdownv2-style
new_string = string
for char in "_*[]()~`>#+-=|{}.!":
new_string = new_string.replace(char, f'\\{char}')
return new_string
def get_slot_weekday_name(slot_day_code):
ISO_WEEKDAY_NAMES = {
0: 'Lunes',
1: 'Martes',
2: 'Miércoles',
3: 'Jueves',
4: 'Viernes',
5: 'Sábado',
6: 'Domingo',
}
pycamp_start_weekday = Pycamp.get(Pycamp.active == True).init.weekday()
# Convert slot day code to a zero-based code, to use it as an
# offset to get the weekday name of the slot
offset = ord(slot_day_code) - ord('A')
day_name = ISO_WEEKDAY_NAMES[pycamp_start_weekday + offset]
return day_name