diff --git a/mojo-rtm/mojo-rtm.py b/mojo-rtm/mojo-rtm.py index b3e3666..384d5dd 100644 --- a/mojo-rtm/mojo-rtm.py +++ b/mojo-rtm/mojo-rtm.py @@ -1,5 +1,6 @@ import os import re +import json import slack EXAMPLE_COMMAND = "do" @@ -10,7 +11,8 @@ BOT_CHANNEL = "bots-like-gaston" def parse_direct_mention(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) # the first group contains the username, the second group contains the remaining message @@ -35,7 +37,6 @@ def reactable_string(text): return reactable_array - @slack.RTMClient.run_on(event='message') def handle_messages(**payload): """ @@ -47,7 +48,6 @@ def handle_messages(**payload): channel_id = data['channel'] thread_ts = data['ts'] - if reactable_string(data['text']): reactions_needed = reactable_string(data['text']) @@ -58,7 +58,6 @@ def handle_messages(**payload): timestamp=thread_ts ) - if 'ai' in reactions_needed: react_to_message("robot_face") if 'furry' in reactions_needed: @@ -78,7 +77,10 @@ def handle_messages(**payload): if is_command[1].startswith("download"): response = "you wouldn't download a car" 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]: response = "mother wouldn't want me to say that" else: @@ -91,6 +93,7 @@ def handle_messages(**payload): timestamp=thread_ts ) + if __name__ == '__main__': SLACK_TOKEN = os.environ["SLACK_API_TOKEN"] CLIENT = slack.WebClient(token=os.environ['SLACK_API_TOKEN'])