diff --git a/contrib_bots/bots/commute_bot/CommuteBot/google-commute.ini b/contrib_bots/bots/commute_bot/commute_bot.config similarity index 100% rename from contrib_bots/bots/commute_bot/CommuteBot/google-commute.ini rename to contrib_bots/bots/commute_bot/commute_bot.config diff --git a/contrib_bots/bots/commute_bot/commute_bot.py b/contrib_bots/bots/commute_bot/commute_bot.py index f184fe0..8b4f869 100644 --- a/contrib_bots/bots/commute_bot/commute_bot.py +++ b/contrib_bots/bots/commute_bot/commute_bot.py @@ -6,7 +6,7 @@ from os.path import expanduser from six.moves import configparser as cp home = expanduser('~') -CONFIG_PATH = home + '/google-commute.ini' +CONFIG_PATH = home + '/commute_bot.config' class CommuteHandler(object): ''' @@ -89,10 +89,10 @@ class CommuteHandler(object): # adds API Authentication Key to url request def get_api_key(self): - # google-commute.ini must have been moved from - # ~/zulip/contrib_bots/bots/commute_bot/CommuteBot/google-commute.ini into - # /google-commute.ini for program to work - # see doc.md for more information + # 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 + # see readme.md for more information with open(CONFIG_PATH) as settings: config = cp.ConfigParser() config.readfp(settings) diff --git a/contrib_bots/bots/commute_bot/CommuteBot/doc.md b/contrib_bots/bots/commute_bot/readme.md similarity index 91% rename from contrib_bots/bots/commute_bot/CommuteBot/doc.md rename to contrib_bots/bots/commute_bot/readme.md index 255a088..08c4dfe 100644 --- a/contrib_bots/bots/commute_bot/CommuteBot/doc.md +++ b/contrib_bots/bots/commute_bot/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 google-commute.ini into +To setup the bot, you will first need to move commute_bot.config into the user home directory and add an API key. Move ``` -~/zulip/contrib_bots/bots/commute_bot/CommuteBot/google-commute.ini +~/zulip/contrib_bots/bots/commute_bot/commute_bot.config ``` into ``` -~/google-commute.ini +~/commute_bot.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 google-commute.ini +to retrieve a key and copy your api key into commute_bot.config Sample input and output: diff --git a/contrib_bots/bots/converter/docs.md b/contrib_bots/bots/converter/readme.md similarity index 100% rename from contrib_bots/bots/converter/docs.md rename to contrib_bots/bots/converter/readme.md diff --git a/contrib_bots/bots/converter/tests.py b/contrib_bots/bots/converter/tests.py index 519059c..d7baf8a 100644 --- a/contrib_bots/bots/converter/tests.py +++ b/contrib_bots/bots/converter/tests.py @@ -20,6 +20,7 @@ def test(): expected: %s but got : %s ''' % (cmd, expected_response, client_dummy.output)) + def sample_conversation(): return [ ('@convert 2 m cm', '2.0 m = 200.0 cm\n'), diff --git a/contrib_bots/bots/define_bot/DefineBot/correct_word.png b/contrib_bots/bots/define_bot/assets/correct_word.png similarity index 100% rename from contrib_bots/bots/define_bot/DefineBot/correct_word.png rename to contrib_bots/bots/define_bot/assets/correct_word.png diff --git a/contrib_bots/bots/define_bot/DefineBot/wrong_word.png b/contrib_bots/bots/define_bot/assets/wrong_word.png similarity index 100% rename from contrib_bots/bots/define_bot/DefineBot/wrong_word.png rename to contrib_bots/bots/define_bot/assets/wrong_word.png diff --git a/contrib_bots/bots/define_bot/DefineBot/docs.md b/contrib_bots/bots/define_bot/readme.md similarity index 100% rename from contrib_bots/bots/define_bot/DefineBot/docs.md rename to contrib_bots/bots/define_bot/readme.md diff --git a/contrib_bots/bots/encrypt_bot/EncryptBot/EncryptBot-terminal.png b/contrib_bots/bots/encrypt_bot/assets/EncryptBot-terminal.png similarity index 100% rename from contrib_bots/bots/encrypt_bot/EncryptBot/EncryptBot-terminal.png rename to contrib_bots/bots/encrypt_bot/assets/EncryptBot-terminal.png diff --git a/contrib_bots/bots/encrypt_bot/EncryptBot/EncryptBot-test.png b/contrib_bots/bots/encrypt_bot/assets/EncryptBot-test.png similarity index 100% rename from contrib_bots/bots/encrypt_bot/EncryptBot/EncryptBot-test.png rename to contrib_bots/bots/encrypt_bot/assets/EncryptBot-test.png diff --git a/contrib_bots/bots/encrypt_bot/EncryptBot/EncryptBot-test2.png b/contrib_bots/bots/encrypt_bot/assets/EncryptBot-test2.png similarity index 100% rename from contrib_bots/bots/encrypt_bot/EncryptBot/EncryptBot-test2.png rename to contrib_bots/bots/encrypt_bot/assets/EncryptBot-test2.png diff --git a/contrib_bots/bots/encrypt_bot/EncryptBot/EncryptBot-test3.png b/contrib_bots/bots/encrypt_bot/assets/EncryptBot-test3.png similarity index 100% rename from contrib_bots/bots/encrypt_bot/EncryptBot/EncryptBot-test3.png rename to contrib_bots/bots/encrypt_bot/assets/EncryptBot-test3.png diff --git a/contrib_bots/bots/encrypt_bot/EncryptBot/docs.md b/contrib_bots/bots/encrypt_bot/readme.md similarity index 100% rename from contrib_bots/bots/encrypt_bot/EncryptBot/docs.md rename to contrib_bots/bots/encrypt_bot/readme.md diff --git a/contrib_bots/bots/encrypt_bot/tests.py b/contrib_bots/bots/encrypt_bot/tests.py new file mode 100644 index 0000000..6e9be11 --- /dev/null +++ b/contrib_bots/bots/encrypt_bot/tests.py @@ -0,0 +1,33 @@ +import encrypt_bot + +def test(): + for cmd, expected_response in sample_conversation(): + message = {'content': cmd, 'subject': 'foo', + 'display_recipient': 'bar'} + + class ClientDummy(object): + def __init__(self): + self.output = '' + + def send_message(self, params): + self.output = params['content'] + handler = encrypt_bot.EncryptHandler() + client_dummy = ClientDummy() + handler.handle_message(message, client_dummy, '') + if client_dummy.output != expected_response: + raise AssertionError(''' + cmd: %s + expected: %s + but got : %s + ''' % (cmd, expected_response, client_dummy.output)) + +def sample_conversation(): + return [ + ('@encrypt Please encrypt this', 'Encrypted/Decrypted text: Cyrnfr rapelcg guvf'), + ('@encrypt Let\'s Do It', 'Encrypted/Decrypted text: Yrg\'f Qb Vg'), + ('@encrypt ', 'Encrypted/Decrypted text: '), + ('@encrypt me&mom together..!!', 'Encrypted/Decrypted text: zr&zbz gbtrgure..!!'), + ] + +if __name__ == '__main__': + test() diff --git a/contrib_bots/bots/foursquare/FourSquareBot/settings.ini b/contrib_bots/bots/foursquare/foursquare.config similarity index 100% rename from contrib_bots/bots/foursquare/FourSquareBot/settings.ini rename to contrib_bots/bots/foursquare/foursquare.config diff --git a/contrib_bots/bots/foursquare/foursquare.py b/contrib_bots/bots/foursquare/foursquare.py index e68ac4c..a89a88d 100644 --- a/contrib_bots/bots/foursquare/foursquare.py +++ b/contrib_bots/bots/foursquare/foursquare.py @@ -9,13 +9,13 @@ from six.moves import configparser as cp from six.moves import range home = expanduser('~') -CONFIG_PATH = home + '/zulip/contrib_bots/bots/foursquare/FourSquareBot/settings.ini' +CONFIG_PATH = home + '/zulip/contrib_bots/bots/foursquare/foursquare.config' def get_api_key(): - # settings.ini must have been moved from - # ~/zulip/contrib_bots/bots/foursquare/FourSquareBot/settings.ini into - # ~/settings.ini for program to work - # see doc.md for more information + # foursquare.config must have been moved from + # ~/zulip/contrib_bots/bots/foursquare/foursquare.config into + # ~/foursquare.config for program to work + # see readme.md for more information with open(CONFIG_PATH) as settings: config = cp.ConfigParser() config.readfp(settings) diff --git a/contrib_bots/bots/foursquare/FourSquareBot/doc.md b/contrib_bots/bots/foursquare/readme.md similarity index 100% rename from contrib_bots/bots/foursquare/FourSquareBot/doc.md rename to contrib_bots/bots/foursquare/readme.md diff --git a/contrib_bots/bots/git_hub_comment/git_hub_comment.py b/contrib_bots/bots/git_hub_comment/git_hub_comment.py index 9cde643..8cda146 100644 --- a/contrib_bots/bots/git_hub_comment/git_hub_comment.py +++ b/contrib_bots/bots/git_hub_comment/git_hub_comment.py @@ -1,4 +1,4 @@ -# See readme-github-comment-bot.md for instructions on running this code. +# See readme.md for instructions on running this code. from __future__ import absolute_import from __future__ import print_function from . import github diff --git a/contrib_bots/bots/git_hub_comment/readme-github-comment-bot.md b/contrib_bots/bots/git_hub_comment/readme.md similarity index 100% rename from contrib_bots/bots/git_hub_comment/readme-github-comment-bot.md rename to contrib_bots/bots/git_hub_comment/readme.md diff --git a/contrib_bots/bots/howdoi_bot/HowdoiBot/answer_howdoi_all.png b/contrib_bots/bots/howdoi_bot/assets/answer_howdoi_all.png similarity index 100% rename from contrib_bots/bots/howdoi_bot/HowdoiBot/answer_howdoi_all.png rename to contrib_bots/bots/howdoi_bot/assets/answer_howdoi_all.png diff --git a/contrib_bots/bots/howdoi_bot/HowdoiBot/answer_howdowe.png b/contrib_bots/bots/howdoi_bot/assets/answer_howdowe.png similarity index 100% rename from contrib_bots/bots/howdoi_bot/HowdoiBot/answer_howdowe.png rename to contrib_bots/bots/howdoi_bot/assets/answer_howdowe.png diff --git a/contrib_bots/bots/howdoi_bot/HowdoiBot/question_howdoi_all.png b/contrib_bots/bots/howdoi_bot/assets/question_howdoi_all.png similarity index 100% rename from contrib_bots/bots/howdoi_bot/HowdoiBot/question_howdoi_all.png rename to contrib_bots/bots/howdoi_bot/assets/question_howdoi_all.png diff --git a/contrib_bots/bots/howdoi_bot/HowdoiBot/question_howdowe.png b/contrib_bots/bots/howdoi_bot/assets/question_howdowe.png similarity index 100% rename from contrib_bots/bots/howdoi_bot/HowdoiBot/question_howdowe.png rename to contrib_bots/bots/howdoi_bot/assets/question_howdowe.png diff --git a/contrib_bots/bots/howdoi_bot/HowdoiBot/docs.md b/contrib_bots/bots/howdoi_bot/readme.md similarity index 89% rename from contrib_bots/bots/howdoi_bot/HowdoiBot/docs.md rename to contrib_bots/bots/howdoi_bot/readme.md index 4d01490..44503a8 100644 --- a/contrib_bots/bots/howdoi_bot/HowdoiBot/docs.md +++ b/contrib_bots/bots/howdoi_bot/readme.md @@ -23,24 +23,24 @@ answer will be formatted differently depending the chosen command. Question -> `@howdowe use supervisor in elixir` - ![howdowe question](question_howdowe.png) + ![howdowe question](assets/question_howdowe.png) Answer -> Howdoi would try to **only** respond with the coding section of the answer. - ![howdowe answer](answer_howdowe.png) + ![howdowe answer](assets/answer_howdowe.png) #### Example 2 Question -> `@howdoi! stack vs heap` - ![howdoi! question](question_howdoi_all.png) + ![howdoi! question](assets/question_howdoi_all.png) Answer -> Howdoi would return the **full** stackoverflow answer via **private message** to the original sender. The URL of the answer can be seen at the bottom of the message. - ![howdoi! answer](answer_howdoi_all.png) + ![howdoi! answer](assets/answer_howdoi_all.png) **Note:** diff --git a/contrib_bots/bots/john/John/assist.png b/contrib_bots/bots/john/assets/assist.png similarity index 100% rename from contrib_bots/bots/john/John/assist.png rename to contrib_bots/bots/john/assets/assist.png diff --git a/contrib_bots/bots/john/John/greetings.png b/contrib_bots/bots/john/assets/greetings.png similarity index 100% rename from contrib_bots/bots/john/John/greetings.png rename to contrib_bots/bots/john/assets/greetings.png diff --git a/contrib_bots/bots/john/John/joke.png b/contrib_bots/bots/john/assets/joke.png similarity index 100% rename from contrib_bots/bots/john/John/joke.png rename to contrib_bots/bots/john/assets/joke.png diff --git a/contrib_bots/bots/john/John/var/jokes.json b/contrib_bots/bots/john/assets/var/jokes.json similarity index 100% rename from contrib_bots/bots/john/John/var/jokes.json rename to contrib_bots/bots/john/assets/var/jokes.json diff --git a/contrib_bots/bots/john/john.py b/contrib_bots/bots/john/john.py index ccfce65..33fcaf1 100644 --- a/contrib_bots/bots/john/john.py +++ b/contrib_bots/bots/john/john.py @@ -15,10 +15,10 @@ CONTRIB_BOTS_DIR = os.path.dirname(os.path.abspath(__file__)) os.chdir(os.path.dirname(CONTRIB_BOTS_DIR)) sys.path.insert(0, os.path.dirname(CONTRIB_BOTS_DIR)) -JOKES_PATH = os.path.join(CONTRIB_BOTS_DIR, 'John/var/jokes.json') -DATABASE_PATH = os.path.join(CONTRIB_BOTS_DIR, 'John/var/database.db') -DIRECTORY_PATH = os.path.join(CONTRIB_BOTS_DIR, 'John') -VAR_PATH = os.path.join(CONTRIB_BOTS_DIR, 'John/var') +JOKES_PATH = os.path.join(CONTRIB_BOTS_DIR, 'assets/var/jokes.json') +DATABASE_PATH = os.path.join(CONTRIB_BOTS_DIR, 'assets/var/database.db') +DIRECTORY_PATH = os.path.join(CONTRIB_BOTS_DIR, 'assets') +VAR_PATH = os.path.join(CONTRIB_BOTS_DIR, 'assets/var') if not os.path.exists(DIRECTORY_PATH): os.makedirs(DIRECTORY_PATH) diff --git a/contrib_bots/bots/john/John/docs.md b/contrib_bots/bots/john/readme.md similarity index 92% rename from contrib_bots/bots/john/John/docs.md rename to contrib_bots/bots/john/readme.md index 0846a07..32d2197 100644 --- a/contrib_bots/bots/john/John/docs.md +++ b/contrib_bots/bots/john/readme.md @@ -10,7 +10,7 @@ interactive bot that uses machine learning heuristics to simulate a conversation with the user. He has a great sense of humor and is also powered by Open Source code! -![Joke John](joke.png) +![Joke John](assets/joke.png) How it works? John is initially trained with Corpus files, or large text files. @@ -20,11 +20,11 @@ try to find the response that best matches the input according to the Levenshtei which is a string metric for measuring the difference between two sequences. If several responses have the same acurracy, he will choose one at random. -![Meet John](greetings.png) +![Meet John](assets/greetings.png) Can he learn by himself? John's engine allows him to learn from his conversations with people. However, without strict supervision bots that learn from people can do harm, so learning is currently restricted to his initial corpus. -![Assist](assist.png) +![Assist](assets/assist.png) diff --git a/contrib_bots/bots/tictactoe-bot/tictactoe/docs.md b/contrib_bots/bots/tictactoe-bot/readme.md similarity index 100% rename from contrib_bots/bots/tictactoe-bot/tictactoe/docs.md rename to contrib_bots/bots/tictactoe-bot/readme.md diff --git a/contrib_bots/bots/xkcd/xkcd-help.png b/contrib_bots/bots/xkcd/assets/xkcd-help.png similarity index 100% rename from contrib_bots/bots/xkcd/xkcd-help.png rename to contrib_bots/bots/xkcd/assets/xkcd-help.png diff --git a/contrib_bots/bots/xkcd/xkcd-latest.png b/contrib_bots/bots/xkcd/assets/xkcd-latest.png similarity index 100% rename from contrib_bots/bots/xkcd/xkcd-latest.png rename to contrib_bots/bots/xkcd/assets/xkcd-latest.png diff --git a/contrib_bots/bots/xkcd/xkcd-random.png b/contrib_bots/bots/xkcd/assets/xkcd-random.png similarity index 100% rename from contrib_bots/bots/xkcd/xkcd-random.png rename to contrib_bots/bots/xkcd/assets/xkcd-random.png diff --git a/contrib_bots/bots/xkcd/xkcd-specific-id.png b/contrib_bots/bots/xkcd/assets/xkcd-specific-id.png similarity index 100% rename from contrib_bots/bots/xkcd/xkcd-specific-id.png rename to contrib_bots/bots/xkcd/assets/xkcd-specific-id.png diff --git a/contrib_bots/bots/xkcd/xkcd-wrong-command.png b/contrib_bots/bots/xkcd/assets/xkcd-wrong-command.png similarity index 100% rename from contrib_bots/bots/xkcd/xkcd-wrong-command.png rename to contrib_bots/bots/xkcd/assets/xkcd-wrong-command.png diff --git a/contrib_bots/bots/xkcd/xkcd-wrong-id.png b/contrib_bots/bots/xkcd/assets/xkcd-wrong-id.png similarity index 100% rename from contrib_bots/bots/xkcd/xkcd-wrong-id.png rename to contrib_bots/bots/xkcd/assets/xkcd-wrong-id.png diff --git a/contrib_bots/bots/xkcd/docs.md b/contrib_bots/bots/xkcd/readme.md similarity index 86% rename from contrib_bots/bots/xkcd/docs.md rename to contrib_bots/bots/xkcd/readme.md index 3201404..6f666e1 100644 --- a/contrib_bots/bots/xkcd/docs.md +++ b/contrib_bots/bots/xkcd/readme.md @@ -12,29 +12,29 @@ xkcd bot has four commands: 1. `help` This command is used to list all commands that can be used with this bot. You can use this command by typing `@xkcd help` in a stream. -![](xkcd-help.png) +![](assets/xkcd-help.png) 2. `latest` This command is used to fetch the latest comic strip from xkcd. You can use this command by typing `@xkcd latest` in a stream. -![](xkcd-latest.png) +![](assets/xkcd-latest.png) 3. `random` This command is used to fetch a random comic strip from xkcd. You can use this command by typing `@xkcd random` in a stream, xkcd bot will post a random xkcd comic strip. -![](xkcd-random.png) +![](assets/xkcd-random.png) 4. `` To fetch a comic strip based on id, you can directly use `@xkcd `, for example if you want to fetch a comic strip with id 1234, you can type `@xkcd 1234`, xkcd bot will post a comic strip with id 1234. -![](xkcd-specific-id.png) +![](assets/xkcd-specific-id.png) If you type a wrong command to xkcd bot, xkcd bot will post information you'd get from `@xkcd help`. -![](xkcd-wrong-command.png) +![](assets/xkcd-wrong-command.png) And if you type a wrong id, xkcd bot will post a message that an xkcd comic strip with that id is not available. -![](xkcd-wrong-id.png) +![](assets/xkcd-wrong-id.png) diff --git a/contrib_bots/bots/yoda_bot/yoda-speak-api.png b/contrib_bots/bots/yoda_bot/assets/yoda-speak-api.png similarity index 100% rename from contrib_bots/bots/yoda_bot/yoda-speak-api.png rename to contrib_bots/bots/yoda_bot/assets/yoda-speak-api.png diff --git a/contrib_bots/bots/yoda_bot/readme-yoda-bot.md b/contrib_bots/bots/yoda_bot/readme.md similarity index 92% rename from contrib_bots/bots/yoda_bot/readme-yoda-bot.md rename to contrib_bots/bots/yoda_bot/readme.md index a789431..7988193 100644 --- a/contrib_bots/bots/yoda_bot/readme-yoda-bot.md +++ b/contrib_bots/bots/yoda_bot/readme.md @@ -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: diff --git a/contrib_bots/bots/yoda_bot/yoda_bot.config b/contrib_bots/bots/yoda_bot/yoda_bot.config new file mode 100644 index 0000000..e69de29 diff --git a/contrib_bots/bots/yoda_bot/yoda_bot.py b/contrib_bots/bots/yoda_bot/yoda_bot.py index 6790e54..22e2b25 100644 --- a/contrib_bots/bots/yoda_bot/yoda_bot.py +++ b/contrib_bots/bots/yoda_bot/yoda_bot.py @@ -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