contrib_bots: Restructure bots to follow a consistent structure.

Now all the bots that are stored in contrib_bots are in the
same file/directory format.
The format is specified here #3427. Add tests.py file for encrypt_bot as well.
Fixes #3427.
This commit is contained in:
Abhijeet Kaur 2017-02-09 02:35:24 +05:30 committed by showell
parent 2282000d78
commit 0419848d3c
42 changed files with 79 additions and 45 deletions

View file

Before

Width:  |  Height:  |  Size: 229 KiB

After

Width:  |  Height:  |  Size: 229 KiB

Before After
Before After

View file

@ -17,7 +17,7 @@ Go to this link:
This is the API that powers the `yoda_bot`. You can read more about it
on this page.
![yoda api overview](yoda-speak-api.png)
![yoda api overview](assets/yoda-speak-api.png)
Click on the **Sign Up Free** button at the top and create
an account. Then click on the **Documentation** tab. Scroll down to the
@ -29,9 +29,9 @@ 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.
This is your Mashape API Key. It is used
to authenticate. Store it in the `yoda_api_key.txt` file.
to authenticate. Store it in the `yoda_bot.config` file.
The `yoda_api_key.txt` file should be located at `~/yoda_api_key.txt`.
The `yoda_bot.config` file should be located at `~/yoda_bot.config`.
Example input:

View file

@ -1,4 +1,4 @@
# See readme-yoda-bot.md for instructions on running this code.
# See readme.md for instructions on running this code.
from __future__ import print_function
import os
@ -17,9 +17,9 @@ HELP_MESSAGE = '''
Users should preface messages with '@yoda'.
Before running this, make sure to get a Mashape Api token.
Instructions are in the 'readme-yoda-bot.md' file.
Store it in the 'yoda_api_key.txt' file.
The 'yoda_api_key.txt' file should be located at '~/yoda_api_key.txt'.
Instructions are in the 'readme.md' file.
Store it in the 'yoda_bot.config' file.
The 'yoda_bot.config' file should be located at '~/yoda_bot.config'.
Example input:
@yoda You will learn how to speak like me someday.
'''
@ -42,9 +42,9 @@ class YodaSpeakHandler(object):
Users should preface messages with '@yoda'.
Before running this, make sure to get a Mashape Api token.
Instructions are in the 'readme-yoda-bot.md' file.
Store it in the 'yoda_api_key.txt' file.
The 'yoda_api_key.txt' file should be located at '~/yoda_api_key.txt'.
Instructions are in the 'readme.md' file.
Store it in the 'yoda_bot.config' file.
The 'yoda_bot.config' file should be located at '~/yoda_bot.config'.
Example input:
@yoda You will learn how to speak like me someday.
'''
@ -85,7 +85,7 @@ def send_to_yoda_api(sentence, api_key):
logging.error(error_message)
error_code = response.status_code
error_message = error_message + 'Error code: ' + error_code +\
' Did you follow the instructions in the `readme-yoda-bot.md` file?'
' Did you follow the instructions in the `readme.md` file?'
return error_message
@ -115,7 +115,7 @@ def handle_input(client, original_content, stream, subject):
except ApiKeyError:
reply_message = 'Invalid Api Key. Did you follow the instructions in the ' \
'`readme-yoda-bot.md` file?'
'`readme.md` file?'
logging.error(reply_message)
send_message(client, reply_message, stream, subject)
@ -124,7 +124,7 @@ def handle_input(client, original_content, stream, subject):
def get_api_key():
# function for getting Mashape api key
home = os.path.expanduser('~')
with open(home + '/yoda_api_key.txt') as api_key_file:
with open(home + '/yoda_bot.config') as api_key_file:
api_key = api_key_file.read().strip()
return api_key