Remove white space, add response for 'arke' command.

master
jowj 4 years ago
parent 5fdccada37
commit d315140e2e

@ -1,5 +1,6 @@
import os import os
import re import re
import json
import slack import slack
EXAMPLE_COMMAND = "do" EXAMPLE_COMMAND = "do"
@ -10,7 +11,8 @@ BOT_CHANNEL = "bots-like-gaston"
def parse_direct_mention(message_text): def parse_direct_mention(message_text):
""" """
Finds a direct mention (a mention that is at the beginning) in message text Finds a direct mention (a mention that is at the beginning) in message text
and returns the user ID which was mentioned. If there is no direct mention, returns None and returns the user ID which was mentioned. If there is no direct mention,
returns None
""" """
matches = re.search(MENTION_REGEX, message_text) matches = re.search(MENTION_REGEX, message_text)
# the first group contains the username, the second group contains the remaining message # the first group contains the username, the second group contains the remaining message
@ -35,7 +37,6 @@ def reactable_string(text):
return reactable_array return reactable_array
@slack.RTMClient.run_on(event='message') @slack.RTMClient.run_on(event='message')
def handle_messages(**payload): def handle_messages(**payload):
""" """
@ -47,7 +48,6 @@ def handle_messages(**payload):
channel_id = data['channel'] channel_id = data['channel']
thread_ts = data['ts'] thread_ts = data['ts']
if reactable_string(data['text']): if reactable_string(data['text']):
reactions_needed = reactable_string(data['text']) reactions_needed = reactable_string(data['text'])
@ -58,7 +58,6 @@ def handle_messages(**payload):
timestamp=thread_ts timestamp=thread_ts
) )
if 'ai' in reactions_needed: if 'ai' in reactions_needed:
react_to_message("robot_face") react_to_message("robot_face")
if 'furry' in reactions_needed: if 'furry' in reactions_needed:
@ -78,7 +77,10 @@ def handle_messages(**payload):
if is_command[1].startswith("download"): if is_command[1].startswith("download"):
response = "you wouldn't download a car" response = "you wouldn't download a car"
if "arke" in is_command[1]: if "arke" in is_command[1]:
pass response = []
with open("/shared/state.log", "r") as json_File:
for line in json_File:
response.append(json.loads(line))
if "pence" in is_command[1]: if "pence" in is_command[1]:
response = "mother wouldn't want me to say that" response = "mother wouldn't want me to say that"
else: else:
@ -91,6 +93,7 @@ def handle_messages(**payload):
timestamp=thread_ts timestamp=thread_ts
) )
if __name__ == '__main__': if __name__ == '__main__':
SLACK_TOKEN = os.environ["SLACK_API_TOKEN"] SLACK_TOKEN = os.environ["SLACK_API_TOKEN"]
CLIENT = slack.WebClient(token=os.environ['SLACK_API_TOKEN']) CLIENT = slack.WebClient(token=os.environ['SLACK_API_TOKEN'])

Loading…
Cancel
Save