Skip to main content

A bot that is also a responsive shell

Project description

https://readthedocs.org/projects/shellbot-for-cisco-spark/badge/?version=latest https://img.shields.io/pypi/v/shellbot.svg https://img.shields.io/travis/bernard357/shellbot.svg https://img.shields.io/badge/coverage-93%25-green.svg https://img.shields.io/pypi/pyversions/shellbot.svg?maxAge=2592000 https://img.shields.io/badge/License-Apache%202.0-blue.svg

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

  • Audit dynamically chat interactions

  • 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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shellbot-17.5.27.tar.gz (138.5 kB view details)

Uploaded Source

Built Distribution

shellbot-17.5.27-py2.py3-none-any.whl (85.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file shellbot-17.5.27.tar.gz.

File metadata

  • Download URL: shellbot-17.5.27.tar.gz
  • Upload date:
  • Size: 138.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for shellbot-17.5.27.tar.gz
Algorithm Hash digest
SHA256 3590f0e034e5a27250f86559602fc51d3d25712d43d650107afb161c6d0b24f8
MD5 e9ef56bba3f5528f927578d412dec50b
BLAKE2b-256 42e4141735b7e70d2df37fec8a6c2d3d1ead99e22ba430b4d0d6a9281fe32ae9

See more details on using hashes here.

File details

Details for the file shellbot-17.5.27-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for shellbot-17.5.27-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 abd5ec1093a7385d2b98577aa884efc4bfdf031d78a5d095bdda6e4eedfc6c51
MD5 4db565de6f164b2288ee58247c19a783
BLAKE2b-256 196e6bbd979b02bc61a91265c9f790ba0beea9ea3dcc8d7ea722cdea8365637f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page