bots: Move contrib_bots to api/bots*.
This will make it convenient to include these bots in Zulip API releases on pypi. Fix #5009.
|
@ -80,7 +80,7 @@ class CommuteHandler(object):
|
||||||
# adds API Authentication Key to url request
|
# adds API Authentication Key to url request
|
||||||
def get_api_key(self):
|
def get_api_key(self):
|
||||||
# commute.config must be moved from
|
# 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
|
# ~/commute.config for program to work
|
||||||
# see readme.md for more information
|
# see readme.md for more information
|
||||||
with open(CONFIG_PATH) as settings:
|
with open(CONFIG_PATH) as settings:
|
|
@ -17,7 +17,7 @@ the user home directory and add an API key.
|
||||||
Move
|
Move
|
||||||
|
|
||||||
```
|
```
|
||||||
~/zulip/contrib_bots/bots/commute/commute.config
|
~/zulip/api/bots/commute/commute.config
|
||||||
```
|
```
|
||||||
|
|
||||||
into
|
into
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 54 KiB |
|
@ -7,6 +7,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
our_dir = os.path.dirname(os.path.abspath(__file__))
|
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.
|
# For dev setups, we can find the API in the repo itself.
|
||||||
if os.path.exists(os.path.join(our_dir, '..')):
|
if os.path.exists(os.path.join(our_dir, '..')):
|
||||||
sys.path.insert(0, '..')
|
sys.path.insert(0, '..')
|
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
|
@ -7,6 +7,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
our_dir = os.path.dirname(os.path.abspath(__file__))
|
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.
|
# For dev setups, we can find the API in the repo itself.
|
||||||
if os.path.exists(os.path.join(our_dir, '..')):
|
if os.path.exists(os.path.join(our_dir, '..')):
|
||||||
sys.path.insert(0, '..')
|
sys.path.insert(0, '..')
|
Before Width: | Height: | Size: 287 KiB After Width: | Height: | Size: 287 KiB |
Before Width: | Height: | Size: 180 KiB After Width: | Height: | Size: 180 KiB |
Before Width: | Height: | Size: 160 KiB After Width: | Height: | Size: 160 KiB |
Before Width: | Height: | Size: 170 KiB After Width: | Height: | Size: 170 KiB |
|
@ -7,6 +7,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
our_dir = os.path.dirname(os.path.abspath(__file__))
|
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.
|
# For dev setups, we can find the API in the repo itself.
|
||||||
if os.path.exists(os.path.join(our_dir, '..')):
|
if os.path.exists(os.path.join(our_dir, '..')):
|
||||||
sys.path.insert(0, '..')
|
sys.path.insert(0, '..')
|
|
@ -9,11 +9,11 @@ from six.moves import configparser as cp
|
||||||
from six.moves import range
|
from six.moves import range
|
||||||
|
|
||||||
home = expanduser('~')
|
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():
|
def get_api_key():
|
||||||
# foursquare.config must have been moved from
|
# 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
|
# ~/foursquare.config for program to work
|
||||||
# see readme.md for more information
|
# see readme.md for more information
|
||||||
with open(CONFIG_PATH) as settings:
|
with open(CONFIG_PATH) as settings:
|
|
@ -26,8 +26,8 @@ github_token = <oauth_token> (The personal access token for the GitHub bot)
|
||||||
Here is an example of running the `git_hub_comment` bot from
|
Here is an example of running the `git_hub_comment` bot from
|
||||||
inside a Zulip repo:
|
inside a Zulip repo:
|
||||||
|
|
||||||
`cd ~/zulip/contrib_bots`
|
`cd ~/zulip/api`
|
||||||
`./run.py bots/git_hub_comment/git_hub_comment.py --config-file ~/.zuliprc-prod`
|
`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
|
Once the bot code starts running, you will see a
|
||||||
message explaining how to use the bot, as well as
|
message explaining how to use the bot, as well as
|
|
@ -8,6 +8,7 @@ import sys
|
||||||
from six.moves import zip
|
from six.moves import zip
|
||||||
|
|
||||||
our_dir = os.path.dirname(os.path.abspath(__file__))
|
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.
|
# For dev setups, we can find the API in the repo itself.
|
||||||
if os.path.exists(os.path.join(our_dir, '..')):
|
if os.path.exists(os.path.join(our_dir, '..')):
|
||||||
sys.path.insert(0, '..')
|
sys.path.insert(0, '..')
|
|
@ -8,6 +8,7 @@ import sys
|
||||||
from six.moves import zip
|
from six.moves import zip
|
||||||
|
|
||||||
our_dir = os.path.dirname(os.path.abspath(__file__))
|
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.
|
# For dev setups, we can find the API in the repo itself.
|
||||||
if os.path.exists(os.path.join(our_dir, '..')):
|
if os.path.exists(os.path.join(our_dir, '..')):
|
||||||
sys.path.insert(0, '..')
|
sys.path.insert(0, '..')
|
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 9 KiB After Width: | Height: | Size: 9 KiB |
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 83 KiB |
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 64 KiB |
|
@ -11,14 +11,14 @@ except ImportError:
|
||||||
raise ImportError("""It looks like you are missing chatterbot.
|
raise ImportError("""It looks like you are missing chatterbot.
|
||||||
Please: pip install chatterbot""")
|
Please: pip install chatterbot""")
|
||||||
|
|
||||||
CONTRIB_BOTS_DIR = os.path.dirname(os.path.abspath(__file__))
|
BOTS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
os.chdir(os.path.dirname(CONTRIB_BOTS_DIR))
|
os.chdir(os.path.dirname(BOTS_DIR))
|
||||||
sys.path.insert(0, os.path.dirname(CONTRIB_BOTS_DIR))
|
sys.path.insert(0, os.path.dirname(BOTS_DIR))
|
||||||
|
|
||||||
JOKES_PATH = os.path.join(CONTRIB_BOTS_DIR, 'assets/var/jokes.json')
|
JOKES_PATH = os.path.join(BOTS_DIR, 'assets/var/jokes.json')
|
||||||
DATABASE_PATH = os.path.join(CONTRIB_BOTS_DIR, 'assets/var/database.db')
|
DATABASE_PATH = os.path.join(BOTS_DIR, 'assets/var/database.db')
|
||||||
DIRECTORY_PATH = os.path.join(CONTRIB_BOTS_DIR, 'assets')
|
DIRECTORY_PATH = os.path.join(BOTS_DIR, 'assets')
|
||||||
VAR_PATH = os.path.join(CONTRIB_BOTS_DIR, 'assets/var')
|
VAR_PATH = os.path.join(BOTS_DIR, 'assets/var')
|
||||||
|
|
||||||
if not os.path.exists(DIRECTORY_PATH):
|
if not os.path.exists(DIRECTORY_PATH):
|
||||||
os.makedirs(DIRECTORY_PATH)
|
os.makedirs(DIRECTORY_PATH)
|
|
@ -29,8 +29,8 @@ to messages in any of the following settings:
|
||||||
Here is an example of running the "follow-up" bot from
|
Here is an example of running the "follow-up" bot from
|
||||||
inside a Zulip repo (and in your remote instance):
|
inside a Zulip repo (and in your remote instance):
|
||||||
|
|
||||||
cd ~/zulip/contrib_bots
|
cd ~/zulip/api
|
||||||
./run.py bots/followup/followup.py --config-file ~/.zuliprc-prod
|
bots_api/run.py bots/followup/followup.py --config-file ~/.zuliprc-prod
|
||||||
|
|
||||||
Once the bot code starts running, you will see a
|
Once the bot code starts running, you will see a
|
||||||
message explaining how to use the bot, as well as
|
message explaining how to use the bot, as well as
|
|
@ -7,6 +7,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
our_dir = os.path.dirname(os.path.abspath(__file__))
|
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.
|
# For dev setups, we can find the API in the repo itself.
|
||||||
if os.path.exists(os.path.join(our_dir, '..')):
|
if os.path.exists(os.path.join(our_dir, '..')):
|
||||||
sys.path.insert(0, '..')
|
sys.path.insert(0, '..')
|
|
@ -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
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
|
@ -7,6 +7,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
our_dir = os.path.dirname(os.path.abspath(__file__))
|
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.
|
# For dev setups, we can find the API in the repo itself.
|
||||||
if os.path.exists(os.path.join(our_dir, '..')):
|
if os.path.exists(os.path.join(our_dir, '..')):
|
||||||
sys.path.insert(0, '..')
|
sys.path.insert(0, '..')
|
Before Width: | Height: | Size: 67 KiB After Width: | Height: | Size: 67 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
@ -7,6 +7,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
our_dir = os.path.dirname(os.path.abspath(__file__))
|
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.
|
# For dev setups, we can find the API in the repo itself.
|
||||||
if os.path.exists(os.path.join(our_dir, '..')):
|
if os.path.exists(os.path.join(our_dir, '..')):
|
||||||
sys.path.insert(0, '..')
|
sys.path.insert(0, '..')
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
@ -8,6 +8,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
our_dir = os.path.dirname(os.path.abspath(__file__))
|
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.
|
# For dev setups, we can find the API in the repo itself.
|
||||||
if os.path.exists(os.path.join(our_dir, '..')):
|
if os.path.exists(os.path.join(our_dir, '..')):
|
||||||
sys.path.insert(0, '..')
|
sys.path.insert(0, '..')
|
Before Width: | Height: | Size: 229 KiB After Width: | Height: | Size: 229 KiB |
|
@ -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
|
Here is an example of running the "yoda" bot from
|
||||||
inside a Zulip repo:
|
inside a Zulip repo:
|
||||||
|
|
||||||
cd ~/zulip/contrib_bots
|
cd ~/zulip/api
|
||||||
./run.py bots/yoda/yoda.py --config-file ~/.zuliprc-prod
|
bots_api/run.py bots/yoda/yoda.py --config-file ~/.zuliprc-prod
|
||||||
|
|
||||||
Once the bot code starts running, you will see a
|
Once the bot code starts running, you will see a
|
||||||
message explaining how to use the bot, as well as
|
message explaining how to use the bot, as well as
|