From db9918f3d62d61cb0f099295c42f3d8e071cde10 Mon Sep 17 00:00:00 2001 From: Rohitt Vashishtha Date: Tue, 30 May 2017 11:40:19 +0530 Subject: [PATCH] bots: Move contrib_bots to api/bots*. This will make it convenient to include these bots in Zulip API releases on pypi. Fix #5009. --- .gitignore | 2 +- {contrib_bots => api/bots}/__init__.py | 0 .../bots => api/bots/commute}/__init__.py | 0 .../bots/commute/commute.config | 0 {contrib_bots => api}/bots/commute/commute.py | 2 +- {contrib_bots => api}/bots/commute/readme.md | 2 +- .../bots/converter}/__init__.py | 0 .../converter/assets/multiple-converts.png | Bin .../bots/converter/converter.config | 0 .../bots/converter/converter.py | 0 .../bots/converter/readme.md | 0 .../bots/converter/test_converter.py | 1 + {contrib_bots => api}/bots/converter/utils.py | 0 .../converter => api/bots/define}/__init__.py | 0 .../bots/define/assets/correct_word.png | Bin .../bots/define/assets/wrong_word.png | Bin {contrib_bots => api}/bots/define/define.py | 0 {contrib_bots => api}/bots/define/readme.md | 0 .../bots/define/test_define.py | 1 + .../define => api/bots/encrypt}/__init__.py | 0 .../encrypt/assets/EncryptBot-terminal.png | Bin .../bots/encrypt/assets/EncryptBot-test.png | Bin .../bots/encrypt/assets/EncryptBot-test2.png | Bin .../bots/encrypt/assets/EncryptBot-test3.png | Bin {contrib_bots => api}/bots/encrypt/encrypt.py | 0 {contrib_bots => api}/bots/encrypt/readme.md | 0 .../bots/encrypt/test_encrypt.py | 1 + .../encrypt => api/bots/followup}/__init__.py | 0 .../bots/followup/followup.py | 0 .../bots/foursquare}/__init__.py | 0 .../bots/foursquare/foursquare.config | 0 .../bots/foursquare/foursquare.py | 4 +-- .../bots/foursquare/readme.md | 0 .../foursquare => api/bots/giphy}/__init__.py | 0 {contrib_bots => api}/bots/giphy/giphy.py | 0 .../bots/git_hub_comment}/__init__.py | 0 .../bots/git_hub_comment/git_hub_comment.py | 0 .../bots/git_hub_comment/readme.md | 4 +-- .../bots/github}/__init__.py | 0 {contrib_bots => api}/bots/github/github.py | 0 .../bots/github_issues}/__init__.py | 0 .../bots/github_issues/github_issues.py | 0 .../bots/googlesearch}/__init__.py | 0 .../bots/googlesearch/googlesearch.py | 0 .../bots/googlesearch/readme.md | 0 .../bots/helloworld}/__init__.py | 0 .../bots/helloworld/helloworld.py | 0 .../bots/helloworld/readme.md | 0 .../bots/helloworld/test_helloworld.py | 1 + .../helloworld => api/bots/help}/__init__.py | 0 {contrib_bots => api}/bots/help/help.py | 0 {contrib_bots => api}/bots/help/test_help.py | 1 + .../bots/help => api/bots/howdoi}/__init__.py | 0 .../bots/howdoi/assets/answer_howdoi_all.png | Bin .../bots/howdoi/assets/answer_howdowe.png | Bin .../howdoi/assets/question_howdoi_all.png | Bin .../bots/howdoi/assets/question_howdowe.png | Bin {contrib_bots => api}/bots/howdoi/howdoi.py | 0 {contrib_bots => api}/bots/howdoi/readme.md | 0 .../bots/incrementor}/__init__.py | 0 .../bots/incrementor/incrementor.py | 0 .../bots/incrementor/readme.md | 0 .../incrementor => api/bots/john}/__init__.py | 0 .../bots/john/assets/assist.png | Bin .../bots/john/assets/greetings.png | Bin .../bots/john/assets/joke.png | Bin .../bots/john/assets/var/jokes.json | 0 {contrib_bots => api}/bots/john/john.py | 14 ++++---- {contrib_bots => api}/bots/john/readme.md | 0 {contrib_bots => api}/bots/readme.md | 4 +-- .../john => api/bots/thesaurus}/__init__.py | 0 .../bots/thesaurus/test_thesaurus.py | 1 + .../bots/thesaurus/thesaurus.py | 2 +- .../bots/tictactoe}/__init__.py | 0 .../bots/tictactoe/readme.md | 0 .../bots/tictactoe/tictactoe.py | 0 .../bots/virtual_fs}/__init__.py | 0 .../bots/virtual_fs/readme.md | 0 .../bots/virtual_fs/test_virtual_fs.py | 1 + .../bots/virtual_fs/virtual_fs.py | 0 .../bots/weather/.weather_config | 0 .../bots/weather/assets/screen1.png | Bin .../bots/weather/assets/screen2.png | Bin {contrib_bots => api}/bots/weather/readme.md | 0 {contrib_bots => api}/bots/weather/weather.py | 0 .../bots/wikipedia}/__init__.py | 0 .../bots/wikipedia/test_wikipedia.py | 1 + .../bots/wikipedia/wikipedia.py | 0 .../wikipedia => api/bots/xkcd}/__init__.py | 0 .../bots/xkcd/assets/xkcd-help.png | Bin .../bots/xkcd/assets/xkcd-latest.png | Bin .../bots/xkcd/assets/xkcd-random.png | Bin .../bots/xkcd/assets/xkcd-specific-id.png | Bin .../bots/xkcd/assets/xkcd-wrong-command.png | Bin .../bots/xkcd/assets/xkcd-wrong-id.png | Bin {contrib_bots => api}/bots/xkcd/readme.md | 0 {contrib_bots => api}/bots/xkcd/test_xkcd.py | 1 + {contrib_bots => api}/bots/xkcd/xkcd.py | 0 .../bots/xkcd => api/bots/yoda}/__init__.py | 0 .../bots/yoda/assets/yoda-speak-api.png | Bin {contrib_bots => api}/bots/yoda/readme.md | 4 +-- {contrib_bots => api}/bots/yoda/yoda.config | 0 {contrib_bots => api}/bots/yoda/yoda.py | 0 .../bots/youtube/assets/screen.png | Bin {contrib_bots => api}/bots/youtube/readme.md | 0 {contrib_bots => api}/bots/youtube/youtube.py | 0 .../bots/yoda => api/bots_api}/__init__.py | 0 {contrib_bots => api/bots_api}/bot_lib.py | 4 +-- .../bots_api}/bots_test_lib.py | 7 ++-- {contrib_bots => api/bots_api}/run.py | 4 +-- {contrib_bots => api/bots_api}/test-bots | 3 +- docs/bots-guide.md | 34 +++++++++--------- docs/custom-apps.md | 2 +- tools/lint | 2 +- tools/run-mypy | 4 +-- zerver/worker/queue_processors.py | 8 +++-- 116 files changed, 64 insertions(+), 51 deletions(-) rename {contrib_bots => api/bots}/__init__.py (100%) rename {contrib_bots/bots => api/bots/commute}/__init__.py (100%) rename {contrib_bots => api}/bots/commute/commute.config (100%) rename {contrib_bots => api}/bots/commute/commute.py (99%) rename {contrib_bots => api}/bots/commute/readme.md (98%) rename {contrib_bots/bots/commute => api/bots/converter}/__init__.py (100%) rename {contrib_bots => api}/bots/converter/assets/multiple-converts.png (100%) rename {contrib_bots => api}/bots/converter/converter.config (100%) rename {contrib_bots => api}/bots/converter/converter.py (100%) rename {contrib_bots => api}/bots/converter/readme.md (100%) rename {contrib_bots => api}/bots/converter/test_converter.py (94%) rename {contrib_bots => api}/bots/converter/utils.py (100%) rename {contrib_bots/bots/converter => api/bots/define}/__init__.py (100%) rename {contrib_bots => api}/bots/define/assets/correct_word.png (100%) rename {contrib_bots => api}/bots/define/assets/wrong_word.png (100%) rename {contrib_bots => api}/bots/define/define.py (100%) rename {contrib_bots => api}/bots/define/readme.md (100%) rename {contrib_bots => api}/bots/define/test_define.py (94%) rename {contrib_bots/bots/define => api/bots/encrypt}/__init__.py (100%) rename {contrib_bots => api}/bots/encrypt/assets/EncryptBot-terminal.png (100%) rename {contrib_bots => api}/bots/encrypt/assets/EncryptBot-test.png (100%) rename {contrib_bots => api}/bots/encrypt/assets/EncryptBot-test2.png (100%) rename {contrib_bots => api}/bots/encrypt/assets/EncryptBot-test3.png (100%) rename {contrib_bots => api}/bots/encrypt/encrypt.py (100%) rename {contrib_bots => api}/bots/encrypt/readme.md (100%) rename {contrib_bots => api}/bots/encrypt/test_encrypt.py (93%) rename {contrib_bots/bots/encrypt => api/bots/followup}/__init__.py (100%) rename {contrib_bots => api}/bots/followup/followup.py (100%) rename {contrib_bots/bots/followup => api/bots/foursquare}/__init__.py (100%) rename {contrib_bots => api}/bots/foursquare/foursquare.config (100%) rename {contrib_bots => api}/bots/foursquare/foursquare.py (96%) rename {contrib_bots => api}/bots/foursquare/readme.md (100%) rename {contrib_bots/bots/foursquare => api/bots/giphy}/__init__.py (100%) rename {contrib_bots => api}/bots/giphy/giphy.py (100%) rename {contrib_bots/bots/giphy => api/bots/git_hub_comment}/__init__.py (100%) rename {contrib_bots => api}/bots/git_hub_comment/git_hub_comment.py (100%) rename {contrib_bots => api}/bots/git_hub_comment/readme.md (94%) rename {contrib_bots/bots/git_hub_comment => api/bots/github}/__init__.py (100%) rename {contrib_bots => api}/bots/github/github.py (100%) rename {contrib_bots/bots/github => api/bots/github_issues}/__init__.py (100%) rename {contrib_bots => api}/bots/github_issues/github_issues.py (100%) rename {contrib_bots/bots/github_issues => api/bots/googlesearch}/__init__.py (100%) rename {contrib_bots => api}/bots/googlesearch/googlesearch.py (100%) rename {contrib_bots => api}/bots/googlesearch/readme.md (100%) rename {contrib_bots/bots/googlesearch => api/bots/helloworld}/__init__.py (100%) rename {contrib_bots => api}/bots/helloworld/helloworld.py (100%) rename {contrib_bots => api}/bots/helloworld/readme.md (100%) rename {contrib_bots => api}/bots/helloworld/test_helloworld.py (91%) rename {contrib_bots/bots/helloworld => api/bots/help}/__init__.py (100%) rename {contrib_bots => api}/bots/help/help.py (100%) rename {contrib_bots => api}/bots/help/test_help.py (91%) rename {contrib_bots/bots/help => api/bots/howdoi}/__init__.py (100%) rename {contrib_bots => api}/bots/howdoi/assets/answer_howdoi_all.png (100%) rename {contrib_bots => api}/bots/howdoi/assets/answer_howdowe.png (100%) rename {contrib_bots => api}/bots/howdoi/assets/question_howdoi_all.png (100%) rename {contrib_bots => api}/bots/howdoi/assets/question_howdowe.png (100%) rename {contrib_bots => api}/bots/howdoi/howdoi.py (100%) rename {contrib_bots => api}/bots/howdoi/readme.md (100%) rename {contrib_bots/bots/howdoi => api/bots/incrementor}/__init__.py (100%) rename {contrib_bots => api}/bots/incrementor/incrementor.py (100%) rename {contrib_bots => api}/bots/incrementor/readme.md (100%) rename {contrib_bots/bots/incrementor => api/bots/john}/__init__.py (100%) rename {contrib_bots => api}/bots/john/assets/assist.png (100%) rename {contrib_bots => api}/bots/john/assets/greetings.png (100%) rename {contrib_bots => api}/bots/john/assets/joke.png (100%) rename {contrib_bots => api}/bots/john/assets/var/jokes.json (100%) rename {contrib_bots => api}/bots/john/john.py (89%) rename {contrib_bots => api}/bots/john/readme.md (100%) rename {contrib_bots => api}/bots/readme.md (98%) rename {contrib_bots/bots/john => api/bots/thesaurus}/__init__.py (100%) rename {contrib_bots => api}/bots/thesaurus/test_thesaurus.py (97%) rename {contrib_bots => api}/bots/thesaurus/thesaurus.py (97%) rename {contrib_bots/bots/thesaurus => api/bots/tictactoe}/__init__.py (100%) rename {contrib_bots => api}/bots/tictactoe/readme.md (100%) rename {contrib_bots => api}/bots/tictactoe/tictactoe.py (100%) rename {contrib_bots/bots/tictactoe => api/bots/virtual_fs}/__init__.py (100%) rename {contrib_bots => api}/bots/virtual_fs/readme.md (100%) rename {contrib_bots => api}/bots/virtual_fs/test_virtual_fs.py (98%) rename {contrib_bots => api}/bots/virtual_fs/virtual_fs.py (100%) rename {contrib_bots => api}/bots/weather/.weather_config (100%) rename {contrib_bots => api}/bots/weather/assets/screen1.png (100%) rename {contrib_bots => api}/bots/weather/assets/screen2.png (100%) rename {contrib_bots => api}/bots/weather/readme.md (100%) rename {contrib_bots => api}/bots/weather/weather.py (100%) rename {contrib_bots/bots/virtual_fs => api/bots/wikipedia}/__init__.py (100%) rename {contrib_bots => api}/bots/wikipedia/test_wikipedia.py (94%) rename {contrib_bots => api}/bots/wikipedia/wikipedia.py (100%) rename {contrib_bots/bots/wikipedia => api/bots/xkcd}/__init__.py (100%) rename {contrib_bots => api}/bots/xkcd/assets/xkcd-help.png (100%) rename {contrib_bots => api}/bots/xkcd/assets/xkcd-latest.png (100%) rename {contrib_bots => api}/bots/xkcd/assets/xkcd-random.png (100%) rename {contrib_bots => api}/bots/xkcd/assets/xkcd-specific-id.png (100%) rename {contrib_bots => api}/bots/xkcd/assets/xkcd-wrong-command.png (100%) rename {contrib_bots => api}/bots/xkcd/assets/xkcd-wrong-id.png (100%) rename {contrib_bots => api}/bots/xkcd/readme.md (100%) rename {contrib_bots => api}/bots/xkcd/test_xkcd.py (96%) rename {contrib_bots => api}/bots/xkcd/xkcd.py (100%) rename {contrib_bots/bots/xkcd => api/bots/yoda}/__init__.py (100%) rename {contrib_bots => api}/bots/yoda/assets/yoda-speak-api.png (100%) rename {contrib_bots => api}/bots/yoda/readme.md (96%) rename {contrib_bots => api}/bots/yoda/yoda.config (100%) rename {contrib_bots => api}/bots/yoda/yoda.py (100%) rename {contrib_bots => api}/bots/youtube/assets/screen.png (100%) rename {contrib_bots => api}/bots/youtube/readme.md (100%) rename {contrib_bots => api}/bots/youtube/youtube.py (100%) rename {contrib_bots/bots/yoda => api/bots_api}/__init__.py (100%) rename {contrib_bots => api/bots_api}/bot_lib.py (98%) rename {contrib_bots => api/bots_api}/bots_test_lib.py (92%) rename {contrib_bots => api/bots_api}/run.py (92%) rename {contrib_bots => api/bots_api}/test-bots (93%) diff --git a/.gitignore b/.gitignore index 77786377fe..65a2fa59b8 100644 --- a/.gitignore +++ b/.gitignore @@ -31,4 +31,4 @@ var/* .vscode/ tools/conf.ini tools/custom_provision -contrib_bots/bots/john/assets/var/database.db +api/bots/john/assets/var/database.db diff --git a/contrib_bots/__init__.py b/api/bots/__init__.py similarity index 100% rename from contrib_bots/__init__.py rename to api/bots/__init__.py diff --git a/contrib_bots/bots/__init__.py b/api/bots/commute/__init__.py similarity index 100% rename from contrib_bots/bots/__init__.py rename to api/bots/commute/__init__.py diff --git a/contrib_bots/bots/commute/commute.config b/api/bots/commute/commute.config similarity index 100% rename from contrib_bots/bots/commute/commute.config rename to api/bots/commute/commute.config diff --git a/contrib_bots/bots/commute/commute.py b/api/bots/commute/commute.py similarity index 99% rename from contrib_bots/bots/commute/commute.py rename to api/bots/commute/commute.py index 8a55afa276..b961ef8367 100644 --- a/contrib_bots/bots/commute/commute.py +++ b/api/bots/commute/commute.py @@ -80,7 +80,7 @@ class CommuteHandler(object): # adds API Authentication Key to url request def get_api_key(self): # commute.config must be moved from - # ~/zulip/contrib_bots/bots/commute/commute.config into + # ~/zulip/api/bots/commute/commute.config into # ~/commute.config for program to work # see readme.md for more information with open(CONFIG_PATH) as settings: diff --git a/contrib_bots/bots/commute/readme.md b/api/bots/commute/readme.md similarity index 98% rename from contrib_bots/bots/commute/readme.md rename to api/bots/commute/readme.md index a60067cafb..d81ca134c3 100644 --- a/contrib_bots/bots/commute/readme.md +++ b/api/bots/commute/readme.md @@ -17,7 +17,7 @@ the user home directory and add an API key. Move ``` -~/zulip/contrib_bots/bots/commute/commute.config +~/zulip/api/bots/commute/commute.config ``` into diff --git a/contrib_bots/bots/commute/__init__.py b/api/bots/converter/__init__.py similarity index 100% rename from contrib_bots/bots/commute/__init__.py rename to api/bots/converter/__init__.py diff --git a/contrib_bots/bots/converter/assets/multiple-converts.png b/api/bots/converter/assets/multiple-converts.png similarity index 100% rename from contrib_bots/bots/converter/assets/multiple-converts.png rename to api/bots/converter/assets/multiple-converts.png diff --git a/contrib_bots/bots/converter/converter.config b/api/bots/converter/converter.config similarity index 100% rename from contrib_bots/bots/converter/converter.config rename to api/bots/converter/converter.config diff --git a/contrib_bots/bots/converter/converter.py b/api/bots/converter/converter.py similarity index 100% rename from contrib_bots/bots/converter/converter.py rename to api/bots/converter/converter.py diff --git a/contrib_bots/bots/converter/readme.md b/api/bots/converter/readme.md similarity index 100% rename from contrib_bots/bots/converter/readme.md rename to api/bots/converter/readme.md diff --git a/contrib_bots/bots/converter/test_converter.py b/api/bots/converter/test_converter.py similarity index 94% rename from contrib_bots/bots/converter/test_converter.py rename to api/bots/converter/test_converter.py index 90843d92fc..b379b0851e 100644 --- a/contrib_bots/bots/converter/test_converter.py +++ b/api/bots/converter/test_converter.py @@ -7,6 +7,7 @@ import os import sys our_dir = os.path.dirname(os.path.abspath(__file__)) +sys.path.insert(0, os.path.normpath(os.path.join(our_dir))) # For dev setups, we can find the API in the repo itself. if os.path.exists(os.path.join(our_dir, '..')): sys.path.insert(0, '..') diff --git a/contrib_bots/bots/converter/utils.py b/api/bots/converter/utils.py similarity index 100% rename from contrib_bots/bots/converter/utils.py rename to api/bots/converter/utils.py diff --git a/contrib_bots/bots/converter/__init__.py b/api/bots/define/__init__.py similarity index 100% rename from contrib_bots/bots/converter/__init__.py rename to api/bots/define/__init__.py diff --git a/contrib_bots/bots/define/assets/correct_word.png b/api/bots/define/assets/correct_word.png similarity index 100% rename from contrib_bots/bots/define/assets/correct_word.png rename to api/bots/define/assets/correct_word.png diff --git a/contrib_bots/bots/define/assets/wrong_word.png b/api/bots/define/assets/wrong_word.png similarity index 100% rename from contrib_bots/bots/define/assets/wrong_word.png rename to api/bots/define/assets/wrong_word.png diff --git a/contrib_bots/bots/define/define.py b/api/bots/define/define.py similarity index 100% rename from contrib_bots/bots/define/define.py rename to api/bots/define/define.py diff --git a/contrib_bots/bots/define/readme.md b/api/bots/define/readme.md similarity index 100% rename from contrib_bots/bots/define/readme.md rename to api/bots/define/readme.md diff --git a/contrib_bots/bots/define/test_define.py b/api/bots/define/test_define.py similarity index 94% rename from contrib_bots/bots/define/test_define.py rename to api/bots/define/test_define.py index e3658606e3..1841fa948a 100644 --- a/contrib_bots/bots/define/test_define.py +++ b/api/bots/define/test_define.py @@ -7,6 +7,7 @@ import os import sys our_dir = os.path.dirname(os.path.abspath(__file__)) +sys.path.insert(0, os.path.normpath(os.path.join(our_dir))) # For dev setups, we can find the API in the repo itself. if os.path.exists(os.path.join(our_dir, '..')): sys.path.insert(0, '..') diff --git a/contrib_bots/bots/define/__init__.py b/api/bots/encrypt/__init__.py similarity index 100% rename from contrib_bots/bots/define/__init__.py rename to api/bots/encrypt/__init__.py diff --git a/contrib_bots/bots/encrypt/assets/EncryptBot-terminal.png b/api/bots/encrypt/assets/EncryptBot-terminal.png similarity index 100% rename from contrib_bots/bots/encrypt/assets/EncryptBot-terminal.png rename to api/bots/encrypt/assets/EncryptBot-terminal.png diff --git a/contrib_bots/bots/encrypt/assets/EncryptBot-test.png b/api/bots/encrypt/assets/EncryptBot-test.png similarity index 100% rename from contrib_bots/bots/encrypt/assets/EncryptBot-test.png rename to api/bots/encrypt/assets/EncryptBot-test.png diff --git a/contrib_bots/bots/encrypt/assets/EncryptBot-test2.png b/api/bots/encrypt/assets/EncryptBot-test2.png similarity index 100% rename from contrib_bots/bots/encrypt/assets/EncryptBot-test2.png rename to api/bots/encrypt/assets/EncryptBot-test2.png diff --git a/contrib_bots/bots/encrypt/assets/EncryptBot-test3.png b/api/bots/encrypt/assets/EncryptBot-test3.png similarity index 100% rename from contrib_bots/bots/encrypt/assets/EncryptBot-test3.png rename to api/bots/encrypt/assets/EncryptBot-test3.png diff --git a/contrib_bots/bots/encrypt/encrypt.py b/api/bots/encrypt/encrypt.py similarity index 100% rename from contrib_bots/bots/encrypt/encrypt.py rename to api/bots/encrypt/encrypt.py diff --git a/contrib_bots/bots/encrypt/readme.md b/api/bots/encrypt/readme.md similarity index 100% rename from contrib_bots/bots/encrypt/readme.md rename to api/bots/encrypt/readme.md diff --git a/contrib_bots/bots/encrypt/test_encrypt.py b/api/bots/encrypt/test_encrypt.py similarity index 93% rename from contrib_bots/bots/encrypt/test_encrypt.py rename to api/bots/encrypt/test_encrypt.py index 21613ca020..030f1753b7 100644 --- a/contrib_bots/bots/encrypt/test_encrypt.py +++ b/api/bots/encrypt/test_encrypt.py @@ -7,6 +7,7 @@ import os import sys our_dir = os.path.dirname(os.path.abspath(__file__)) +sys.path.insert(0, os.path.normpath(os.path.join(our_dir))) # For dev setups, we can find the API in the repo itself. if os.path.exists(os.path.join(our_dir, '..')): sys.path.insert(0, '..') diff --git a/contrib_bots/bots/encrypt/__init__.py b/api/bots/followup/__init__.py similarity index 100% rename from contrib_bots/bots/encrypt/__init__.py rename to api/bots/followup/__init__.py diff --git a/contrib_bots/bots/followup/followup.py b/api/bots/followup/followup.py similarity index 100% rename from contrib_bots/bots/followup/followup.py rename to api/bots/followup/followup.py diff --git a/contrib_bots/bots/followup/__init__.py b/api/bots/foursquare/__init__.py similarity index 100% rename from contrib_bots/bots/followup/__init__.py rename to api/bots/foursquare/__init__.py diff --git a/contrib_bots/bots/foursquare/foursquare.config b/api/bots/foursquare/foursquare.config similarity index 100% rename from contrib_bots/bots/foursquare/foursquare.config rename to api/bots/foursquare/foursquare.config diff --git a/contrib_bots/bots/foursquare/foursquare.py b/api/bots/foursquare/foursquare.py similarity index 96% rename from contrib_bots/bots/foursquare/foursquare.py rename to api/bots/foursquare/foursquare.py index e71a18a428..2fa11aafed 100644 --- a/contrib_bots/bots/foursquare/foursquare.py +++ b/api/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/bots/foursquare/foursquare.config' +CONFIG_PATH = home + '/zulip/api/bots/foursquare/foursquare.config' def get_api_key(): # foursquare.config must have been moved from - # ~/zulip/contrib_bots/bots/foursquare/foursquare.config into + # ~/zulip/api/bots/foursquare/foursquare.config into # ~/foursquare.config for program to work # see readme.md for more information with open(CONFIG_PATH) as settings: diff --git a/contrib_bots/bots/foursquare/readme.md b/api/bots/foursquare/readme.md similarity index 100% rename from contrib_bots/bots/foursquare/readme.md rename to api/bots/foursquare/readme.md diff --git a/contrib_bots/bots/foursquare/__init__.py b/api/bots/giphy/__init__.py similarity index 100% rename from contrib_bots/bots/foursquare/__init__.py rename to api/bots/giphy/__init__.py diff --git a/contrib_bots/bots/giphy/giphy.py b/api/bots/giphy/giphy.py similarity index 100% rename from contrib_bots/bots/giphy/giphy.py rename to api/bots/giphy/giphy.py diff --git a/contrib_bots/bots/giphy/__init__.py b/api/bots/git_hub_comment/__init__.py similarity index 100% rename from contrib_bots/bots/giphy/__init__.py rename to api/bots/git_hub_comment/__init__.py diff --git a/contrib_bots/bots/git_hub_comment/git_hub_comment.py b/api/bots/git_hub_comment/git_hub_comment.py similarity index 100% rename from contrib_bots/bots/git_hub_comment/git_hub_comment.py rename to api/bots/git_hub_comment/git_hub_comment.py diff --git a/contrib_bots/bots/git_hub_comment/readme.md b/api/bots/git_hub_comment/readme.md similarity index 94% rename from contrib_bots/bots/git_hub_comment/readme.md rename to api/bots/git_hub_comment/readme.md index d852c4f9e4..06ffc56471 100644 --- a/contrib_bots/bots/git_hub_comment/readme.md +++ b/api/bots/git_hub_comment/readme.md @@ -26,8 +26,8 @@ github_token = (The personal access token for the GitHub bot) Here is an example of running the `git_hub_comment` bot from inside a Zulip repo: - `cd ~/zulip/contrib_bots` - `./run.py bots/git_hub_comment/git_hub_comment.py --config-file ~/.zuliprc-prod` + `cd ~/zulip/api` + `bots_api/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/bots/git_hub_comment/__init__.py b/api/bots/github/__init__.py similarity index 100% rename from contrib_bots/bots/git_hub_comment/__init__.py rename to api/bots/github/__init__.py diff --git a/contrib_bots/bots/github/github.py b/api/bots/github/github.py similarity index 100% rename from contrib_bots/bots/github/github.py rename to api/bots/github/github.py diff --git a/contrib_bots/bots/github/__init__.py b/api/bots/github_issues/__init__.py similarity index 100% rename from contrib_bots/bots/github/__init__.py rename to api/bots/github_issues/__init__.py diff --git a/contrib_bots/bots/github_issues/github_issues.py b/api/bots/github_issues/github_issues.py similarity index 100% rename from contrib_bots/bots/github_issues/github_issues.py rename to api/bots/github_issues/github_issues.py diff --git a/contrib_bots/bots/github_issues/__init__.py b/api/bots/googlesearch/__init__.py similarity index 100% rename from contrib_bots/bots/github_issues/__init__.py rename to api/bots/googlesearch/__init__.py diff --git a/contrib_bots/bots/googlesearch/googlesearch.py b/api/bots/googlesearch/googlesearch.py similarity index 100% rename from contrib_bots/bots/googlesearch/googlesearch.py rename to api/bots/googlesearch/googlesearch.py diff --git a/contrib_bots/bots/googlesearch/readme.md b/api/bots/googlesearch/readme.md similarity index 100% rename from contrib_bots/bots/googlesearch/readme.md rename to api/bots/googlesearch/readme.md diff --git a/contrib_bots/bots/googlesearch/__init__.py b/api/bots/helloworld/__init__.py similarity index 100% rename from contrib_bots/bots/googlesearch/__init__.py rename to api/bots/helloworld/__init__.py diff --git a/contrib_bots/bots/helloworld/helloworld.py b/api/bots/helloworld/helloworld.py similarity index 100% rename from contrib_bots/bots/helloworld/helloworld.py rename to api/bots/helloworld/helloworld.py diff --git a/contrib_bots/bots/helloworld/readme.md b/api/bots/helloworld/readme.md similarity index 100% rename from contrib_bots/bots/helloworld/readme.md rename to api/bots/helloworld/readme.md diff --git a/contrib_bots/bots/helloworld/test_helloworld.py b/api/bots/helloworld/test_helloworld.py similarity index 91% rename from contrib_bots/bots/helloworld/test_helloworld.py rename to api/bots/helloworld/test_helloworld.py index c115ae0258..256b8b83d1 100644 --- a/contrib_bots/bots/helloworld/test_helloworld.py +++ b/api/bots/helloworld/test_helloworld.py @@ -8,6 +8,7 @@ import sys from six.moves import zip our_dir = os.path.dirname(os.path.abspath(__file__)) +sys.path.insert(0, os.path.normpath(os.path.join(our_dir))) # For dev setups, we can find the API in the repo itself. if os.path.exists(os.path.join(our_dir, '..')): sys.path.insert(0, '..') diff --git a/contrib_bots/bots/helloworld/__init__.py b/api/bots/help/__init__.py similarity index 100% rename from contrib_bots/bots/helloworld/__init__.py rename to api/bots/help/__init__.py diff --git a/contrib_bots/bots/help/help.py b/api/bots/help/help.py similarity index 100% rename from contrib_bots/bots/help/help.py rename to api/bots/help/help.py diff --git a/contrib_bots/bots/help/test_help.py b/api/bots/help/test_help.py similarity index 91% rename from contrib_bots/bots/help/test_help.py rename to api/bots/help/test_help.py index 8a2633c68c..c115722b6e 100644 --- a/contrib_bots/bots/help/test_help.py +++ b/api/bots/help/test_help.py @@ -8,6 +8,7 @@ import sys from six.moves import zip our_dir = os.path.dirname(os.path.abspath(__file__)) +sys.path.insert(0, os.path.normpath(os.path.join(our_dir))) # For dev setups, we can find the API in the repo itself. if os.path.exists(os.path.join(our_dir, '..')): sys.path.insert(0, '..') diff --git a/contrib_bots/bots/help/__init__.py b/api/bots/howdoi/__init__.py similarity index 100% rename from contrib_bots/bots/help/__init__.py rename to api/bots/howdoi/__init__.py diff --git a/contrib_bots/bots/howdoi/assets/answer_howdoi_all.png b/api/bots/howdoi/assets/answer_howdoi_all.png similarity index 100% rename from contrib_bots/bots/howdoi/assets/answer_howdoi_all.png rename to api/bots/howdoi/assets/answer_howdoi_all.png diff --git a/contrib_bots/bots/howdoi/assets/answer_howdowe.png b/api/bots/howdoi/assets/answer_howdowe.png similarity index 100% rename from contrib_bots/bots/howdoi/assets/answer_howdowe.png rename to api/bots/howdoi/assets/answer_howdowe.png diff --git a/contrib_bots/bots/howdoi/assets/question_howdoi_all.png b/api/bots/howdoi/assets/question_howdoi_all.png similarity index 100% rename from contrib_bots/bots/howdoi/assets/question_howdoi_all.png rename to api/bots/howdoi/assets/question_howdoi_all.png diff --git a/contrib_bots/bots/howdoi/assets/question_howdowe.png b/api/bots/howdoi/assets/question_howdowe.png similarity index 100% rename from contrib_bots/bots/howdoi/assets/question_howdowe.png rename to api/bots/howdoi/assets/question_howdowe.png diff --git a/contrib_bots/bots/howdoi/howdoi.py b/api/bots/howdoi/howdoi.py similarity index 100% rename from contrib_bots/bots/howdoi/howdoi.py rename to api/bots/howdoi/howdoi.py diff --git a/contrib_bots/bots/howdoi/readme.md b/api/bots/howdoi/readme.md similarity index 100% rename from contrib_bots/bots/howdoi/readme.md rename to api/bots/howdoi/readme.md diff --git a/contrib_bots/bots/howdoi/__init__.py b/api/bots/incrementor/__init__.py similarity index 100% rename from contrib_bots/bots/howdoi/__init__.py rename to api/bots/incrementor/__init__.py diff --git a/contrib_bots/bots/incrementor/incrementor.py b/api/bots/incrementor/incrementor.py similarity index 100% rename from contrib_bots/bots/incrementor/incrementor.py rename to api/bots/incrementor/incrementor.py diff --git a/contrib_bots/bots/incrementor/readme.md b/api/bots/incrementor/readme.md similarity index 100% rename from contrib_bots/bots/incrementor/readme.md rename to api/bots/incrementor/readme.md diff --git a/contrib_bots/bots/incrementor/__init__.py b/api/bots/john/__init__.py similarity index 100% rename from contrib_bots/bots/incrementor/__init__.py rename to api/bots/john/__init__.py diff --git a/contrib_bots/bots/john/assets/assist.png b/api/bots/john/assets/assist.png similarity index 100% rename from contrib_bots/bots/john/assets/assist.png rename to api/bots/john/assets/assist.png diff --git a/contrib_bots/bots/john/assets/greetings.png b/api/bots/john/assets/greetings.png similarity index 100% rename from contrib_bots/bots/john/assets/greetings.png rename to api/bots/john/assets/greetings.png diff --git a/contrib_bots/bots/john/assets/joke.png b/api/bots/john/assets/joke.png similarity index 100% rename from contrib_bots/bots/john/assets/joke.png rename to api/bots/john/assets/joke.png diff --git a/contrib_bots/bots/john/assets/var/jokes.json b/api/bots/john/assets/var/jokes.json similarity index 100% rename from contrib_bots/bots/john/assets/var/jokes.json rename to api/bots/john/assets/var/jokes.json diff --git a/contrib_bots/bots/john/john.py b/api/bots/john/john.py similarity index 89% rename from contrib_bots/bots/john/john.py rename to api/bots/john/john.py index 29e031928f..341b859cfe 100644 --- a/contrib_bots/bots/john/john.py +++ b/api/bots/john/john.py @@ -11,14 +11,14 @@ except ImportError: raise ImportError("""It looks like you are missing chatterbot. Please: pip install chatterbot""") -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)) +BOTS_DIR = os.path.dirname(os.path.abspath(__file__)) +os.chdir(os.path.dirname(BOTS_DIR)) +sys.path.insert(0, os.path.dirname(BOTS_DIR)) -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') +JOKES_PATH = os.path.join(BOTS_DIR, 'assets/var/jokes.json') +DATABASE_PATH = os.path.join(BOTS_DIR, 'assets/var/database.db') +DIRECTORY_PATH = os.path.join(BOTS_DIR, 'assets') +VAR_PATH = os.path.join(BOTS_DIR, 'assets/var') if not os.path.exists(DIRECTORY_PATH): os.makedirs(DIRECTORY_PATH) diff --git a/contrib_bots/bots/john/readme.md b/api/bots/john/readme.md similarity index 100% rename from contrib_bots/bots/john/readme.md rename to api/bots/john/readme.md diff --git a/contrib_bots/bots/readme.md b/api/bots/readme.md similarity index 98% rename from contrib_bots/bots/readme.md rename to api/bots/readme.md index 8a4ce63d10..85a37e81ba 100644 --- a/contrib_bots/bots/readme.md +++ b/api/bots/readme.md @@ -29,8 +29,8 @@ to messages in any of the following settings: 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 bots/followup/followup.py --config-file ~/.zuliprc-prod + cd ~/zulip/api + bots_api/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/bots/john/__init__.py b/api/bots/thesaurus/__init__.py similarity index 100% rename from contrib_bots/bots/john/__init__.py rename to api/bots/thesaurus/__init__.py diff --git a/contrib_bots/bots/thesaurus/test_thesaurus.py b/api/bots/thesaurus/test_thesaurus.py similarity index 97% rename from contrib_bots/bots/thesaurus/test_thesaurus.py rename to api/bots/thesaurus/test_thesaurus.py index ba41f41643..bb485a9632 100644 --- a/contrib_bots/bots/thesaurus/test_thesaurus.py +++ b/api/bots/thesaurus/test_thesaurus.py @@ -7,6 +7,7 @@ import os import sys our_dir = os.path.dirname(os.path.abspath(__file__)) +sys.path.insert(0, os.path.normpath(os.path.join(our_dir))) # For dev setups, we can find the API in the repo itself. if os.path.exists(os.path.join(our_dir, '..')): sys.path.insert(0, '..') diff --git a/contrib_bots/bots/thesaurus/thesaurus.py b/api/bots/thesaurus/thesaurus.py similarity index 97% rename from contrib_bots/bots/thesaurus/thesaurus.py rename to api/bots/thesaurus/thesaurus.py index 8960c47f01..db25e03ca4 100644 --- a/contrib_bots/bots/thesaurus/thesaurus.py +++ b/api/bots/thesaurus/thesaurus.py @@ -1,4 +1,4 @@ -# See zulip/contrib_bots/bots/readme.md for instructions on running this code. +# See zulip/api/bots/readme.md for instructions on running this code. from __future__ import print_function import sys import logging diff --git a/contrib_bots/bots/thesaurus/__init__.py b/api/bots/tictactoe/__init__.py similarity index 100% rename from contrib_bots/bots/thesaurus/__init__.py rename to api/bots/tictactoe/__init__.py diff --git a/contrib_bots/bots/tictactoe/readme.md b/api/bots/tictactoe/readme.md similarity index 100% rename from contrib_bots/bots/tictactoe/readme.md rename to api/bots/tictactoe/readme.md diff --git a/contrib_bots/bots/tictactoe/tictactoe.py b/api/bots/tictactoe/tictactoe.py similarity index 100% rename from contrib_bots/bots/tictactoe/tictactoe.py rename to api/bots/tictactoe/tictactoe.py diff --git a/contrib_bots/bots/tictactoe/__init__.py b/api/bots/virtual_fs/__init__.py similarity index 100% rename from contrib_bots/bots/tictactoe/__init__.py rename to api/bots/virtual_fs/__init__.py diff --git a/contrib_bots/bots/virtual_fs/readme.md b/api/bots/virtual_fs/readme.md similarity index 100% rename from contrib_bots/bots/virtual_fs/readme.md rename to api/bots/virtual_fs/readme.md diff --git a/contrib_bots/bots/virtual_fs/test_virtual_fs.py b/api/bots/virtual_fs/test_virtual_fs.py similarity index 98% rename from contrib_bots/bots/virtual_fs/test_virtual_fs.py rename to api/bots/virtual_fs/test_virtual_fs.py index 2252f179d2..f7b60eabd6 100644 --- a/contrib_bots/bots/virtual_fs/test_virtual_fs.py +++ b/api/bots/virtual_fs/test_virtual_fs.py @@ -7,6 +7,7 @@ import os import sys our_dir = os.path.dirname(os.path.abspath(__file__)) +sys.path.insert(0, os.path.normpath(os.path.join(our_dir))) # For dev setups, we can find the API in the repo itself. if os.path.exists(os.path.join(our_dir, '..')): sys.path.insert(0, '..') diff --git a/contrib_bots/bots/virtual_fs/virtual_fs.py b/api/bots/virtual_fs/virtual_fs.py similarity index 100% rename from contrib_bots/bots/virtual_fs/virtual_fs.py rename to api/bots/virtual_fs/virtual_fs.py diff --git a/contrib_bots/bots/weather/.weather_config b/api/bots/weather/.weather_config similarity index 100% rename from contrib_bots/bots/weather/.weather_config rename to api/bots/weather/.weather_config diff --git a/contrib_bots/bots/weather/assets/screen1.png b/api/bots/weather/assets/screen1.png similarity index 100% rename from contrib_bots/bots/weather/assets/screen1.png rename to api/bots/weather/assets/screen1.png diff --git a/contrib_bots/bots/weather/assets/screen2.png b/api/bots/weather/assets/screen2.png similarity index 100% rename from contrib_bots/bots/weather/assets/screen2.png rename to api/bots/weather/assets/screen2.png diff --git a/contrib_bots/bots/weather/readme.md b/api/bots/weather/readme.md similarity index 100% rename from contrib_bots/bots/weather/readme.md rename to api/bots/weather/readme.md diff --git a/contrib_bots/bots/weather/weather.py b/api/bots/weather/weather.py similarity index 100% rename from contrib_bots/bots/weather/weather.py rename to api/bots/weather/weather.py diff --git a/contrib_bots/bots/virtual_fs/__init__.py b/api/bots/wikipedia/__init__.py similarity index 100% rename from contrib_bots/bots/virtual_fs/__init__.py rename to api/bots/wikipedia/__init__.py diff --git a/contrib_bots/bots/wikipedia/test_wikipedia.py b/api/bots/wikipedia/test_wikipedia.py similarity index 94% rename from contrib_bots/bots/wikipedia/test_wikipedia.py rename to api/bots/wikipedia/test_wikipedia.py index 45dcbd5b26..5d9f50f911 100644 --- a/contrib_bots/bots/wikipedia/test_wikipedia.py +++ b/api/bots/wikipedia/test_wikipedia.py @@ -7,6 +7,7 @@ import os import sys our_dir = os.path.dirname(os.path.abspath(__file__)) +sys.path.insert(0, os.path.normpath(os.path.join(our_dir))) # For dev setups, we can find the API in the repo itself. if os.path.exists(os.path.join(our_dir, '..')): sys.path.insert(0, '..') diff --git a/contrib_bots/bots/wikipedia/wikipedia.py b/api/bots/wikipedia/wikipedia.py similarity index 100% rename from contrib_bots/bots/wikipedia/wikipedia.py rename to api/bots/wikipedia/wikipedia.py diff --git a/contrib_bots/bots/wikipedia/__init__.py b/api/bots/xkcd/__init__.py similarity index 100% rename from contrib_bots/bots/wikipedia/__init__.py rename to api/bots/xkcd/__init__.py diff --git a/contrib_bots/bots/xkcd/assets/xkcd-help.png b/api/bots/xkcd/assets/xkcd-help.png similarity index 100% rename from contrib_bots/bots/xkcd/assets/xkcd-help.png rename to api/bots/xkcd/assets/xkcd-help.png diff --git a/contrib_bots/bots/xkcd/assets/xkcd-latest.png b/api/bots/xkcd/assets/xkcd-latest.png similarity index 100% rename from contrib_bots/bots/xkcd/assets/xkcd-latest.png rename to api/bots/xkcd/assets/xkcd-latest.png diff --git a/contrib_bots/bots/xkcd/assets/xkcd-random.png b/api/bots/xkcd/assets/xkcd-random.png similarity index 100% rename from contrib_bots/bots/xkcd/assets/xkcd-random.png rename to api/bots/xkcd/assets/xkcd-random.png diff --git a/contrib_bots/bots/xkcd/assets/xkcd-specific-id.png b/api/bots/xkcd/assets/xkcd-specific-id.png similarity index 100% rename from contrib_bots/bots/xkcd/assets/xkcd-specific-id.png rename to api/bots/xkcd/assets/xkcd-specific-id.png diff --git a/contrib_bots/bots/xkcd/assets/xkcd-wrong-command.png b/api/bots/xkcd/assets/xkcd-wrong-command.png similarity index 100% rename from contrib_bots/bots/xkcd/assets/xkcd-wrong-command.png rename to api/bots/xkcd/assets/xkcd-wrong-command.png diff --git a/contrib_bots/bots/xkcd/assets/xkcd-wrong-id.png b/api/bots/xkcd/assets/xkcd-wrong-id.png similarity index 100% rename from contrib_bots/bots/xkcd/assets/xkcd-wrong-id.png rename to api/bots/xkcd/assets/xkcd-wrong-id.png diff --git a/contrib_bots/bots/xkcd/readme.md b/api/bots/xkcd/readme.md similarity index 100% rename from contrib_bots/bots/xkcd/readme.md rename to api/bots/xkcd/readme.md diff --git a/contrib_bots/bots/xkcd/test_xkcd.py b/api/bots/xkcd/test_xkcd.py similarity index 96% rename from contrib_bots/bots/xkcd/test_xkcd.py rename to api/bots/xkcd/test_xkcd.py index fa43894504..4d702b19ae 100644 --- a/contrib_bots/bots/xkcd/test_xkcd.py +++ b/api/bots/xkcd/test_xkcd.py @@ -8,6 +8,7 @@ import os import sys our_dir = os.path.dirname(os.path.abspath(__file__)) +sys.path.insert(0, os.path.normpath(os.path.join(our_dir))) # For dev setups, we can find the API in the repo itself. if os.path.exists(os.path.join(our_dir, '..')): sys.path.insert(0, '..') diff --git a/contrib_bots/bots/xkcd/xkcd.py b/api/bots/xkcd/xkcd.py similarity index 100% rename from contrib_bots/bots/xkcd/xkcd.py rename to api/bots/xkcd/xkcd.py diff --git a/contrib_bots/bots/xkcd/__init__.py b/api/bots/yoda/__init__.py similarity index 100% rename from contrib_bots/bots/xkcd/__init__.py rename to api/bots/yoda/__init__.py diff --git a/contrib_bots/bots/yoda/assets/yoda-speak-api.png b/api/bots/yoda/assets/yoda-speak-api.png similarity index 100% rename from contrib_bots/bots/yoda/assets/yoda-speak-api.png rename to api/bots/yoda/assets/yoda-speak-api.png diff --git a/contrib_bots/bots/yoda/readme.md b/api/bots/yoda/readme.md similarity index 96% rename from contrib_bots/bots/yoda/readme.md rename to api/bots/yoda/readme.md index bc9e16ef99..742b066d49 100644 --- a/contrib_bots/bots/yoda/readme.md +++ b/api/bots/yoda/readme.md @@ -44,8 +44,8 @@ If you need help while the bot is running just input `@mention-bot help`. Here is an example of running the "yoda" bot from inside a Zulip repo: - cd ~/zulip/contrib_bots - ./run.py bots/yoda/yoda.py --config-file ~/.zuliprc-prod + cd ~/zulip/api + bots_api/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/yoda.config b/api/bots/yoda/yoda.config similarity index 100% rename from contrib_bots/bots/yoda/yoda.config rename to api/bots/yoda/yoda.config diff --git a/contrib_bots/bots/yoda/yoda.py b/api/bots/yoda/yoda.py similarity index 100% rename from contrib_bots/bots/yoda/yoda.py rename to api/bots/yoda/yoda.py diff --git a/contrib_bots/bots/youtube/assets/screen.png b/api/bots/youtube/assets/screen.png similarity index 100% rename from contrib_bots/bots/youtube/assets/screen.png rename to api/bots/youtube/assets/screen.png diff --git a/contrib_bots/bots/youtube/readme.md b/api/bots/youtube/readme.md similarity index 100% rename from contrib_bots/bots/youtube/readme.md rename to api/bots/youtube/readme.md diff --git a/contrib_bots/bots/youtube/youtube.py b/api/bots/youtube/youtube.py similarity index 100% rename from contrib_bots/bots/youtube/youtube.py rename to api/bots/youtube/youtube.py diff --git a/contrib_bots/bots/yoda/__init__.py b/api/bots_api/__init__.py similarity index 100% rename from contrib_bots/bots/yoda/__init__.py rename to api/bots_api/__init__.py diff --git a/contrib_bots/bot_lib.py b/api/bots_api/bot_lib.py similarity index 98% rename from contrib_bots/bot_lib.py rename to api/bots_api/bot_lib.py index 3079608ad8..d9ad3847a7 100644 --- a/contrib_bots/bot_lib.py +++ b/api/bots_api/bot_lib.py @@ -15,8 +15,8 @@ from types import ModuleType our_dir = os.path.dirname(os.path.abspath(__file__)) # For dev setups, we can find the API in the repo itself. -if os.path.exists(os.path.join(our_dir, '../api/zulip')): - sys.path.insert(0, '../api') +if os.path.exists(os.path.join(our_dir, '../zulip')): + sys.path.insert(0, os.path.join(our_dir, '../')) from zulip import Client diff --git a/contrib_bots/bots_test_lib.py b/api/bots_api/bots_test_lib.py similarity index 92% rename from contrib_bots/bots_test_lib.py rename to api/bots_api/bots_test_lib.py index 04f82fc693..8555a6b59a 100644 --- a/contrib_bots/bots_test_lib.py +++ b/api/bots_api/bots_test_lib.py @@ -12,7 +12,7 @@ from mock import MagicMock, patch from run import get_lib_module from bot_lib import StateHandler -from contrib_bots import bot_lib +from bots_api import bot_lib from six.moves import zip from unittest import TestCase @@ -27,8 +27,7 @@ class BotTestCase(TestCase): def assert_bot_output(self, request, response): # type: (Dict[str, Any], str) -> None - bot_module = os.path.join(current_dir, "bots", - self.bot_name, self.bot_name + ".py") + bot_module = os.path.normpath(os.path.join(current_dir, "../bots", self.bot_name, self.bot_name + ".py")) self.bot_test(messages=[request], bot_module=bot_module, bot_response=[response]) @@ -52,7 +51,7 @@ class BotTestCase(TestCase): # function. # type: (List[Dict[str, Any]], Any, List[str]) -> None # Mocking BotHandlerApi - with patch('contrib_bots.bot_lib.BotHandlerApi') as MockClass: + with patch('bots_api.bot_lib.BotHandlerApi') as MockClass: instance = MockClass.return_value for (message, response) in zip(messages, bot_response): diff --git a/contrib_bots/run.py b/api/bots_api/run.py similarity index 92% rename from contrib_bots/run.py rename to api/bots_api/run.py index 3aea9422e4..73d8438d13 100755 --- a/contrib_bots/run.py +++ b/api/bots_api/run.py @@ -17,8 +17,8 @@ from bot_lib import run_message_handler_for_bot def get_lib_module(bots_fn): # type: (str) -> ModuleType bots_fn = os.path.realpath(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.') + if not os.path.dirname(bots_fn).startswith(os.path.normpath(os.path.join(our_dir, "../bots"))): + print('Sorry, we will only import code from api/bots.') sys.exit(1) if not bots_fn.endswith('.py'): diff --git a/contrib_bots/test-bots b/api/bots_api/test-bots similarity index 93% rename from contrib_bots/test-bots rename to api/bots_api/test-bots index c137bf162b..9d5d17c3f5 100755 --- a/contrib_bots/test-bots +++ b/api/bots_api/test-bots @@ -26,9 +26,10 @@ if __name__ == '__main__': bots_dir = os.path.dirname(os.path.abspath(__file__)) root_dir = dir_join(bots_dir, '..') - bots_test_dir = dir_join(bots_dir, 'bots') + bots_test_dir = dir_join(bots_dir, '../bots') sys.path.insert(0, root_dir) + sys.path.insert(0, bots_test_dir) # mypy doesn't recognize the TestLoader attribute, even though the code # is executable diff --git a/docs/bots-guide.md b/docs/bots-guide.md index cdbb8b15cb..e4350bc2fb 100644 --- a/docs/bots-guide.md +++ b/docs/bots-guide.md @@ -25,20 +25,14 @@ that help with writing bots, please visit [Zulip development community server](https://chat.zulip.org), open an issue, or submit a pull request to share your ideas! -# The contrib_bot system +# The bots system -Zulip's bot system resides in the `contrib_bots` directory. +Zulip's bot system resides in the `api` directory. - **Note: There exists an additional directory called `bots`. This directory does *not* contain normal bots, - but rather unpolished integrations.** - -The `contrib_bots` directory structure looks like the following: +The structure of the bots ecosystem in the `api` directory looks like the following: ``` -contrib_bots -│ bot_lib.py -│ run.py -│ +api └───bots └───bot1 └───bot2 @@ -52,6 +46,12 @@ contrib_bots └───assets | └───pic.png +├── bots_api +│   ├── bot_lib.py +│   ├── bots_test_lib.py +│   ├── run.py +│   ├── test_bots +├── integrations ``` Each subdirectory in `bots` contains a bot. When developing bots, try to use the structure outlined @@ -60,9 +60,9 @@ above as an orientation. ## How to run a bot This guide will show you how to run a bot on a running Zulip -server. It assumes you want to use one of the existing `contrib_bots` +server. It assumes you want to use one of the existing `api/bots` bots in your Zulip organization. If you want to write a new one, you -just need to write the `.py` script and put it into `/contrib_bots/bots/` directory. +just need to write the `.py` script and put it into `/api/bots/` directory. You need: @@ -73,7 +73,7 @@ You need: your bot. * A computer where you're running the bot from, with a clone of the [Zulip repository](https://github.com/zulip/zulip), which contains - the bot library code in its `contrib_bots/` subdirectory. This is + the bot library code in its `api/bots_api/` subdirectory. This is required to run your bot. The following instructions assume this repository to be located in `~/zulip/`. @@ -106,10 +106,10 @@ You need: 4. Run the bot. - * In your Zulip repository, navigate to `~/zulip/contrib_bots/` + * In your Zulip repository, navigate to `~/zulip/api/bots_api/` * Run ``` - python run.py bots//.py --config-file ~/.zuliprc` + python run.py ../bots//.py --config-file ~/.zuliprc` ``` (using the path to the `.zuliprc` file from step 2). * Check the output of the command. It should start with the text @@ -296,7 +296,7 @@ will edit the content of a previously sent message. ### Example -From `/zulip/contrib_bots/incrementor/incrementor.py`: +From `/zulip/api/bots/incrementor/incrementor.py`: ``` client.update_message(dict( @@ -330,7 +330,7 @@ client.update_message(dict( * My bot won't start * Ensure that your API config file is correct (download the config file from the server). - * Ensure that your bot script is located in zulip/contrib_bots/bots// + * Ensure that you bot script is located in zulip/api/bots// * Are you using your own Zulip development server? Ensure that you run your bot outside the Vagrant environment. * Some bots require Python 3. Try switching to a Python 3 environment before running diff --git a/docs/custom-apps.md b/docs/custom-apps.md index d06d950865..7731e79944 100644 --- a/docs/custom-apps.md +++ b/docs/custom-apps.md @@ -307,7 +307,7 @@ We want to make it easier to deploy **Zulip Readers** on Zulip hardware. The following document talks about how we want to enable this from a code structuring standpoint: -[Writing contrib bots](https://github.com/zulip/zulip/blob/master/contrib_bots/bots/readme.md) +[Writing contrib bots](https://github.com/zulip/zulip/blob/master/api/bots/readme.md) This document, on the other hand, is more about designing the Zulip backend system to support eventual deployment of reader apps on the Zulip server. diff --git a/tools/lint b/tools/lint index b2b0594968..e9b79408cb 100755 --- a/tools/lint +++ b/tools/lint @@ -586,7 +586,7 @@ def build_custom_checkers(by_lang): failed = True markdown_docs_length_exclude = { - "contrib_bots/bots/converter/readme.md", + "api/bots/converter/readme.md", "docs/bots-guide.md", "docs/dev-env-first-time-contributors.md", "docs/webhook-walkthrough.md", diff --git a/tools/run-mypy b/tools/run-mypy index 96d41ed509..18b0541053 100755 --- a/tools/run-mypy +++ b/tools/run-mypy @@ -27,10 +27,10 @@ zproject/settings.py zproject/test_settings.py """.split() -# We don't run mypy on contrib_bots, since the code there will +# We don't run mypy on api/bots since the code there will # often be shared with other projects that do not want a mypy # dependency (at least while it's still kind of beta). -exclude_common += ['contrib_bots/bots'] +exclude_common += ['api/bots'] exclude_py2 = [] # type: List[str] diff --git a/zerver/worker/queue_processors.py b/zerver/worker/queue_processors.py index d5c31a2774..1e16bef3ab 100644 --- a/zerver/worker/queue_processors.py +++ b/zerver/worker/queue_processors.py @@ -2,7 +2,11 @@ from __future__ import absolute_import from typing import Any, Callable, Dict, List, Mapping, Optional, cast -from contrib_bots.bot_lib import BotHandlerApi, StateHandler +import sys +import os +sys.path.insert(0, os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../api'))) + +from bots_api.bot_lib import BotHandlerApi, StateHandler from django.conf import settings from django.core.handlers.wsgi import WSGIRequest from django.core.handlers.base import BaseHandler @@ -462,7 +466,7 @@ class EmbeddedBotWorker(QueueProcessingWorker): def get_bot_handler(self, service): # type: (Service) -> Any - bot_module_name = 'contrib_bots.bots.%s.%s' % (service.name, service.name) + bot_module_name = 'bots_api.bots.%s.%s' % (service.name, service.name) bot_module = importlib.import_module(bot_module_name) # type: Any return bot_module.handler_class()