forked from DonDebonair/slack-machine
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add documentation, fix linting errors, make ready for first PyPI release
- Loading branch information
1 parent
89c0e37
commit 7b21341
Showing
23 changed files
with
241 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2017 Daan Debie | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
include README.rst LICENSE requirements.txt | ||
include extra/logo.png | ||
include run_dev.py | ||
exclude local_settings.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
Slack Machine | ||
============= | ||
|
||
Slack Machine is a sexy, simple, yet powerful and extendable Slack bot. More than just a bot, | ||
Slack Machine is a framework that helps you develop your Slack team into a ChatOps powerhouse. | ||
|
||
.. image:: extra/logo.png | ||
|
||
Features | ||
-------- | ||
|
||
- Get started with mininal configuration | ||
- Built on top of the `Slack RTM API`_ for smooth, real-time interactions | ||
- Support for rich interactions using the `Slack Web API`_ | ||
- High-level API for maximum convenience when building plugins | ||
- Low-level API for maximum flexibility | ||
- Plugin API features: | ||
- Listen and respond to any regular expression | ||
- Capture parts of messages to use as variables in your functions | ||
- Respond to messages in channels, groups and direct message conversations | ||
- Respond with Emoji | ||
- Respond in threads | ||
- Send DMs to any user | ||
- Support for `message attachments`_ | ||
- Listen and respond to any `Slack event`_ supported by the RTM API | ||
|
||
.. _Slack RTM API: https://api.slack.com/rtm | ||
.. _Slack Web API: https://api.slack.com/web | ||
.. _message attachments: https://api.slack.com/docs/message-attachments | ||
.. _Slack event: https://api.slack.com/events | ||
|
||
Coming Soon | ||
""""""""""" | ||
|
||
- Schedule actions and messages | ||
- Plugin-accesible storage | ||
- Help texts for Plugins | ||
- ... and much more | ||
|
||
Installation | ||
------------ | ||
|
||
You can install Slack Machine using pip: | ||
|
||
.. code-block:: bash | ||
$ pip install slack-machine | ||
It is **strongly recommended** that you install ``slack-machine`` inside a `virtual environment`_! | ||
|
||
.. _virtual environment: http://docs.python-guide.org/en/latest/dev/virtualenvs/ | ||
|
||
Usage | ||
----- | ||
|
||
#. Create a directory for your Slack bot: ``mkdir my-slack-bot && cd my-slack-bot`` | ||
#. Add a ``local_settings.py`` file to your bot directory: ``touch local_settings.py`` | ||
#. Create a Bot User for your Slack team: https://my.slack.com/services/new/bot (take note of your API token) | ||
#. Add the Slack API token to your ``local_settings.py`` like this: | ||
|
||
.. code-block:: python | ||
SLACK_API_TOKEN = 'xox-my-slack-token' | ||
#. Start the bot with ``slack-machine`` | ||
#. ... | ||
#. Profit! | ||
|
||
Writing plugins | ||
--------------- | ||
|
||
*Coming Soon!* |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
__all__ = [ | ||
'__title__', '__description__', '__uri__', '__version__', '__author__', | ||
'__email__', '__license__', '__copyright__' | ||
] | ||
|
||
__title__ = "slack-machine" | ||
__description__ = "A sexy, simple, yet powerful and extendable Slack bot" | ||
__uri__ = "https://github.com/DandyDev/slack-machine" | ||
|
||
__version__ = "0.1" | ||
|
||
__author__ = "Daan Debie" | ||
__email__ = "[email protected]" | ||
|
||
__license__ = "MIT" | ||
__copyright__ = "Copyright 2017 {}".format(__author__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
from .core import * | ||
from .core import Machine | ||
from .__about__ import (__title__, __description__, __uri__, __version__, __author__, | ||
__email__, __license__, __copyright__) | ||
|
||
__all__ = [ | ||
'__title__', '__description__', '__uri__', '__version__', '__author__', '__email__', | ||
'__license__', '__copyright__', 'Machine' | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import sys | ||
import os | ||
|
||
from machine import Machine | ||
|
||
|
||
def main(): | ||
# When running this function as console entry point, the current working dir is not in the | ||
# Python path, so we have to add it | ||
sys.path.insert(0, os.getcwd()) | ||
bot = Machine() | ||
try: | ||
bot.run() | ||
except (KeyboardInterrupt, SystemExit): | ||
print("Thanks for playing!") | ||
sys.exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,47 @@ | ||
from functools import wraps | ||
import re | ||
|
||
|
||
def process(event_type): | ||
def process_decorator(f): | ||
@wraps(f) | ||
def wrapped_f(*args, **kwargs): | ||
return f(*args, **kwargs) | ||
|
||
wrapped_f.metadata = getattr(f, "metadata", {}) | ||
wrapped_f.metadata['plugin_actions'] = wrapped_f.metadata.get('plugin_actions', {}) | ||
wrapped_f.metadata['plugin_actions']['process'] = {} | ||
wrapped_f.metadata['plugin_actions']['process']['event_type'] = event_type | ||
return wrapped_f | ||
|
||
return process_decorator | ||
|
||
|
||
def listen_to(regex, flags=re.IGNORECASE): | ||
def listen_to_decorator(f): | ||
@wraps(f) | ||
def wrapped_f(*args, **kwargs): | ||
return f(*args, **kwargs) | ||
|
||
wrapped_f.metadata = getattr(f, "metadata", {}) | ||
wrapped_f.metadata['plugin_actions'] = wrapped_f.metadata.get('plugin_actions', {}) | ||
wrapped_f.metadata['plugin_actions']['listen_to'] = {} | ||
wrapped_f.metadata['plugin_actions']['listen_to']['regex'] = re.compile(regex, flags) | ||
return wrapped_f | ||
|
||
return listen_to_decorator | ||
|
||
|
||
def respond_to(regex, flags=re.IGNORECASE): | ||
def respond_to_decorator(f): | ||
@wraps(f) | ||
def wrapped_f(*args, **kwargs): | ||
return f(*args, **kwargs) | ||
|
||
wrapped_f.metadata = getattr(f, "metadata", {}) | ||
wrapped_f.metadata['plugin_actions'] = wrapped_f.metadata.get('plugin_actions', {}) | ||
wrapped_f.metadata['plugin_actions']['respond_to'] = {} | ||
wrapped_f.metadata['plugin_actions']['respond_to']['regex'] = re.compile(regex, flags) | ||
return wrapped_f | ||
|
||
return respond_to_decorator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.