From 9bf4316a83dd8f9d823cf3911a7ff01f90c1a6e5 Mon Sep 17 00:00:00 2001 From: jowj Date: Thu, 1 Feb 2018 21:40:09 -0600 Subject: [PATCH] removing bot2.py --- mojojojo-bot2.py | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) delete mode 100644 mojojojo-bot2.py diff --git a/mojojojo-bot2.py b/mojojojo-bot2.py deleted file mode 100644 index 4928f4d..0000000 --- a/mojojojo-bot2.py +++ /dev/null @@ -1,48 +0,0 @@ -import os -import time -import re -import logging -from slackclient import SlackClient - -# instantiate Slack client -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 care about: -bot_channel = "bots-like-gaston" - -# constants -RTM_READ_DELAY = 1 # 1 second delay between reading from RTM - - -def reactable_message(event): - """Test whether a (Slack) event is a reaction-able message - - Check whether it's not a DM, it's not empty, and it's actually a message - """ - return 'channel' in event and 'text' in event and event.get('type') == 'message' - -def get_channel_ID(channelName): - for channel in slack_client.api_call('channels.list')["channels"]: - if channel["name"] == channelName: - return channel["id"] - raise Exception("couldn't find channel requested.") - -if slack_client.rtm_connect(): - while True: - events = slack_client.rtm_read() - for event in events: - if reactable_message(event): - channel = event['channel'] - text = event['text'] - if 'blah' in text.lower(): - print(event.get('ts')) # does this populate - slack_client.api_call( - 'reactions.add', - channel = get_channel_ID("bots-like-gaston"), - name = "thumbsup", - timestamp = event.get('ts') - ) - time.sleep(1) -else: - print('Connection failed, invalid token?') \ No newline at end of file