Пример #1
0
import requests
import sys
from apikeys import getUWApiKey
from uwaterlooapi import UWaterlooAPI

uw = UWaterlooAPI(api_key=getUWApiKey())

#classes = uw.courses("MAdsfdsfsTH")

#print(classes)

def getCourse():
    #get input
    currentCourse = raw_input()

    # error check
    while not currentCourse or len(currentCourse.split(' ')) != 2:          
        print "Please enter a valid course name"
        currentCourse = raw_input() 

    return currentCourse.upper()



#assuming 5 courses, loops 0-4
i = 1
enteredCourses = []
finalDates = [[] for x in range(5)]
while i <= 5:
        print "Enter name for Course #%d (e.g CS 350)" % (i)
        # These are network problems with Telegram.
        if e.message in ("Bad Gateway", "Timed out"):
            sleep(1)
        elif e.message == "Unauthorized":
            # The user has removed or blocked the bot.
            update_id += 1
        else:
            raise e


def echo(bot, update_id, message):
    bot.sendMessage(chat_id="130724919", text=message)
    return update_id


API_KEY = apikeys.getUWApiKey()
uw = UWaterlooAPI(api_key=API_KEY)


todays_sessions = []


day = int(time.strftime("%d"))

todaysDate = time.strftime("%B ") + str(day) + time.strftime(", %Y")


for event in uw.infosessions():
    if "CANCELLED" in event["employer"].upper():
        continue
    if event["date"] == todaysDate: