diff --git a/contrib_bots/bots/commute_bot/commute_bot.py b/contrib_bots/bots/commute/commute.py similarity index 93% rename from contrib_bots/bots/commute_bot/commute_bot.py rename to contrib_bots/bots/commute/commute.py index f3394e3..08ef85b 100644 --- a/contrib_bots/bots/commute_bot/commute_bot.py +++ b/contrib_bots/bots/commute/commute.py @@ -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) diff --git a/contrib_bots/bots/commute_bot/readme.md b/contrib_bots/bots/commute/readme.md similarity index 91% rename from contrib_bots/bots/commute_bot/readme.md rename to contrib_bots/bots/commute/readme.md index 08c4dfe..a60067c 100644 --- a/contrib_bots/bots/commute_bot/readme.md +++ b/contrib_bots/bots/commute/readme.md @@ -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: diff --git a/contrib_bots/bots/define_bot/readme.md b/contrib_bots/bots/define/readme.md similarity index 90% rename from contrib_bots/bots/define_bot/readme.md rename to contrib_bots/bots/define/readme.md index c84e973..cdafb30 100644 --- a/contrib_bots/bots/define_bot/readme.md +++ b/contrib_bots/bots/define/readme.md @@ -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) diff --git a/contrib_bots/bots/tictactoe-bot/readme.md b/contrib_bots/bots/tictactoe/readme.md similarity index 58% rename from contrib_bots/bots/tictactoe-bot/readme.md rename to contrib_bots/bots/tictactoe/readme.md index e5d8162..3697a7a 100644 --- a/contrib_bots/bots/tictactoe-bot/readme.md +++ b/contrib_bots/bots/tictactoe/readme.md @@ -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 ** (or **@ttt **) will make a move at the -entered coordinate. For example, **@ttt 1,1** . After this, the bot will make +**@mention-botname ** 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** . diff --git a/contrib_bots/bots/yoda_bot/readme.md b/contrib_bots/bots/yoda/readme.md similarity index 75% rename from contrib_bots/bots/yoda_bot/readme.md rename to contrib_bots/bots/yoda/readme.md index 66dad30..bc9e16e 100644 --- a/contrib_bots/bots/yoda_bot/readme.md +++ b/contrib_bots/bots/yoda/readme.md @@ -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: -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 diff --git a/contrib_bots/bots/yoda_bot/yoda_bot.py b/contrib_bots/bots/yoda/yoda.py similarity index 92% rename from contrib_bots/bots/yoda_bot/yoda_bot.py rename to contrib_bots/bots/yoda/yoda.py index b4003d0..cc5b132 100644 --- a/contrib_bots/bots/yoda_bot/yoda_bot.py +++ b/contrib_bots/bots/yoda/yoda.py @@ -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