From 31cec8c005db5b3829e55125222dcf2818df8467 Mon Sep 17 00:00:00 2001 From: jowj Date: Thu, 1 Feb 2018 21:39:18 -0600 Subject: [PATCH] Slight tweaks; making reactAdd trigger with robot_face, other small changes --- mojojojo-bot.py | 14 +++++--------- mojojojo-bot2.py | 3 --- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/mojojojo-bot.py b/mojojojo-bot.py index d5cd738..df6d898 100644 --- a/mojojojo-bot.py +++ b/mojojojo-bot.py @@ -3,7 +3,6 @@ import time import re import logging from slackclient import SlackClient -import pdb from json import JSONDecoder from random import randint from functools import partial @@ -13,7 +12,7 @@ slack_client = SlackClient(os.environ.get('SLACK_BOT_TOKEN')) # starterbot's user ID in Slack: value is assigned after the bot starts up starterbot_id = None # channel i want to get ID from -bot_channel = "bots-like-gaston" +bot_channel = "inmyimo" # constants RTM_READ_DELAY = 1 # 1 second delay between reading from RTM @@ -42,11 +41,10 @@ def parse_direct_mention(message_text): return (matches.group(1), matches.group(2).strip()) if matches else (None, None) def select_noun(): - with open('corpora1\corpora.json', 'r') as infh: + with open('/mjj1/corpora.json', 'r') as infh: for data in json_parse(infh): upper_Limit = len(data["nouns"]) x = randint(0, upper_Limit) - # pdb.set_trace() if data["nouns"][x]: return(data["nouns"][x]) else: @@ -111,20 +109,18 @@ if __name__ == "__main__": starterbot_id = slack_client.api_call("auth.test")["user_id"] while True: for event in (slack_client.rtm_read()): - pdb.set_trace command, channel = parse_bot_commands(event) if command: handle_command(command, channel) if reactable_message(event): channel = event['channel'] text = event['text'] - if 'blah' in text.lower(): + if 'ai ' in text.lower(): print(event.get('ts')) # does this populate - #pdb.set_trace() slack_client.api_call( 'reactions.add', - channel = get_channel_ID("bots-like-gaston"), - name = "thumbsup", + channel = get_channel_ID("inmyimo"), + name = "robot_face", timestamp = event.get('ts') ) time.sleep(RTM_READ_DELAY) diff --git a/mojojojo-bot2.py b/mojojojo-bot2.py index 658a336..4928f4d 100644 --- a/mojojojo-bot2.py +++ b/mojojojo-bot2.py @@ -3,8 +3,6 @@ import time import re import logging from slackclient import SlackClient -import pdb - # instantiate Slack client slack_client = SlackClient(os.environ.get('SLACK_BOT_TOKEN')) @@ -39,7 +37,6 @@ if slack_client.rtm_connect(): text = event['text'] if 'blah' in text.lower(): print(event.get('ts')) # does this populate - pdb.set_trace() slack_client.api_call( 'reactions.add', channel = get_channel_ID("bots-like-gaston"),