import bot_id # Instructor and student imports import wray.slacklib import joe.slacklib import chris.slacklib import homeschool.baron.slacklib import homeschool.elliot.slacklib import homeschool.kaleb.slacklib import homeschool.owen.slacklib import homeschool.vivian.slacklib # constants try: AT_BOT = "<@" + bot_id.get_id() + ">" except TypeError: pass # instantiate client slack_client = SlackClient(os.environ.get('SLACK_BOT_TOKEN')) def handle_command(command, channel): """ Receives commands directed at the bot and determines if they are valid commands. If so, then acts on the commands. If not, returns back what it needs for clarification. Need to determine an algorithm for student overloaded commands. """
def test_slack_client(self): self.assertTrue(bot_id.get_id() == None)
import os import time from slackclient import SlackClient from bot_id import get_id BOT_ID = get_id() #BOT_ID = os.environ.get("BOT_ID") AT_BOT = "<@" + BOT_ID + ">" TRAINER = "U2RLLPDK6" sc = SlackClient(os.environ.get('SLACK_BOT_TOKEN')) def handle_command(command, channel, user): print("command" + command) response = "bark!" if TRAINER in user: response = "YOU ARE THE BEST" if "buddy" in command: response = "bark bark?" sc.api_call("chat.postMessage", channel=channel, text=response, as_user=True) def parse_slack_output(rtm_output): output_list = rtm_output print output_list if output_list and len(output_list) > 0: for output in output_list: