跳转到主要内容

既是机器人又是响应式外壳的软件

项目描述

https://readthedocs.org/projects/shellbot-framework/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

Python的快速、简单、轻量级微机器人框架。它作为一个单独的包分发,除了Python标准库之外几乎没有依赖项。Shellbot支持Python 3和Python 2.7。测试覆盖率超过90%。

  • 通道:单个机器人可以共同访问群组和直接通道

  • 命令:从聊天框到功能调用的路由变得简单,包括支持文件上传

  • 状态机:以Pythonic的方式为您的机器人带来智能

  • 存储:每个机器人都有一个专用的数据存储

  • 实用工具:方便的配置驱动方法、聊天审计等

  • 平台:思科Spark、测试的本地断开连接模式 - 正在寻找更多

蝙蝠侠示例

import os
import time

from shellbot import Engine, Context, Command
Context.set_logger()


class Batman(Command):  # a command that displays static text
    keyword = 'whoareyou'
    information_message = u"I'm Batman!"


class Batcave(Command):  # a command that reflects input from the end user
    keyword = 'cave'
    information_message = u"The Batcave is silent..."

    def execute(self, bot, arguments=None, **kwargs):
        if arguments:
            bot.say(u"The Batcave echoes, '{0}'".format(arguments))
        else:
            bot.say(self.information_message)


class Batsignal(Command):  # a command that uploads a file/link
    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, bot, arguments=None, **kwargs):
        bot.say(self.information_message,
                file=self.information_file)


class Batsuicide(Command):  # a command only for group channels
    keyword = 'suicide'
    information_message = u"Go back to Hell"
    in_direct = False

    def execute(self, bot, arguments=None, **kwargs):
        bot.say(self.information_message)
        bot.dispose()


engine = Engine(  # use Cisco Spark and load shell commands
    type='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 ready

engine.bond(reset=True)  # create a group channel for this example
engine.run()  # until Ctl-C
engine.dispose()  # delete the initial group channel

快速安装

要安装shellbot包,请输入

$ pip install shellbot

或者,如果您想下载包括示例和文档在内的完整项目并安装,请按照以下步骤操作

$ git clone https://github.com/bernard357/shellbot.git
$ cd shellbot
$ pip install -e .

您想从哪里开始?

致谢

项目详情


下载文件

下载您平台上的文件。如果您不确定选择哪一个,请了解更多关于 安装包 的信息。

源代码发行版

shellbot-17.10.20.tar.gz (195.6 kB 查看哈希)

上传时间: 源代码

构建发行版

shellbot-17.10.20-py2.py3-none-any.whl (125.9 kB 查看哈希)

上传时间: Python 2 Python 3

支持者