Made the bot a bit less keen to respond to messages. WIll now only trigger the bot if the first word is waiton, housejob, etc.
This commit is contained in:
parent
10c2999bb0
commit
219ae0c832
Binary file not shown.
12
WaitonBot.py
12
WaitonBot.py
|
|
@ -5,6 +5,8 @@ from SlackUtil import *
|
||||||
from WaitonUtil import handleWaitonMsg #For waitons
|
from WaitonUtil import handleWaitonMsg #For waitons
|
||||||
from ScrollUtil import handleScrollMsg #For scrolls
|
from ScrollUtil import handleScrollMsg #For scrolls
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
#Read api token from file
|
#Read api token from file
|
||||||
apifile = open("apitoken.txt", 'r')
|
apifile = open("apitoken.txt", 'r')
|
||||||
SLACK_API = next(apifile).strip()
|
SLACK_API = next(apifile).strip()
|
||||||
|
|
@ -40,6 +42,10 @@ def handleProfilelessScum(slack, msg, user, for_user=None):
|
||||||
reply(slack, msg, f_response)
|
reply(slack, msg, f_response)
|
||||||
|
|
||||||
|
|
||||||
|
waiton_pattern = re.compile("^waiton")
|
||||||
|
scroll_pattern = re.compile("^scroll")
|
||||||
|
housejob_pattern = re.compile("^(house)?job")
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
#Init slack
|
#Init slack
|
||||||
slack = SlackClient(SLACK_API)
|
slack = SlackClient(SLACK_API)
|
||||||
|
|
@ -68,13 +74,13 @@ def main():
|
||||||
elif for_user and not isValidProfile(for_user):#invalid for_user profile
|
elif for_user and not isValidProfile(for_user):#invalid for_user profile
|
||||||
handleProfilelessScum(slack, msg, user, for_user)
|
handleProfilelessScum(slack, msg, user, for_user)
|
||||||
|
|
||||||
elif "waiton" in text:
|
elif waiton_pattern.match(text):
|
||||||
handleWaitonMsg(slack, sheet_service, msg, user, for_user)
|
handleWaitonMsg(slack, sheet_service, msg, user, for_user)
|
||||||
|
|
||||||
elif "scroll" in text:
|
elif scroll_pattern.match(text):
|
||||||
handleScrollMsg(slack, msg)
|
handleScrollMsg(slack, msg)
|
||||||
|
|
||||||
elif "housejob" in text:
|
elif housejob_pattern.match(text):
|
||||||
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():
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue