Made workable.
This commit is contained in:
parent
f1d04954f0
commit
68244a2e7c
|
@ -16,7 +16,17 @@ def readfile(path):
|
||||||
self = Self()
|
self = Self()
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def get_full_schedule():
|
## code ##
|
||||||
|
if (self.MESSAGE["text"].lower() == "!пара" or self.MESSAGE["text"].lower().split()[0] == "!пари"):
|
||||||
|
|
||||||
|
#getting current time
|
||||||
|
current_time = datetime.datetime.now()
|
||||||
|
|
||||||
|
current_week = current_time.isocalendar()[1] % 2
|
||||||
|
current_day = current_time.weekday()
|
||||||
|
current_seconds = current_week*604800 + current_day*86400 + current_time.hour*3600 + current_time.minute*60 + current_time.second
|
||||||
|
reference_time = int(current_time.strftime("%s")) - current_seconds
|
||||||
|
|
||||||
# baking defined schedule
|
# baking defined schedule
|
||||||
raw_schedule = json.loads( readfile(self.path + "schedule.json") )
|
raw_schedule = json.loads( readfile(self.path + "schedule.json") )
|
||||||
schedule = {}
|
schedule = {}
|
||||||
|
@ -37,21 +47,7 @@ def get_full_schedule():
|
||||||
new_item["source"] = "additions"
|
new_item["source"] = "additions"
|
||||||
schedule[ts] = new_item
|
schedule[ts] = new_item
|
||||||
|
|
||||||
result = dict(list(schedule.items()) + list(additions.items()))
|
full_schedule = dict(list(schedule.items()) + list(additions.items()))
|
||||||
return result
|
|
||||||
|
|
||||||
## code ##
|
|
||||||
if (self.MESSAGE["text"].lower() == "!пара" or self.MESSAGE["text"].lower().split()[0] == "!пари"):
|
|
||||||
|
|
||||||
#getting current time
|
|
||||||
current_time = datetime.datetime.now()
|
|
||||||
|
|
||||||
current_week = current_time.isocalendar()[1] % 2
|
|
||||||
current_day = current_time.weekday()
|
|
||||||
current_seconds = current_week*604800 + current_day*86400 + current_time.hour*3600 + current_time.minute*60 + current_time.second
|
|
||||||
reference_time = int(current_time.strftime("%s")) - current_seconds
|
|
||||||
|
|
||||||
full_schedule = get_full_schedule()
|
|
||||||
|
|
||||||
if self.MESSAGE["text"].lower() == "!пара":
|
if self.MESSAGE["text"].lower() == "!пара":
|
||||||
print("test1")
|
print("test1")
|
||||||
|
@ -170,7 +166,7 @@ if self.MESSAGE["text"].lower().split()[0] == "!пари":
|
||||||
if selected_day*86400 <= i < (selected_day+1)*86400:
|
if selected_day*86400 <= i < (selected_day+1)*86400:
|
||||||
found_lessons[i] = dict(full_schedule[i])
|
found_lessons[i] = dict(full_schedule[i])
|
||||||
|
|
||||||
result_text = f"Пари у {self.WEEKDAY_NAMES_ZNAH[selected_day%7]}:\n\n"
|
result_text = f"Пари у {self.WEEKDAYS_ACCUSATIVE[selected_day%7]}:\n\n"
|
||||||
for i in found_lessons:
|
for i in found_lessons:
|
||||||
actual_lesson_ts = reference_time + i
|
actual_lesson_ts = reference_time + i
|
||||||
dt_lesson = datetime.datetime.fromtimestamp(actual_lesson_ts)
|
dt_lesson = datetime.datetime.fromtimestamp(actual_lesson_ts)
|
||||||
|
|
Loading…
Reference in New Issue