moved testing of reactionbot to mojojojo-bot2.py - getting closer!

master
jowj 6 years ago
parent b72aaaf2df
commit 76f2d8b29e

@ -72,18 +72,18 @@ if __name__ == "__main__":
handle_command(command, channel)
time.sleep(RTM_READ_DELAY)
# below section listens for shit about "AI" and adds a reaction (lul)
events = slack_client.rtm_read()
for event in events:
if (
'bots-like-gaston' in event and
'test' in event and
event.get(type) == 'message'
) :
if "test" in text.lower and link not in text:
slack_client.api_call(
"reactions.add",
name = thumbsup
)
# events = slack_client.rtm_read()
# for event in events:
# if (
# 'bots-like-gaston' in event and
# 'test' in event and
# event.get(type) == 'message'
# ) :
# if "test" in text.lower and link not in text:
# slack_client.api_call(
# "reactions.add",
# name = thumbsup
# )
logging.info("Client worked. No errors (we think lol)")
else:

@ -0,0 +1,37 @@
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
# constants
RTM_READ_DELAY = 1 # 1 second delay between reading from RTM
if slack_client.rtm_connect():
while True:
events = slack_client.rtm_read()
for event in events:
if (
'channel' in event and
'text' in event and
event.get('type') == 'message'
):
channel = event['channel']
text = event['text']
if 'blah' in text.lower():
print(event.get('ts'))
slack_client.api_call(
'reactions.add',
channel = "bots-like-gaston",
name = "thumbsup",
timestamp = event.get('ts')
)
time.sleep(1)
else:
print('Connection failed, invalid token?')
Loading…
Cancel
Save