From 4fa9a9f8420261e99eb972a54b30ec6b09427eff Mon Sep 17 00:00:00 2001 From: Jacob Henry Date: Thu, 27 Oct 2016 21:26:25 +0000 Subject: [PATCH 1/3] Added debug out to waitonbot. Fixed scrollutil. --- ScrollUtil.py | 8 ++++---- WaitonBot.py | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ScrollUtil.py b/ScrollUtil.py index 3ac990c..7004019 100644 --- a/ScrollUtil.py +++ b/ScrollUtil.py @@ -37,14 +37,14 @@ def handleScrollMsg(slack, msg): if not m: response = "Could not parse your query. Please invoke as \"scroll \" or \"scroll \"" else: - response = getResponseByQuery() + response = getResponseByQuery(m.group(1)) reply(slack, msg, response, username="scrollbot") def getResponseByQuery(query): try: #Try get scroll number - scroll = int(m.group(1).strip()) + scroll = int(query) b = findBrotherByScroll(scroll) if b: @@ -53,7 +53,7 @@ def getResponseByQuery(query): return "Could not find scroll {0}".format(scroll) except ValueError: #Use as name - name = m.group(1).strip() + name = query b = findBrotherByName(name) if b: @@ -77,5 +77,5 @@ def findBrotherByName(name): """ #Do fuzzy match - return process.extractOne(name, brothers, processor=lambda b: b["name"]) + return process.extractOne(name, brothers, processor=lambda b: b["name"])[0] diff --git a/WaitonBot.py b/WaitonBot.py index c0c7272..3546694 100755 --- a/WaitonBot.py +++ b/WaitonBot.py @@ -70,17 +70,23 @@ def main(): #Handle Message text = msg['text'].lower() if not isValidProfile(user):#invalid profile + print("Received profileless") handleProfilelessScum(slack, msg, user) + elif for_user and not isValidProfile(for_user):#invalid for_user profile + print("Received for profileless") handleProfilelessScum(slack, msg, user, for_user) elif waiton_pattern.match(text): + print("Received waiton from " + user['user']['name']) handleWaitonMsg(slack, sheet_service, msg, user, for_user) elif scroll_pattern.match(text): + print("Received scroll from " + user['user']['name']) handleScrollMsg(slack, msg) elif housejob_pattern.match(text): + print("Received housejob from " + user['user']['name']) reply(slack, msg, "I cannot do that (yet)", username="sadbot") elif killswitch == msg['text'].lower(): From f8d107bcf10ca3c252816f23a5d2304d297f907b Mon Sep 17 00:00:00 2001 From: Jacob Henry Date: Mon, 31 Oct 2016 01:15:38 +0000 Subject: [PATCH 2/3] Updated sheet id to the comprehensive b-term list --- WaitonUtil.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WaitonUtil.py b/WaitonUtil.py index e79bf5b..89af5cf 100644 --- a/WaitonUtil.py +++ b/WaitonUtil.py @@ -8,7 +8,8 @@ Only really kept separate for neatness sake. #ID of waiton sheet on drive #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_SHEED_ID = "1jnLXo_QhZWId84gAVC3rzzo26HmTo_cs2FqviyU6_mw" #All of b term From 09be408789d66bb1a81a98b92933552c8166780a Mon Sep 17 00:00:00 2001 From: Jacob Henry Date: Mon, 31 Oct 2016 04:33:15 +0000 Subject: [PATCH 3/3] Added specific ignores to the "starts at 4:30p" string. Should have more fine tuned conversion later. --- WaitonUtil.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WaitonUtil.py b/WaitonUtil.py index 89af5cf..658d4cc 100644 --- a/WaitonUtil.py +++ b/WaitonUtil.py @@ -9,7 +9,7 @@ Only really kept separate for neatness sake. #ID of waiton sheet on drive #WAITON_SHEET_ID = "1J3WDe-OI7YjtDv6mMlM1PN3UlfZo8_y9GBVNBEPwOhE" #A term 2016 #WAITON_SHEET_ID = "1I4keh9cIt0x-WwZAdnBsZefSZV-tMIAy37r2NLUOLh4" #First week b term -WAITON_SHEED_ID = "1jnLXo_QhZWId84gAVC3rzzo26HmTo_cs2FqviyU6_mw" #All of b term +WAITON_SHEET_ID = "1jnLXo_QhZWId84gAVC3rzzo26HmTo_cs2FqviyU6_mw" #All of b term @@ -55,7 +55,7 @@ def getWaitons(sheet_service): curr_meal = None for row in values: #Update curr meal: - if row[1] != "": + if row[1] != "" and row[1] not in ["starts at 4:30p", "Midnight"]: curr_meal = row[1] if curr_meal is not None: