2017-01-04 17:55:52 +01:00
|
|
|
# Overview
|
|
|
|
|
2017-03-05 19:42:39 +01:00
|
|
|
This is the documentation for how to set up and run the yoda bot. (`yoda.py`)
|
2017-01-04 17:55:52 +01:00
|
|
|
|
|
|
|
This directory contains library code for running Zulip
|
|
|
|
bots that react to messages sent by users.
|
|
|
|
|
|
|
|
This bot will allow users to translate a sentence into 'Yoda speak'.
|
2017-03-05 19:42:39 +01:00
|
|
|
It looks for messages starting with at-mention of the botname. You will need to have a
|
2017-01-04 17:55:52 +01:00
|
|
|
Mashape API key. Please see instructions for getting one below.
|
|
|
|
|
|
|
|
## Setup
|
|
|
|
|
2017-03-09 07:34:50 +01:00
|
|
|
Before running this bot, make sure to get a Mashape API key.
|
2017-01-04 17:55:52 +01:00
|
|
|
Go to this link:
|
|
|
|
<https://market.mashape.com/ismaelc/yoda-speak/overview>
|
2017-03-05 19:42:39 +01:00
|
|
|
This is the API that powers the `yoda`. You can read more about it
|
2017-01-04 17:55:52 +01:00
|
|
|
on this page.
|
|
|
|
|
2017-02-08 22:05:24 +01:00
|
|
|
![yoda api overview](assets/yoda-speak-api.png)
|
2017-01-04 17:55:52 +01:00
|
|
|
|
|
|
|
Click on the **Sign Up Free** button at the top and create
|
|
|
|
an account. Then click on the **Documentation** tab. Scroll down to the
|
|
|
|
bottom, and click on the **Test Endpoint** button.
|
|
|
|
This will add the Yoda Speak API to your default application. You can
|
|
|
|
also add it to a different application if you wish. Now click on the
|
|
|
|
**Applications** tab at the top. Select the application that you added
|
|
|
|
the Yoda Speak API to. Click on the blue **GET THE KEYS** button.
|
|
|
|
|
|
|
|
On the pop-up that comes up, click on the **COPY** button.
|
2017-03-09 07:34:50 +01:00
|
|
|
This is your Mashape API key. It is used
|
2017-03-05 19:42:39 +01:00
|
|
|
to authenticate. Store it in the `yoda.config` file.
|
2017-01-04 17:55:52 +01:00
|
|
|
|
2017-03-05 19:42:39 +01:00
|
|
|
The `yoda.config` file should be located at `~/yoda.config`.
|
2017-01-04 17:55:52 +01:00
|
|
|
|
|
|
|
Example input:
|
|
|
|
|
2017-03-05 19:42:39 +01:00
|
|
|
@mention-bot You will learn how to speak like me someday.
|
2017-01-04 17:55:52 +01:00
|
|
|
|
2017-03-05 19:42:39 +01:00
|
|
|
If you need help while the bot is running just input `@mention-bot help`.
|
2017-01-04 17:55:52 +01:00
|
|
|
|
|
|
|
## Running the bot
|
|
|
|
|
2017-03-05 19:42:39 +01:00
|
|
|
Here is an example of running the "yoda" bot from
|
2017-01-04 17:55:52 +01:00
|
|
|
inside a Zulip repo:
|
|
|
|
|
|
|
|
cd ~/zulip/contrib_bots
|
2017-03-05 19:42:39 +01:00
|
|
|
./run.py bots/yoda/yoda.py --config-file ~/.zuliprc-prod
|
2017-01-04 17:55:52 +01:00
|
|
|
|
|
|
|
Once the bot code starts running, you will see a
|
|
|
|
message explaining how to use the bot, as well as
|
|
|
|
some log messages. You can use the `--quiet` option
|
|
|
|
to suppress some of the informational messages.
|
|
|
|
|
|
|
|
The bot code will run continuously until you kill them with
|
|
|
|
control-C (or otherwise).
|
|
|
|
|
|
|
|
### Configuration
|
|
|
|
|
|
|
|
For this document we assume you have some prior experience
|
|
|
|
with using the Zulip API, but here is a quick review of
|
|
|
|
what a `.zuliprc` files looks like. You can connect to the
|
|
|
|
API as your own human user, or you can go into the Zulip settings
|
|
|
|
page to create a user-owned bot.
|
|
|
|
|
|
|
|
[api]
|
|
|
|
email=someuser@example.com
|
|
|
|
key=<your api key>
|
|
|
|
site=https://zulip.somewhere.com
|