Fast, simple and lightweight micro bot framework for Python. It is distributed as a single package and has very few dependencies other than the Python Standard Library. Shellbot supports Python 3 and Python 2.7. Test coverage exceeds 90%.
- Channels: a single bot can access jointly group and direct channels
- Commands: routing from chat box to function calls made easy, including support of file uploads
- State machines: powerful and pythonic way to bring intelligence to your bot
- Stores: each bot has a dedicated data store
- Utilities: convenient configuration-driven approach, chat audit, and more
- Platforms: Cisco Spark, local disconnected mode for tests -- looking for more
importosimporttimefromshellbotimportEngine, Context, CommandContext.set_logger()
classBatman(Command): # a command that displays static textkeyword='whoareyou'information_message=u"I'm Batman!"classBatcave(Command): # a command that reflects input from the end userkeyword='cave'information_message=u"The Batcave is silent..."defexecute(self, bot, arguments=None, **kwargs):
ifarguments:
bot.say(u"The Batcave echoes, '{0}'".format(arguments))
else:
bot.say(self.information_message)
classBatsignal(Command): # a command that uploads a file/linkkeyword='signal'information_message=u"NANA NANA NANA NANA"information_file="https://upload.wikimedia.org/wikipedia/en/c/c6/Bat-signal_1989_film.jpg"defexecute(self, bot, arguments=None, **kwargs):
bot.say(self.information_message,
file=self.information_file)
classBatsuicide(Command): # a command only for group channelskeyword='suicide'information_message=u"Go back to Hell"in_direct=Falsedefexecute(self, bot, arguments=None, **kwargs):
bot.say(self.information_message)
bot.dispose()
engine=Engine( # use Cisco Spark and load shell commandstype='spark',
commands=[Batman(), Batcave(), Batsignal(), Batsuicide()])
os.environ['BOT_ON_ENTER'] ='You can now chat with Batman'os.environ['BOT_ON_EXIT'] ='Batman is now quitting the room, bye'os.environ['CHAT_ROOM_TITLE'] ='Chat with Batman'engine.configure() # ensure that all components are readyengine.bond(reset=True) # create a group channel for this exampleengine.run() # until Ctl-Cengine.dispose() # delete the initial group channelTo install the shellbot package, type:
$ pip install shellbot
Or, if you prefer to download the full project including examples and documentation, and install it, do the following:
$ git clone https://github.com/bernard357/shellbot.git $ cd shellbot $ pip install -e .
- Documentation: Shellbot at ReadTheDocs
- Python package: Shellbot at PyPi
- Source code: Shellbot at GitHub
- Free software: Apache License (2.0)
- securitybot from the Dropbox team
- Bottle
- ciscosparkapi
- PyYAML
- Cookiecutter
- cookiecutter-pypackage