diff --git a/contrib_bots/lib/__init__.py b/contrib_bots/bots/__init__.py similarity index 100% rename from contrib_bots/lib/__init__.py rename to contrib_bots/bots/__init__.py diff --git a/contrib_bots/lib/CommuteBot/doc.md b/contrib_bots/bots/commute_bot/CommuteBot/doc.md similarity index 97% rename from contrib_bots/lib/CommuteBot/doc.md rename to contrib_bots/bots/commute_bot/CommuteBot/doc.md index 121b48e..255a088 100644 --- a/contrib_bots/lib/CommuteBot/doc.md +++ b/contrib_bots/bots/commute_bot/CommuteBot/doc.md @@ -17,7 +17,7 @@ the user home directory and add an API key. Move ``` -~/zulip/contrib_bots/lib/CommuteBot/google-commute.ini +~/zulip/contrib_bots/bots/commute_bot/CommuteBot/google-commute.ini ``` into diff --git a/contrib_bots/lib/CommuteBot/google-commute.ini b/contrib_bots/bots/commute_bot/CommuteBot/google-commute.ini similarity index 100% rename from contrib_bots/lib/CommuteBot/google-commute.ini rename to contrib_bots/bots/commute_bot/CommuteBot/google-commute.ini diff --git a/contrib_bots/lib/commute_bot.py b/contrib_bots/bots/commute_bot/commute_bot.py similarity index 97% rename from contrib_bots/lib/commute_bot.py rename to contrib_bots/bots/commute_bot/commute_bot.py index 862503b..ad4e0c8 100644 --- a/contrib_bots/lib/commute_bot.py +++ b/contrib_bots/bots/commute_bot/commute_bot.py @@ -62,7 +62,9 @@ class CommuteHandler(object): Please note: Fare information can be derived, though is solely dependent on the - availability of the informatipython run.py lib/followup.py --config-file ~/.zuliprc-localon released by public transport operators. + availability of the information + python run.py bots/followup/followup.py --config-file ~/.zuliprc-local + released by public transport operators. Duration in traffic can only be derived if a departure time is set. If a location has spaces in its name, please use a + symbol in the place of the space/s. @@ -88,7 +90,7 @@ 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/lib/CommuteBot/google-commute.ini into + # ~/zulip/contrib_bots/bots/commute_bot/CommuteBot/google-commute.ini into # /google-commute.ini for program to work # see doc.md for more information with open(CONFIG_PATH) as settings: diff --git a/contrib_bots/lib/ConverterBot/docs.md b/contrib_bots/bots/converter/ConverterBot/docs.md similarity index 100% rename from contrib_bots/lib/ConverterBot/docs.md rename to contrib_bots/bots/converter/ConverterBot/docs.md diff --git a/contrib_bots/lib/ConverterBot/multiple-converts.png b/contrib_bots/bots/converter/ConverterBot/multiple-converts.png similarity index 100% rename from contrib_bots/lib/ConverterBot/multiple-converts.png rename to contrib_bots/bots/converter/ConverterBot/multiple-converts.png diff --git a/contrib_bots/lib/converter.py b/contrib_bots/bots/converter/converter.py similarity index 100% rename from contrib_bots/lib/converter.py rename to contrib_bots/bots/converter/converter.py diff --git a/contrib_bots/lib/DefineBot/correct_word.png b/contrib_bots/bots/define_bot/DefineBot/correct_word.png similarity index 100% rename from contrib_bots/lib/DefineBot/correct_word.png rename to contrib_bots/bots/define_bot/DefineBot/correct_word.png diff --git a/contrib_bots/lib/DefineBot/docs.md b/contrib_bots/bots/define_bot/DefineBot/docs.md similarity index 100% rename from contrib_bots/lib/DefineBot/docs.md rename to contrib_bots/bots/define_bot/DefineBot/docs.md diff --git a/contrib_bots/lib/DefineBot/wrong_word.png b/contrib_bots/bots/define_bot/DefineBot/wrong_word.png similarity index 100% rename from contrib_bots/lib/DefineBot/wrong_word.png rename to contrib_bots/bots/define_bot/DefineBot/wrong_word.png diff --git a/contrib_bots/lib/define_bot.py b/contrib_bots/bots/define_bot/define_bot.py similarity index 100% rename from contrib_bots/lib/define_bot.py rename to contrib_bots/bots/define_bot/define_bot.py diff --git a/contrib_bots/lib/EncryptBot/EncryptBot-terminal.png b/contrib_bots/bots/encrypt_bot/EncryptBot/EncryptBot-terminal.png similarity index 100% rename from contrib_bots/lib/EncryptBot/EncryptBot-terminal.png rename to contrib_bots/bots/encrypt_bot/EncryptBot/EncryptBot-terminal.png diff --git a/contrib_bots/lib/EncryptBot/EncryptBot-test.png b/contrib_bots/bots/encrypt_bot/EncryptBot/EncryptBot-test.png similarity index 100% rename from contrib_bots/lib/EncryptBot/EncryptBot-test.png rename to contrib_bots/bots/encrypt_bot/EncryptBot/EncryptBot-test.png diff --git a/contrib_bots/lib/EncryptBot/EncryptBot-test2.png b/contrib_bots/bots/encrypt_bot/EncryptBot/EncryptBot-test2.png similarity index 100% rename from contrib_bots/lib/EncryptBot/EncryptBot-test2.png rename to contrib_bots/bots/encrypt_bot/EncryptBot/EncryptBot-test2.png diff --git a/contrib_bots/lib/EncryptBot/EncryptBot-test3.png b/contrib_bots/bots/encrypt_bot/EncryptBot/EncryptBot-test3.png similarity index 100% rename from contrib_bots/lib/EncryptBot/EncryptBot-test3.png rename to contrib_bots/bots/encrypt_bot/EncryptBot/EncryptBot-test3.png diff --git a/contrib_bots/lib/EncryptBot/docs.md b/contrib_bots/bots/encrypt_bot/EncryptBot/docs.md similarity index 100% rename from contrib_bots/lib/EncryptBot/docs.md rename to contrib_bots/bots/encrypt_bot/EncryptBot/docs.md diff --git a/contrib_bots/lib/encrypt_bot.py b/contrib_bots/bots/encrypt_bot/encrypt_bot.py similarity index 100% rename from contrib_bots/lib/encrypt_bot.py rename to contrib_bots/bots/encrypt_bot/encrypt_bot.py diff --git a/contrib_bots/lib/followup.py b/contrib_bots/bots/followup/followup.py similarity index 100% rename from contrib_bots/lib/followup.py rename to contrib_bots/bots/followup/followup.py diff --git a/contrib_bots/lib/FourSquareBot/doc.md b/contrib_bots/bots/foursquare/FourSquareBot/doc.md similarity index 100% rename from contrib_bots/lib/FourSquareBot/doc.md rename to contrib_bots/bots/foursquare/FourSquareBot/doc.md diff --git a/contrib_bots/lib/FourSquareBot/settings.ini b/contrib_bots/bots/foursquare/FourSquareBot/settings.ini similarity index 100% rename from contrib_bots/lib/FourSquareBot/settings.ini rename to contrib_bots/bots/foursquare/FourSquareBot/settings.ini diff --git a/contrib_bots/lib/foursquare.py b/contrib_bots/bots/foursquare/foursquare.py similarity index 96% rename from contrib_bots/lib/foursquare.py rename to contrib_bots/bots/foursquare/foursquare.py index 21c6826..c70d115 100644 --- a/contrib_bots/lib/foursquare.py +++ b/contrib_bots/bots/foursquare/foursquare.py @@ -9,11 +9,11 @@ from six.moves import configparser as cp from six.moves import range home = expanduser('~') -CONFIG_PATH = home + '/zulip/contrib_bots/lib/FourSquareBot/settings.ini' +CONFIG_PATH = home + '/zulip/contrib_bots/bots/foursquare/FourSquareBot/settings.ini' def get_api_key(): # settings.ini must have been moved from - # ~/zulip/contrib_bots/lib/FourSquareBot/settings.ini into + # ~/zulip/contrib_bots/bots/foursquare/FourSquareBot/settings.ini into # ~/settings.ini for program to work # see doc.md for more information with open(CONFIG_PATH) as settings: diff --git a/contrib_bots/lib/giphy.py b/contrib_bots/bots/giphy/giphy.py similarity index 100% rename from contrib_bots/lib/giphy.py rename to contrib_bots/bots/giphy/giphy.py diff --git a/contrib_bots/lib/git_hub_comment.py b/contrib_bots/bots/git_hub_comment/git_hub_comment.py similarity index 100% rename from contrib_bots/lib/git_hub_comment.py rename to contrib_bots/bots/git_hub_comment/git_hub_comment.py diff --git a/contrib_bots/lib/readme-github-comment-bot.md b/contrib_bots/bots/git_hub_comment/readme-github-comment-bot.md similarity index 95% rename from contrib_bots/lib/readme-github-comment-bot.md rename to contrib_bots/bots/git_hub_comment/readme-github-comment-bot.md index 90e7f2d..d852c4f 100644 --- a/contrib_bots/lib/readme-github-comment-bot.md +++ b/contrib_bots/bots/git_hub_comment/readme-github-comment-bot.md @@ -27,7 +27,7 @@ Here is an example of running the `git_hub_comment` bot from inside a Zulip repo: `cd ~/zulip/contrib_bots` - `./run.py lib/git_hub_comment.py --config-file ~/.zuliprc-prod` + `./run.py bots/git_hub_comment/git_hub_comment.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/lib/github.py b/contrib_bots/bots/github/github.py similarity index 100% rename from contrib_bots/lib/github.py rename to contrib_bots/bots/github/github.py diff --git a/contrib_bots/lib/github_issues.py b/contrib_bots/bots/github_issues/github_issues.py similarity index 100% rename from contrib_bots/lib/github_issues.py rename to contrib_bots/bots/github_issues/github_issues.py diff --git a/contrib_bots/lib/help.py b/contrib_bots/bots/help/help.py similarity index 100% rename from contrib_bots/lib/help.py rename to contrib_bots/bots/help/help.py diff --git a/contrib_bots/lib/HowdoiBot/answer_howdoi_all.png b/contrib_bots/bots/howdoi_bot/HowdoiBot/answer_howdoi_all.png similarity index 100% rename from contrib_bots/lib/HowdoiBot/answer_howdoi_all.png rename to contrib_bots/bots/howdoi_bot/HowdoiBot/answer_howdoi_all.png diff --git a/contrib_bots/lib/HowdoiBot/answer_howdowe.png b/contrib_bots/bots/howdoi_bot/HowdoiBot/answer_howdowe.png similarity index 100% rename from contrib_bots/lib/HowdoiBot/answer_howdowe.png rename to contrib_bots/bots/howdoi_bot/HowdoiBot/answer_howdowe.png diff --git a/contrib_bots/lib/HowdoiBot/docs.md b/contrib_bots/bots/howdoi_bot/HowdoiBot/docs.md similarity index 100% rename from contrib_bots/lib/HowdoiBot/docs.md rename to contrib_bots/bots/howdoi_bot/HowdoiBot/docs.md diff --git a/contrib_bots/lib/HowdoiBot/question_howdoi_all.png b/contrib_bots/bots/howdoi_bot/HowdoiBot/question_howdoi_all.png similarity index 100% rename from contrib_bots/lib/HowdoiBot/question_howdoi_all.png rename to contrib_bots/bots/howdoi_bot/HowdoiBot/question_howdoi_all.png diff --git a/contrib_bots/lib/HowdoiBot/question_howdowe.png b/contrib_bots/bots/howdoi_bot/HowdoiBot/question_howdowe.png similarity index 100% rename from contrib_bots/lib/HowdoiBot/question_howdowe.png rename to contrib_bots/bots/howdoi_bot/HowdoiBot/question_howdowe.png diff --git a/contrib_bots/lib/howdoi_bot.py b/contrib_bots/bots/howdoi_bot/howdoi_bot.py similarity index 100% rename from contrib_bots/lib/howdoi_bot.py rename to contrib_bots/bots/howdoi_bot/howdoi_bot.py diff --git a/contrib_bots/lib/John/assist.png b/contrib_bots/bots/john/John/assist.png similarity index 100% rename from contrib_bots/lib/John/assist.png rename to contrib_bots/bots/john/John/assist.png diff --git a/contrib_bots/lib/John/docs.md b/contrib_bots/bots/john/John/docs.md similarity index 100% rename from contrib_bots/lib/John/docs.md rename to contrib_bots/bots/john/John/docs.md diff --git a/contrib_bots/lib/John/greetings.png b/contrib_bots/bots/john/John/greetings.png similarity index 100% rename from contrib_bots/lib/John/greetings.png rename to contrib_bots/bots/john/John/greetings.png diff --git a/contrib_bots/lib/John/joke.png b/contrib_bots/bots/john/John/joke.png similarity index 100% rename from contrib_bots/lib/John/joke.png rename to contrib_bots/bots/john/John/joke.png diff --git a/contrib_bots/lib/John/var/jokes.json b/contrib_bots/bots/john/John/var/jokes.json similarity index 100% rename from contrib_bots/lib/John/var/jokes.json rename to contrib_bots/bots/john/John/var/jokes.json diff --git a/contrib_bots/lib/john.py b/contrib_bots/bots/john/john.py similarity index 100% rename from contrib_bots/lib/john.py rename to contrib_bots/bots/john/john.py diff --git a/contrib_bots/lib/readme.md b/contrib_bots/bots/readme.md similarity index 98% rename from contrib_bots/lib/readme.md rename to contrib_bots/bots/readme.md index 9e5baac..848f4ec 100644 --- a/contrib_bots/lib/readme.md +++ b/contrib_bots/bots/readme.md @@ -33,7 +33,7 @@ Here is an example of running the "follow-up" bot from inside a Zulip repo (and in your remote instance): cd ~/zulip/contrib_bots - ./run.py lib/followup.py --config-file ~/.zuliprc-prod + ./run.py bots/followup/followup.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/lib/thesaurus.py b/contrib_bots/bots/thesaurus/thesaurus.py similarity index 97% rename from contrib_bots/lib/thesaurus.py rename to contrib_bots/bots/thesaurus/thesaurus.py index e9de297..42bee56 100644 --- a/contrib_bots/lib/thesaurus.py +++ b/contrib_bots/bots/thesaurus/thesaurus.py @@ -1,4 +1,4 @@ -# See zulip/contrib_bots/lib/readme.md for instructions on running this code. +# See zulip/contrib_bots/bots/readme.md for instructions on running this code. from __future__ import print_function import sys import logging diff --git a/contrib_bots/lib/tictactoe-bot.py b/contrib_bots/bots/tictactoe-bot/tictactoe-bot.py similarity index 100% rename from contrib_bots/lib/tictactoe-bot.py rename to contrib_bots/bots/tictactoe-bot/tictactoe-bot.py diff --git a/contrib_bots/lib/tictactoe/docs.md b/contrib_bots/bots/tictactoe-bot/tictactoe/docs.md similarity index 100% rename from contrib_bots/lib/tictactoe/docs.md rename to contrib_bots/bots/tictactoe-bot/tictactoe/docs.md diff --git a/contrib_bots/lib/virtual_fs.py b/contrib_bots/bots/virtual_fs/virtual_fs.py similarity index 100% rename from contrib_bots/lib/virtual_fs.py rename to contrib_bots/bots/virtual_fs/virtual_fs.py diff --git a/contrib_bots/lib/wikipedia.py b/contrib_bots/bots/wikipedia/wikipedia.py similarity index 100% rename from contrib_bots/lib/wikipedia.py rename to contrib_bots/bots/wikipedia/wikipedia.py diff --git a/contrib_bots/lib/xkcd/docs.md b/contrib_bots/bots/xkcd/docs.md similarity index 100% rename from contrib_bots/lib/xkcd/docs.md rename to contrib_bots/bots/xkcd/docs.md diff --git a/contrib_bots/lib/xkcd/xkcd-help.png b/contrib_bots/bots/xkcd/xkcd-help.png similarity index 100% rename from contrib_bots/lib/xkcd/xkcd-help.png rename to contrib_bots/bots/xkcd/xkcd-help.png diff --git a/contrib_bots/lib/xkcd/xkcd-latest.png b/contrib_bots/bots/xkcd/xkcd-latest.png similarity index 100% rename from contrib_bots/lib/xkcd/xkcd-latest.png rename to contrib_bots/bots/xkcd/xkcd-latest.png diff --git a/contrib_bots/lib/xkcd/xkcd-random.png b/contrib_bots/bots/xkcd/xkcd-random.png similarity index 100% rename from contrib_bots/lib/xkcd/xkcd-random.png rename to contrib_bots/bots/xkcd/xkcd-random.png diff --git a/contrib_bots/lib/xkcd/xkcd-specific-id.png b/contrib_bots/bots/xkcd/xkcd-specific-id.png similarity index 100% rename from contrib_bots/lib/xkcd/xkcd-specific-id.png rename to contrib_bots/bots/xkcd/xkcd-specific-id.png diff --git a/contrib_bots/lib/xkcd/xkcd-wrong-command.png b/contrib_bots/bots/xkcd/xkcd-wrong-command.png similarity index 100% rename from contrib_bots/lib/xkcd/xkcd-wrong-command.png rename to contrib_bots/bots/xkcd/xkcd-wrong-command.png diff --git a/contrib_bots/lib/xkcd/xkcd-wrong-id.png b/contrib_bots/bots/xkcd/xkcd-wrong-id.png similarity index 100% rename from contrib_bots/lib/xkcd/xkcd-wrong-id.png rename to contrib_bots/bots/xkcd/xkcd-wrong-id.png diff --git a/contrib_bots/lib/xkcd.py b/contrib_bots/bots/xkcd/xkcd.py similarity index 100% rename from contrib_bots/lib/xkcd.py rename to contrib_bots/bots/xkcd/xkcd.py diff --git a/contrib_bots/lib/readme-yoda-bot.md b/contrib_bots/bots/yoda_bot/readme-yoda-bot.md similarity index 97% rename from contrib_bots/lib/readme-yoda-bot.md rename to contrib_bots/bots/yoda_bot/readme-yoda-bot.md index f0616fd..a05bb05 100644 --- a/contrib_bots/lib/readme-yoda-bot.md +++ b/contrib_bots/bots/yoda_bot/readme-yoda-bot.md @@ -55,7 +55,7 @@ Here is an example of running the "yoda_bot" bot from inside a Zulip repo: cd ~/zulip/contrib_bots - ./run.py lib/yoda_bot.py --config-file ~/.zuliprc-prod + ./run.py bots/yoda_bot/yoda_bot.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/lib/yoda-speak-api.png b/contrib_bots/bots/yoda_bot/yoda-speak-api.png similarity index 100% rename from contrib_bots/lib/yoda-speak-api.png rename to contrib_bots/bots/yoda_bot/yoda-speak-api.png diff --git a/contrib_bots/lib/yoda_bot.py b/contrib_bots/bots/yoda_bot/yoda_bot.py similarity index 100% rename from contrib_bots/lib/yoda_bot.py rename to contrib_bots/bots/yoda_bot/yoda_bot.py diff --git a/contrib_bots/run.py b/contrib_bots/run.py index d56422d..3bec299 100755 --- a/contrib_bots/run.py +++ b/contrib_bots/run.py @@ -12,36 +12,31 @@ sys.path.insert(0, our_dir) from bot_lib import run_message_handler_for_bot -def get_lib_module(lib_fn): - lib_fn = os.path.abspath(lib_fn) - if not os.path.dirname(lib_fn).startswith(os.path.join(our_dir, 'lib')): - print('Sorry, we will only import code from contrib_bots/lib.') +def get_lib_module(bots_fn): + bots_fn = os.path.abspath(bots_fn) + if not os.path.dirname(bots_fn).startswith(os.path.join(our_dir, 'bots')): + print('Sorry, we will only import code from contrib_bots/bots.') sys.exit(1) - if not lib_fn.endswith('.py'): + if not bots_fn.endswith('.py'): print('Please use a .py extension for library files.') sys.exit(1) - - sys.path.append('lib') - base_lib_fn = os.path.basename(os.path.splitext(lib_fn)[0]) - module_name = 'lib.' + base_lib_fn + base_bots_fn = os.path.basename(os.path.splitext(bots_fn)[0]) + sys.path.append('bots/{}'.format(base_bots_fn)) + module_name = base_bots_fn module = importlib.import_module(module_name) return module def run(): usage = ''' ./run.py - Example: ./run.py lib/followup.py - (This program loads bot-related code from the library code and then runs a message loop, feeding messages to the library code to handle.) - Please make sure you have a current ~/.zuliprc file with the credentials you want to use for this bot. - See lib/readme.md for more context. ''' @@ -58,7 +53,7 @@ def run(): print('You must specify a library!') sys.exit(1) - lib_module = get_lib_module(lib_fn=args[0]) + lib_module = get_lib_module(bots_fn=args[0]) if not options.quiet: logging.basicConfig(stream=sys.stdout, level=logging.INFO)