https://github.com/heavenshell/py-robo
Dead simple bot framework
https://github.com/heavenshell/py-robo
Last synced: 10 months ago
JSON representation
Dead simple bot framework
- Host: GitHub
- URL: https://github.com/heavenshell/py-robo
- Owner: heavenshell
- License: bsd-3-clause
- Created: 2015-01-04T14:49:38.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2018-05-26T16:23:44.000Z (about 8 years ago)
- Last Synced: 2025-08-23T22:19:18.791Z (10 months ago)
- Language: Python
- Homepage:
- Size: 45.9 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGES.rst
- License: LICENSE
Awesome Lists containing this project
README
robo
====
.. image:: https://travis-ci.org/heavenshell/py-robo.png?branch=master
Dead simple bot framework which is inspired by Ruby's `ruboty `_.
Why reinvent the wheel
----------------------
I Love Python and I'm not good at Node.js(hubot), Ruby(Ruboty).
`Err `_ is pluggable but it's too complex for me.
`brutal `_ is also pluggable but I don't wont to write config file.
So I reinvent the wheel.
Architecture
------------
Message flow.
.. code:: text
+--[handler a]--+
| |
[chat service]-->[adapter]--+--[handler b]--+--[adapter]-->[chat service]
| |
+--[handler c]--+
Adapter
-------
Adapter is interface of chat services receive message and send message to chat service.
Robo includes two adapters.
- `shell `_
- `Slack `_
Handler
-------
Handler provides various behaviors to your robot.
.. code:: python
from robo.decorators import cmd
class Ping(object):
@cmd(regex=r'^ping', description='')
def pong(self, message, **kwargs):
return 'pong'
This handler matches message `ping` and return `pong` to chat service.
Bootstrap
---------
`example/main.py `_ is a example of bootstraping `robo`.
.. code:: python
def main(args=None):
#: `name` is bot's name.
#: This arg is trigger of handler.
robot = Robot(name=args.name, logger=logger)
#: `register_default_handlers()` register default handlers.
#: Default handlers are `help`, `ping`, `echo`.
robot.register_default_handlers()
#: Load given adapter name.
robot.load_adapter(args.adapter)
#: Run robot
robot.run(args.adapter)