1
0
mirror of https://github.com/MarkParker5/STARK.git synced 2025-11-23 21:34:45 +02:00
This commit is contained in:
MarkParker5
2021-02-07 22:08:08 +02:00
parent 3cee3e03fa
commit 6654c59bb5
4 changed files with 19 additions and 14 deletions

1
.gitignore vendored
View File

@@ -7,6 +7,7 @@ __pycache__
*.sqlite3
*.save
*.xls
/audio
/tts-gc-key.json
/test.py

View File

@@ -1,4 +1,9 @@
from Command import Command # import parent class
import urllib.request
import xlrd
import xlwt
from xlutils.copy import copy
from datetime import datetime
class Zieit (Command):
lessonsStartTime = ['07:55','09:25','11:05','12:35','14:05','15:45','17:15']
@@ -7,8 +12,8 @@ class Zieit (Command):
def start(this, string): # main method
pass
@staticmethod
def getShedule():
@classmethod
def getShedule(self):
url = 'https://www.zieit.edu.ua/wp-content/uploads/Rozklad/2k.xls'
name = url.split('/')[-1]
urllib.request.urlretrieve(url, name)
@@ -52,18 +57,19 @@ class Zieit (Command):
lesson['type'] = row[14]
return week
@staticmethod
def getTodaysShedule():
week = getShedule()
@classmethod
def getTodaysShedule(self):
week = self.getShedule()
for d, lessons in week.items():
date = datetime.strptime(d, "%d.%m.%Y").date()
today = datetime.now().date()
if date == today: return lessons
return None
@staticmethod
def getNextLesson(lessonsTime):
lessons = getTodaysShedule()
@classmethod
def getNextLesson(self, lessonsTime):
lessons = self.getTodaysShedule()
if lessons == None: return None
next = {}
for i, lesson in lessons.items():
border = datetime.strptime(lessonsTime[i-1], '%H:%M').time()

View File

@@ -1,10 +1,6 @@
from .Zieit import *
import urllib.request
import xlrd
import xlwt
from xlutils.copy import copy
################################################################################
def nextLesson(params):
def nextLessonMethod(params):
lesson = Zieit.getNextLesson(Zieit.lessonsStartTime)
if lesson == None: voice = text = 'Сегодня пар нет'
else:
@@ -23,4 +19,4 @@ def nextLesson(params):
keywords = {}
patterns = ['* следующ* (предмет|урок|пара)']
nextLesson = Zieit('Next Lesson', keywords, patterns)
nextLesson.setStart(nextLesson)
nextLesson.setStart(nextLessonMethod)

View File

@@ -5,6 +5,7 @@ import Text2Speech
import telebot
import config
import modules
import time
threads = []
online = True
@@ -70,4 +71,5 @@ while True:
print("Start polling...")
bot.polling(callback = check_threads, args = (threads,) )
except:
time.sleep(10)
print("Polling failed")