Skip to content
This repository was archived by the owner on Aug 15, 2022. It is now read-only.

Commit 8251988

Browse files
author
Jeff Ammons
committed
Cleanup from code review.
1 parent 81f0819 commit 8251988

File tree

5 files changed

+22
-16
lines changed

5 files changed

+22
-16
lines changed

MANIFEST.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
include LICENSE
22
include CHANGELOG.md
3-
include README.md
3+
include README.md
4+

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ python-rtmbot
66

77
A Slack bot written in Python that connects via the RTM API.
88

9-
Python-rtmbot is a bot engine. The plugins architecture should be familiar to anyone with knowledge to the [Slack API](https://api.slack.com) and Python. The configuration file format is YAML.
9+
Python-rtmbot is a bot engine. The plugins architecture should be familiar to anyone with knowledge of the [Slack API](https://api.slack.com) and Python. The configuration file format is YAML.
1010

1111
Some differences to webhooks:
1212

@@ -28,21 +28,21 @@ Installation
2828
mkdir myproject
2929
cd myproject
3030

31-
2. Install rtmbot (ideally into a virtualenv https://virtualenv.readthedocs.io/en/latest/)
31+
2. Install rtmbot (ideally into a [virtualenv](https://virtualenv.readthedocs.io/en/latest/))
3232

3333
pip install rtmbot
3434

35-
3. Create and rtmbot.conf file and configure rtmbot (https://api.slack.com/bot-users)
35+
3. Create an rtmbot.conf file and [create a bot for your team](https://api.slack.com/bot-users)
3636

3737
# Add the following to rtmbot.conf
3838
DEBUG: True # make this False in production
3939
SLACK_TOKEN: "xoxb-11111111111-222222222222222"
4040
ACTIVE_PLUGINS:
4141
- plugins.repeat.RepeatPlugin
4242

43-
```DEBUG``` will adjust logging verbosity and cause the runner to exit on exceptions, generally making dubugging more pleasant.
43+
```DEBUG``` will adjust logging verbosity and cause the runner to exit on exceptions, generally making debugging more pleasant.
4444

45-
```SLACK_TOKEN``` is needed to authenticate with your Slack team. More info at https://api.slack.com/web#authentication
45+
```SLACK_TOKEN``` is needed to [authenticate with your Slack team.](https://api.slack.com/web#authentication)
4646

4747
```ACTIVE_PLUGINS``` RTMBot will attempt to import any Plugin specified in `ACTIVE_PLUGINS` (relative to your python path) and instantiate them as plugins. These specified classes should inherit from the core Plugin class.
4848

@@ -63,7 +63,7 @@ RtmBot
6363

6464
Add Plugins
6565
-------
66-
Plugins can live within any python module, but we recommend just putting them in ./plugins. (Don't forget to add an __init__.py file to your directory to make it a module -- use `touch __init__.py` within your plugin directory to create one)
66+
Plugins can live within any python module, but we recommend just putting them in ./plugins. (Don't forget to add an `__init__.py` file to your directory to make it a module -- use `touch __init__.py` within your plugin directory to create one)
6767

6868
To add a plugin, create a file within your plugin directory (./plugins is a good place for it).
6969

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
requests
2-
python-daemon
32
pyyaml
43
websocket-client
54
slackclient

rtmbot/core.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ def __init__(self, config):
3030

3131
# set slack token
3232
self.token = config.get('SLACK_TOKEN', None)
33-
# TODO: Raise an exception if no SLACK_TOKEN is specified
33+
if not self.token:
34+
raise ValueError("Please add a SLACK_TOKEN to your config file.")
3435

3536
# get list of directories to search for loading plugins
3637
self.active_plugins = config.get('ACTIVE_PLUGINS', [])
@@ -71,8 +72,12 @@ def _start(self):
7172
try:
7273
self._dbg("Registering jobs for {}".format(plugin.name))
7374
plugin.register_jobs()
74-
except:
75+
except NotImplementedError: # this plugin doesn't register jobs
7576
self._dbg("No jobs registered for {}".format(plugin.name))
77+
except Exception as error:
78+
self._dbg("Error registering jobs for {} - {}".format(
79+
plugin.name, error)
80+
)
7681
while True:
7782
for reply in self.slack_client.rtm_read():
7883
self.input(reply)
@@ -138,8 +143,10 @@ def load_plugins(self):
138143
# otherwise we log the exception and carry on
139144
try:
140145
cls = import_string(plugin_path)
141-
except ImportError:
142-
logging.exception("Problem importing {}".format(plugin_path))
146+
except ImportError as error:
147+
logging.exception("Problem importing {} - {}".format(
148+
plugin_path, error)
149+
)
143150

144151
plugin_config = self.config.get(cls.__name__, {})
145152
plugin = cls(slack_client=self.slack_client, plugin_config=plugin_config) # instatiate!

setup.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33

44
setup(
55
name='rtmbot',
6-
version='0.2.11',
6+
version='0.3.0',
77
description='A Slack bot written in python that connects via the RTM API.',
88
author='Ryan Huber and Jeff Ammons',
99
author_email='[email protected]',
1010
url='https://github.com/slackhq/python-rtmbot',
1111
packages=find_packages(),
1212
entry_points={'console_scripts': ['rtmbot=rtmbot.bin.run_rtmbot:main']},
1313
install_requires=[
14-
'python-daemon',
15-
'pyyaml',
16-
'slackclient'
14+
'pyyaml>=3, <4',
15+
'slackclient>=1, <2'
1716
]
1817
)

0 commit comments

Comments
 (0)