This commit is contained in:
Jacob Henry 2016-11-07 10:54:22 -05:00
commit d76e69c197
3 changed files with 13 additions and 6 deletions

View File

@ -37,14 +37,14 @@ def handleScrollMsg(slack, msg):
if not m: if not m:
response = "Could not parse your query. Please invoke as \"scroll <name>\" or \"scroll <scroll#>\"" response = "Could not parse your query. Please invoke as \"scroll <name>\" or \"scroll <scroll#>\""
else: else:
response = getResponseByQuery() response = getResponseByQuery(m.group(1))
reply(slack, msg, response, username="scrollbot") reply(slack, msg, response, username="scrollbot")
def getResponseByQuery(query): def getResponseByQuery(query):
try: try:
#Try get scroll number #Try get scroll number
scroll = int(m.group(1).strip()) scroll = int(query)
b = findBrotherByScroll(scroll) b = findBrotherByScroll(scroll)
if b: if b:
@ -53,7 +53,7 @@ def getResponseByQuery(query):
return "Could not find scroll {0}".format(scroll) return "Could not find scroll {0}".format(scroll)
except ValueError: except ValueError:
#Use as name #Use as name
name = m.group(1).strip() name = query
b = findBrotherByName(name) b = findBrotherByName(name)
if b: if b:
@ -77,5 +77,5 @@ def findBrotherByName(name):
""" """
#Do fuzzy match #Do fuzzy match
return process.extractOne(name, brothers, processor=lambda b: b["name"]) return process.extractOne(name, brothers, processor=lambda b: b["name"])[0]

View File

@ -70,17 +70,23 @@ def main():
#Handle Message #Handle Message
text = msg['text'].lower() text = msg['text'].lower()
if not isValidProfile(user):#invalid profile if not isValidProfile(user):#invalid profile
print("Received profileless")
handleProfilelessScum(slack, msg, user) handleProfilelessScum(slack, msg, user)
elif for_user and not isValidProfile(for_user):#invalid for_user profile elif for_user and not isValidProfile(for_user):#invalid for_user profile
print("Received for profileless")
handleProfilelessScum(slack, msg, user, for_user) handleProfilelessScum(slack, msg, user, for_user)
elif waiton_pattern.match(text): elif waiton_pattern.match(text):
print("Received waiton from " + user['user']['name'])
handleWaitonMsg(slack, sheet_service, msg, user, for_user) handleWaitonMsg(slack, sheet_service, msg, user, for_user)
elif scroll_pattern.match(text): elif scroll_pattern.match(text):
print("Received scroll from " + user['user']['name'])
handleScrollMsg(slack, msg) handleScrollMsg(slack, msg)
elif housejob_pattern.match(text): elif housejob_pattern.match(text):
print("Received housejob from " + user['user']['name'])
reply(slack, msg, "I cannot do that (yet)", username="sadbot") reply(slack, msg, "I cannot do that (yet)", username="sadbot")
elif killswitch == msg['text'].lower(): elif killswitch == msg['text'].lower():

View File

@ -8,7 +8,8 @@ Only really kept separate for neatness sake.
#ID of waiton sheet on drive #ID of waiton sheet on drive
#WAITON_SHEET_ID = "1J3WDe-OI7YjtDv6mMlM1PN3UlfZo8_y9GBVNBEPwOhE" #A term 2016 #WAITON_SHEET_ID = "1J3WDe-OI7YjtDv6mMlM1PN3UlfZo8_y9GBVNBEPwOhE" #A term 2016
WAITON_SHEET_ID = "1I4keh9cIt0x-WwZAdnBsZefSZV-tMIAy37r2NLUOLh4" #First week b term #WAITON_SHEET_ID = "1I4keh9cIt0x-WwZAdnBsZefSZV-tMIAy37r2NLUOLh4" #First week b term
WAITON_SHEET_ID = "1jnLXo_QhZWId84gAVC3rzzo26HmTo_cs2FqviyU6_mw" #All of b term
@ -54,7 +55,7 @@ def getWaitons(sheet_service):
curr_meal = None curr_meal = None
for row in values: for row in values:
#Update curr meal: #Update curr meal:
if row[1] != "": if row[1] != "" and row[1] not in ["starts at 4:30p", "Midnight"]:
curr_meal = row[1] curr_meal = row[1]
if curr_meal is not None: if curr_meal is not None: