You've already forked STARK
mirror of
https://github.com/MarkParker5/STARK.git
synced 2025-11-28 21:39:53 +02:00
fix
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,6 +7,7 @@ __pycache__
|
|||||||
*.sqlite3
|
*.sqlite3
|
||||||
*.save
|
*.save
|
||||||
|
|
||||||
|
*.xls
|
||||||
/audio
|
/audio
|
||||||
/tts-gc-key.json
|
/tts-gc-key.json
|
||||||
/test.py
|
/test.py
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
from Command import Command # import parent class
|
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):
|
class Zieit (Command):
|
||||||
lessonsStartTime = ['07:55','09:25','11:05','12:35','14:05','15:45','17:15']
|
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
|
def start(this, string): # main method
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@staticmethod
|
@classmethod
|
||||||
def getShedule():
|
def getShedule(self):
|
||||||
url = 'https://www.zieit.edu.ua/wp-content/uploads/Rozklad/2k.xls'
|
url = 'https://www.zieit.edu.ua/wp-content/uploads/Rozklad/2k.xls'
|
||||||
name = url.split('/')[-1]
|
name = url.split('/')[-1]
|
||||||
urllib.request.urlretrieve(url, name)
|
urllib.request.urlretrieve(url, name)
|
||||||
@@ -52,18 +57,19 @@ class Zieit (Command):
|
|||||||
lesson['type'] = row[14]
|
lesson['type'] = row[14]
|
||||||
return week
|
return week
|
||||||
|
|
||||||
@staticmethod
|
@classmethod
|
||||||
def getTodaysShedule():
|
def getTodaysShedule(self):
|
||||||
week = getShedule()
|
week = self.getShedule()
|
||||||
for d, lessons in week.items():
|
for d, lessons in week.items():
|
||||||
date = datetime.strptime(d, "%d.%m.%Y").date()
|
date = datetime.strptime(d, "%d.%m.%Y").date()
|
||||||
today = datetime.now().date()
|
today = datetime.now().date()
|
||||||
if date == today: return lessons
|
if date == today: return lessons
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@classmethod
|
||||||
def getNextLesson(lessonsTime):
|
def getNextLesson(self, lessonsTime):
|
||||||
lessons = getTodaysShedule()
|
lessons = self.getTodaysShedule()
|
||||||
|
if lessons == None: return None
|
||||||
next = {}
|
next = {}
|
||||||
for i, lesson in lessons.items():
|
for i, lesson in lessons.items():
|
||||||
border = datetime.strptime(lessonsTime[i-1], '%H:%M').time()
|
border = datetime.strptime(lessonsTime[i-1], '%H:%M').time()
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
from .Zieit import *
|
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)
|
lesson = Zieit.getNextLesson(Zieit.lessonsStartTime)
|
||||||
if lesson == None: voice = text = 'Сегодня пар нет'
|
if lesson == None: voice = text = 'Сегодня пар нет'
|
||||||
else:
|
else:
|
||||||
@@ -23,4 +19,4 @@ def nextLesson(params):
|
|||||||
keywords = {}
|
keywords = {}
|
||||||
patterns = ['* следующ* (предмет|урок|пара)']
|
patterns = ['* следующ* (предмет|урок|пара)']
|
||||||
nextLesson = Zieit('Next Lesson', keywords, patterns)
|
nextLesson = Zieit('Next Lesson', keywords, patterns)
|
||||||
nextLesson.setStart(nextLesson)
|
nextLesson.setStart(nextLessonMethod)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import Text2Speech
|
|||||||
import telebot
|
import telebot
|
||||||
import config
|
import config
|
||||||
import modules
|
import modules
|
||||||
|
import time
|
||||||
|
|
||||||
threads = []
|
threads = []
|
||||||
online = True
|
online = True
|
||||||
@@ -70,4 +71,5 @@ while True:
|
|||||||
print("Start polling...")
|
print("Start polling...")
|
||||||
bot.polling(callback = check_threads, args = (threads,) )
|
bot.polling(callback = check_threads, args = (threads,) )
|
||||||
except:
|
except:
|
||||||
|
time.sleep(10)
|
||||||
print("Polling failed")
|
print("Polling failed")
|
||||||
|
|||||||
Reference in New Issue
Block a user