I hereby claim:
- I am elleo on github.
- I am mikesheldon (https://keybase.io/mikesheldon) on keybase.
- I have a public key ASDM-m_Sm2wTOFdOmDgO9gG1_SsqDIEIlV-DAdVykhJBYgo
To claim this, I am signing this object:
class DeepAsylumEvaluator: | |
def grantAsylum(self): | |
return True |
deploy: | |
ampy -p /dev/ttyACM0 put module1 | |
ampy -p /dev/ttyACM0 put module2 | |
ampy -p /dev/ttyACM0 put main.py | |
run: | |
ampy -p /dev/ttyACM0 run main.py |
I hereby claim:
To claim this, I am signing this object:
CAPE_TOKEN = 'myusertoken' # Your Cape user token | |
CAPE_ADMIN_TOKEN = 'myadmintoken' # Your Cape admin token | |
SLACK_KEY = 'myslackkey' # Your bot's Slack key | |
BOT_ID = 'mybotid' # Your bot's Slack ID |
def add_saved_reply(message, channel, slack_client, cape_client): | |
try: | |
# Split the message up into its component parts | |
message = message.split(".add-saved-reply")[1] | |
question, answer = message.split('|', 1) | |
except Exception as e: | |
# Let the user know the correct formatting if we couldn't parse what they sent | |
slack_client.api_call("chat.postMessage", channel=channel, | |
text="Sorry, I didn't understand that. The usage for " \ | |
".add-saved-reply is: .add-saved-reply " \ |
while True: | |
message, channel = parse_slack_output(slack_client.rtm_read()) | |
if message and channel: | |
if message.lower().startswith(".add-saved-reply"): | |
add_saved_reply(message, channel, slack_client, cape_client) | |
else: | |
handle_question(message, channel, slack_client, cape_client) | |
time.sleep(READ_WEBSOCKET_DELAY) |
def handle_question(question, channel, slack_client, cape_client): | |
# Retrieve a list of answers to the user's question | |
answers = cape_client.answer(question, CAPE_TOKEN) | |
if len(answers) > 0: | |
# Respond with the highest confidence answer | |
slack_client.api_call("chat.postMessage", channel=channel, | |
text=answers[0]['answerText'], | |
as_user=True) | |
else: | |
# No answer was found above the current confidence threshold |
CAPE_TOKEN = 'myusertoken' # Your Cape user token | |
SLACK_KEY = 'myslackkey' # Your bot's Slack key | |
BOT_ID = 'mybotid' # Your bot's Slack ID |
from cape.client import CapeClient |
def handle_question(question, channel, slack_client): | |
slack_client.api_call("chat.postMessage", channel=channel, | |
text="Hello!", as_user=True) |