A bot that is also a responsive shell
Project description
Fast, simple and lightweight micro bot-framework for Python.
Features
Comprehensive set of examples is included
Create powerful state machines for mastering bot-human interactions
Create the exact set of shell commands needed for your application
Either respond interactively, or pipeline long-lasting commands
Native support of Cisco Spark
Local disconnected mode of operation for development and tests
Bottle is included for easy interactions over the web
Test coverage exceeds 90%
Made for python 2.7 and for python 3.x
Documentation: Shellbot at ReadTheDocs
Python package: Shellbot at PyPi
Source code: Shellbot at GitHub
Free software: Apache License (2.0)
The Batman example
from shellbot import ShellBot, Context, Command
# create a bot and load commands
#
class Batman(Command):
keyword = 'whoareyou'
information_message = u"I'm Batman!"
class Batcave(Command):
keyword = 'cave'
information_message = u"The Batcave is silent..."
def execute(self, arguments=None):
if arguments:
self.bot.say(u"The Batcave echoes, '{0}'".format(arguments))
else:
self.bot.say(self.information_message)
class Batsignal(Command):
keyword = 'signal'
information_message = u"NANA NANA NANA NANA"
information_file = "https://upload.wikimedia.org/wikipedia/en/c/c6/Bat-signal_1989_film.jpg"
def execute(self, arguments=None):
self.bot.say(self.information_message,
file=self.information_file)
class Batsuicide(Command):
keyword = 'suicide'
information_message = u"Go back to Hell"
is_interactive = False
def execute(self, arguments=None):
time.sleep(3)
self.bot.say(self.information_message)
self.bot.stop()
bot = ShellBot(commands=[Batman(), Batcave(), Batsignal(), Batsuicide()])
# load configuration
#
os.environ['BOT_ON_START'] = 'You can now chat with Batman'
os.environ['BOT_ON_STOP'] = 'Batman is now quitting the room, bye'
os.environ['CHAT_ROOM_TITLE'] = 'Chat with Batman'
bot.configure()
# initialise a chat room
#
bot.bond(reset=True)
# run the bot
#
bot.run()
# delete the chat room when the bot is stopped
#
bot.dispose()
Quick installation
To 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 .
Credits
securitybot from the Dropbox team
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for shellbot-17.5.16-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4998b16944d581b96c34ed35db40f64b4a44eeccece03c2250c87a4e6bff7ea |
|
MD5 | 2216a2ec684cf51090d8b383f95fb58a |
|
BLAKE2b-256 | 8eb5c9cd21ccc5b05cf3264ba010aa9bdfbc80db89ab7407698a25e27be4a20a |