Пример #1
0
def getVotes():
    userInfo = getUserInfo(request)
    if(not isValidUser(userInfo)):
        return pleaseRegister()
    if(inPoll):
        return grabVoting()
    else:
        return  wrapResponse().format(response_type="ephemeral", data='"We aren\'t in a poll right now."')
Пример #2
0
def listRestaurants():
    try:
        userInfo = getUserInfo(request)
        if(not isValidUser(userInfo)):
            return pleaseRegister()
        test = '"|hi|there|\\n|:-|:-|\\n|1|2|"'
        return wrapResponse().format(response_type="in_channel", data=getRestaurantList())
    except Exception as e:
        print(e)
        return wrapResponse().format(response_type="ephemeral", data='"Error, Cannot list restaurants at this time."')
Пример #3
0
def resetRestaurant(rest):
    try:
        userInfo = getUserInfo(request)
        if(not isValidUser(userInfo)):
            return pleaseRegister()
        restaurant = re.match("[a-zA-Z0-9']+", rest).string
        removePriority(restaurant)
        return wrapResponse().format(response_type="in_channel", data='"Weight reset for {0}. Hope it was good!"'.format(restaurant))
    except Exception as e:
        print(e)
        return wrapResponse().format(response_type="ephemeral", data='"Error, failed to modify weighting. Try again later."')
Пример #4
0
def addFood(restaurant):
    try:
        userInfo = getUserInfo(request)
        if(not isValidUser(userInfo)):
            return pleaseRegister()
        newRestaurant = re.match("[a-zA-Z0-9'&]+", restaurant).string
        if(not alreadyAdded(newRestaurant)):
            addRestaurant(newRestaurant)
            return wrapResponse().format(response_type="in_channel", data='"Added {0} from user {1}!"'.format(newRestaurant, request.form.get("user_name")))
        return wrapResponse().format(response_type="ephemeral", data='"It\'s already there!"')
    except Exception as e:
        print(e)
        return wrapResponse().format(response_type="ephemeral", data='"Error, failed to add eatery. Try again later."')
Пример #5
0
def killPoll():
    global inPoll
    try:
        userInfo = getUserInfo(request)
        if(not isValidUser(userInfo)):
            return pleaseRegister()
        if(inPoll):
            inPoll = False
            killPollHelper()
            return wrapResponse().format(response_type="in_channel", data='"{} has killed the poll. Brutal..."'.format(userInfo['name']))
        else:
            return wrapResponse().format(response_type="ephemeral", data='"We are not currently in a poll."')
    except Exception as e:
        return wrapResponse().format(response_type="ephemeral", data='"Error, failed to kill poll. Yell at the admin to fix it."')
Пример #6
0
def resetPoll():
    global inPoll
    try:
        userInfo = getUserInfo(request)
        if(not isValidUser(userInfo)):
            return pleaseRegister()
        if(inPoll):
          incrementPollID()
          return resetPollHelper(userInfo['name'])
        else:
          return wrapResponse().format(response_type="ephemeral", data='"We are not currently in a poll."')
    except Exception as e:
        print(e)
        return wrapResponse().format(response_type="ephemeral", data='"Error, failed to remove eatery. Try again later."')
Пример #7
0
def removeFood(rest):
    try:
        userInfo = getUserInfo(request)
        if(not isValidUser(userInfo)):
            return pleaseRegister()
        restaurant = re.match("[a-zA-Z0-9']+", rest).string
        success = removeRestaurant(restaurant)
        if(success):
            return wrapResponse().format(response_type="in_channel", data='"Sad to see {0} go..."'.format(restaurant))
        else:
            return wrapResponse().format(response_type="ephemeral", data='"Restaurant not found."')
    except Exception as e:
        print(e)
        return wrapResponse().format(response_type="ephemeral", data='"Error, failed to remove eatery. Try again later."')
Пример #8
0
def endPoll():
    global inPoll
    try:
        userInfo = getUserInfo(request)
        if(not isValidUser(userInfo)):
            return pleaseRegister()
        pollResults = displayVotes()
        userChoices = displayUserVotes()
        winner = endPollHelper()
        incrementWeights()
        removePriority(winner)
        inPoll = False
        return wrapResponse().format(response_type="in_channel", data='"Lunch is at: {place}\\n\\n{poll}\\n\\n{users}"'.format(place=winner, poll=pollResults, users=userChoices))
    except Exception as e:
        print(e)
        return wrapResponse().format(response_type="ephemeral", data='"Error, failed to modify weighting. Try again later."')
Пример #9
0
def gimmeLunch():
    global inPoll
    try:
        userInfo = getUserInfo(request)
        if(not isValidUser(userInfo)):
            return pleaseRegister()
        if(not inPoll):
            inPoll = True
            incrementPollID()
            poll = grabPoll()
            print(poll)
            return poll
        else:
            return wrapResponse().format(response_type="ephemeral", data='"Already deciding what is for lunch."')
    except Exception as e:
        inPoll = False
        return wrapResponse().format(response_type="ephemeral", data='"Error, failed to select a lunch place. Looks like you\'re on your own kid!. {error}"'.format(error=e))
Пример #10
0
def registerUser():
    userInfo = getUserInfo(request)
    registerUserToList(userInfo)
    return wrapResponse().format(response_type="ephemeral", data='"You have been successfully registered as {0}"'.format(userInfo['name']))