diff --git a/mojojojo-bot.py b/mojojojo-bot.py index d2ac642..6aaab4e 100644 --- a/mojojojo-bot.py +++ b/mojojojo-bot.py @@ -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: diff --git a/mojojojo-bot2.py b/mojojojo-bot2.py new file mode 100644 index 0000000..f1cef4d --- /dev/null +++ b/mojojojo-bot2.py @@ -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?') \ No newline at end of file