-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunctions.py
More file actions
35 lines (23 loc) · 774 Bytes
/
functions.py
File metadata and controls
35 lines (23 loc) · 774 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
33
34
35
import math
from time import time
from lesson_settings import lesson_settings
def real_user(update):
return update.message.chat.type == "private"
def get_elapsed_time():
t = max(math.ceil((lesson_settings['ending'] - time()) / 60), 0)
endings = [' минут', ' минуты', ' минута']
if t % 10 >= 5 or t % 10 == 0:
t = str(t) + endings[0]
elif t % 10 >= 2:
t = str(t) + endings[1]
else:
t = str(t) + endings[2]
return t
def get_homework_id(title: str) -> int:
return int(title.split()[2][0:-1])
def get_homework_title_by_id(task_id: int):
p = lesson_settings['actual_problems']
for i in range(len(p)):
if task_id == get_homework_id(p[i]):
return p[i]
return None