contrib bots: Rename bots to follow a consistent pattern.

Files renamed with few changes to accomodate the change in
path name of files. Fix few "at-mention bot" errors in docs.
This commit is contained in:
Abhijeet Kaur 2017-03-06 00:12:39 +05:30 committed by showell
parent 6dda0eb506
commit d715787170
6 changed files with 39 additions and 39 deletions

View file

@ -6,13 +6,13 @@ from os.path import expanduser
from six.moves import configparser as cp
home = expanduser('~')
CONFIG_PATH = home + '/commute_bot.config'
CONFIG_PATH = home + '/commute.config'
class CommuteHandler(object):
'''
This plugin provides information regarding commuting
from an origin to a destination, providing a multitude of information.
It looks for messages starting with '@commute'.
It looks for messages starting with @mention of the bot.
'''
def __init__(self):
@ -25,7 +25,7 @@ class CommuteHandler(object):
It can vary outputs depending on traffic conditions, departure and
arrival times as well as user preferences
(toll avoidance, preference for bus travel, etc.).
It looks for messages starting with '@commute'.
It looks for messages starting with @mention of the bot.
Users should input an origin and a destination
in any stream or through private messages to the bot to receive a
@ -33,8 +33,8 @@ class CommuteHandler(object):
input was originally private.
Sample input:
@commute origins=Chicago,IL,USA destinations=New+York,NY,USA
@commute help
@mention-botname origins=Chicago,IL,USA destinations=New+York,NY,USA
@mention-botname help
'''
help_info = '''
@ -58,7 +58,7 @@ class CommuteHandler(object):
e.g. language=fr
Sample request:
@commute origins=Chicago,IL,USA destinations=New+York,NY,USA language=fr
@mention-botname origins=Chicago,IL,USA destinations=New+York,NY,USA language=fr
Please note:
Fare information can be derived, though is solely dependent on the
@ -79,9 +79,9 @@ class CommuteHandler(object):
# adds API Authentication Key to url request
def get_api_key(self):
# commute_bot.config must have been moved from
# ~/zulip/contrib_bots/bots/commute_bot/commute_bot.config into
# /commute_bot.config for program to work
# commute.config must be moved from
# ~/zulip/contrib_bots/bots/commute/commute.config into
# ~/commute.config for program to work
# see readme.md for more information
with open(CONFIG_PATH) as settings:
config = cp.ConfigParser()
@ -210,13 +210,13 @@ class CommuteHandler(object):
def handle_message(self, message, client, state_handler):
original_content = message['content']
content_list = original_content.split()
query = original_content.split()
if "help" in content_list:
if "help" in query:
self.send_info(message, self.help_info, client)
return
params = self.parse_pair(content_list)
params = self.parse_pair(query)
params['key'] = self.api_key
self.add_time_to_params(params)

View file

@ -11,24 +11,24 @@ units and information in various languages.
The bot will respond to the same stream input was in. And if called as
private message, the bot will reply with a private message.
To setup the bot, you will first need to move commute_bot.config into
To setup the bot, you will first need to move commute.config into
the user home directory and add an API key.
Move
```
~/zulip/contrib_bots/bots/commute_bot/commute_bot.config
~/zulip/contrib_bots/bots/commute/commute.config
```
into
```
~/commute_bot.config
~/commute.config
```
To add an API key, please visit:
https://developers.google.com/maps/documentation/distance-matrix/start
to retrieve a key and copy your api key into commute_bot.config
to retrieve a key and copy your api key into commute.config
Sample input and output:

View file

@ -12,10 +12,10 @@ is not in the dictionary, the definition is not displayed.
* For example, if the user says "@define crash", all the meanings of crash
appear, each in a separate line.
![Correct Word](correct_word.png)
![Correct Word](assets/correct_word.png)
* If the user enters a wrong word, like "@define cresh" or "@define crish",
then an error message saying no definition is available is displayed.
![Wrong Word](wrong_word.png)
![Wrong Word](assets/wrong_word.png)

View file

@ -4,19 +4,19 @@ This bot allows you to play tic-tac-toe in a private message with the bot.
Multiple games can simultaneously be played by different users, each playing
against the computer.
The bot only responds to messages starting with **@tictactoe** or **@ttt**.
The bot only responds to messages starting with @mention of the bot(botname).
### Commands
**@tictactoe new** (or **@ttt new**) will start a new game (but not if you are
**@mention-botname new** will start a new game (but not if you are
already playing a game.) You must type this first to start playing!
**@tictactoe help** (or **@ttt help**) will return a help function with valid
**@mention-botname help** will return a help function with valid
commands and coordinates.
**@tictactoe quit** (or **@ttt quit**) will quit from the current game.
**@mention-botname quit** will quit from the current game.
**@tictactoe <coordinate>** (or **@ttt <coordinate>**) will make a move at the
entered coordinate. For example, **@ttt 1,1** . After this, the bot will make
**@mention-botname <coordinate>** will make a move at the
entered coordinate. For example, **@mention-botname 1,1** . After this, the bot will make
its move, or declare the game over if the user or bot has won.
Coordinates are entered in a (row, column) format. Numbering is from top to
@ -31,4 +31,4 @@ and spaces are optional.
(3, 1) | (3, 2) | (3, 3)
Invalid commands will result in an "I don't understand" response from the bot,
with a suggestion to type **@tictactoe help** (or **@ttt help**).
with a suggestion to type **@mention-botname help** .

View file

@ -1,12 +1,12 @@
# Overview
This is the documentation for how to set up and run the yoda_bot. (`yoda_bot.py`)
This is the documentation for how to set up and run the yoda bot. (`yoda.py`)
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'.
It looks for messages starting with '@yoda'. You will need to have a
It looks for messages starting with at-mention of the botname. You will need to have a
Mashape API key. Please see instructions for getting one below.
## Setup
@ -14,7 +14,7 @@ Mashape API key. Please see instructions for getting one below.
Before running this bot, make sure to get a Mashape API key.
Go to this link:
<https://market.mashape.com/ismaelc/yoda-speak/overview>
This is the API that powers the `yoda_bot`. You can read more about it
This is the API that powers the `yoda`. You can read more about it
on this page.
![yoda api overview](assets/yoda-speak-api.png)
@ -29,23 +29,23 @@ 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_bot.config` file.
to authenticate. Store it in the `yoda.config` file.
The `yoda_bot.config` file should be located at `~/yoda_bot.config`.
The `yoda.config` file should be located at `~/yoda.config`.
Example input:
@yoda You will learn how to speak like me someday.
@mention-bot You will learn how to speak like me someday.
If you need help while the bot is running just input `@yoda help`.
If you need help while the bot is running just input `@mention-bot help`.
## Running the bot
Here is an example of running the "yoda_bot" bot from
Here is an example of running the "yoda" bot from
inside a Zulip repo:
cd ~/zulip/contrib_bots
./run.py bots/yoda_bot/yoda_bot.py --config-file ~/.zuliprc-prod
./run.py bots/yoda/yoda.py --config-file ~/.zuliprc-prod
Once the bot code starts running, you will see a
message explaining how to use the bot, as well as

View file

@ -18,8 +18,8 @@ HELP_MESSAGE = '''
Before running this, make sure to get a Mashape Api token.
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'.
Store it in the 'yoda.config' file.
The 'yoda.config' file should be located at '~/yoda.config'.
Example input:
@mention-bot You will learn how to speak like me someday.
'''
@ -43,8 +43,8 @@ class YodaSpeakHandler(object):
Before running this, make sure to get a Mashape Api token.
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'.
Store it in the 'yoda.config' file.
The 'yoda.config' file should be located at '~/yoda.config'.
Example input:
@mention-bot You will learn how to speak like me someday.
'''
@ -115,7 +115,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_bot.config') as api_key_file:
with open(home + '/yoda.config') as api_key_file:
api_key = api_key_file.read().strip()
return api_key