mrtaddy/omg-hubot

语言: CoffeeScript

git: https://github.com/mrtaddy/omg-hubot

README.md (中文)

hubot

Build Status Dependency Status

这是GitHub的Campfire bot,hubot的一个版本。他很酷。

此版本旨在部署在Heroku上。本自述文件由hubot为您生成,以帮助您入门。绝对更新和改进,讨论你自己的实例,如何使用和部署,他有什么功能,等等!

在本地测试Hubot

您可以通过运行以下命令来测试您的hubot。

% bin/hubot

你会看到一些关于脚本来自哪里的启动输出和a 提示。

[Sun, 04 Dec 2011 18:41:11 GMT] INFO Loading adapter shell
[Sun, 04 Dec 2011 18:41:11 GMT] INFO Loading scripts from /home/tomb/Development/hubot/scripts
[Sun, 04 Dec 2011 18:41:11 GMT] INFO Loading scripts from /home/tomb/Development/hubot/src/scripts
Hubot>

然后,您可以通过键入hubot help与hubot进行交互。

Hubot> hubot help

Hubot> animate me <query> - The same thing as `image me`, except adds a few
convert me <expression> to <units> - Convert expression to given units.
help - Displays all of the help commands that Hubot knows about.
...

脚本

有关示例,请查看./scripts文件夹中的脚本。 删除您认为无用或无聊的任何脚本。添加你的任何功能 想拥有hubot。阅读“脚本指南”中有关hubot的功能。

Redis Persistence

如果要使用hubot-scripts中的redis-brain.coffee脚本 (强烈建议),你需要在Heroku上添加Redis to Go插件,这需要经过验证 帐户或您可以手动在Redis to Go创建帐户 设置REDISTOGO_URL变量。

% heroku config:set REDISTOGO_URL="..."

如果你不需要任何持久性,请随意删除 来自hubot-scripts.json的redis-brain.coffee,你不必担心 关于redis。

适配器

适配器是您希望hubot运行的服务的接口。这个 可以像Campfire或IRC。有一些第三方 社区贡献的适配器。检查 适用于Hubot适配器的适配器。

如果您想运行非Campfire或shell适配器,则需要添加 适配器包作为依赖于package.json文件的 依赖部分。

一旦你添加了依赖项并运行npm install来安装它就可以了 然后使用适配器运行hubot。

% bin/hubot -a <adapter>

其中<adapter>是没有hubot-前缀的适配器的名称。

裸体脚本

每个人都想要的功能将不可避免地存在。代替 将它添加到hubot本身,您可以提交拉取请求 hubot的脚本。

要从hubot-scripts包启用脚本,请使用以下命令添加脚本名称 扩展为双引号字符串到hubot-scripts.json文件中 回购。

外部脚本

厌倦了等待你的脚本合并到hubot脚本?想要 自己维护存储库和包?然后这个添加的功能 也许对你来说!

Hubot现在可以从第三方npm包加载脚本!启用 您可以按照以下步骤操作此功能。

  1. 将包作为依赖项添加到package.json中
  2. npm install以确保安装了这些软件包

要启用已添加的第三方脚本,您需要添加该程序包 将此名称作为此repo中external-scripts.json文件的双引号字符串。

部署

% heroku create --stack cedar
% git push heroku master
% heroku ps:scale app=1

如果您的Heroku帐户已经过验证,您可以运行以下命令来启用 并将Redis to Go插件添加到您的应用中。

% heroku addons:add redistogo:nano

如果您遇到任何问题,请查看Heroku的文档。

您需要编辑Procfile以设置hubot的名称。

更详细的文档可以在上找到 将hubot部署到Heroku wiki页面。

部署到UNIX或Windows

如果要部署到UNIX操作系统或Windows。 请查看在UNIX上部署hubot 将hubot部署到Windows wiki页面上。

篝火变量

如果您使用的是Campfire适配器,则需要设置一些环境 变量。请参阅其他适配器和配置文档 其中,可以在Hubot Adapters上找到适配器的链接。

为您的机器人创建一个单独的Campfire用户,并从Web获取其令牌 UI。

% heroku config:set HUBOT_CAMPFIRE_TOKEN="..."

获取您希望机器人加入的房间的数字ID,逗号分隔。如果 您希望机器人连接到https://mysubdomain.campfirenow.com/room/42 和https://mysubdomain.campfirenow.com/room/1024然后你这样添加它:

% heroku config:set HUBOT_CAMPFIRE_ROOMS="42,1024"

添加要连接的子域hubot。如果你的网址看起来像 http://mysubdomain.campfirenow.com然后你会像这样添加它:

% heroku config:set HUBOT_CAMPFIRE_ACCOUNT="mysubdomain"

重启机器人

您可能希望熟悉heroku日志和heroku重启 如果你有问题。

本文使用googletrans自动翻译,仅供参考, 原文来自github.com

en_README.md

Hubot

Build Status Dependency Status

This is a version of GitHub's Campfire bot, hubot. He's pretty cool.

This version is designed to be deployed on Heroku. This README was generated for you by hubot to help get you started. Definitely update and improve to talk about your own instance, how to use and deploy, what functionality he has, etc!

Testing Hubot Locally

You can test your hubot by running the following.

% bin/hubot

You'll see some start up output about where your scripts come from and a
prompt.

[Sun, 04 Dec 2011 18:41:11 GMT] INFO Loading adapter shell
[Sun, 04 Dec 2011 18:41:11 GMT] INFO Loading scripts from /home/tomb/Development/hubot/scripts
[Sun, 04 Dec 2011 18:41:11 GMT] INFO Loading scripts from /home/tomb/Development/hubot/src/scripts
Hubot>

Then you can interact with hubot by typing hubot help.

Hubot> hubot help

Hubot> animate me <query> - The same thing as `image me`, except adds a few
convert me <expression> to <units> - Convert expression to given units.
help - Displays all of the help commands that Hubot knows about.
...

Scripting

Take a look at the scripts in the ./scripts folder for examples.
Delete any scripts you think are useless or boring. Add whatever functionality you
want hubot to have. Read up on what you can do with hubot in the Scripting Guide.

Redis Persistence

If you are going to use the redis-brain.coffee script from hubot-scripts
(strongly suggested), you will need to add the Redis to Go addon on Heroku which requires a verified
account or you can create an account at Redis to Go and manually
set the REDISTOGO_URL variable.

% heroku config:set REDISTOGO_URL="..."

If you don't require any persistence feel free to remove the
redis-brain.coffee from hubot-scripts.json and you don't need to worry
about redis at all.

Adapters

Adapters are the interface to the service you want your hubot to run on. This
can be something like Campfire or IRC. There are a number of third party
adapters that the community have contributed. Check
Hubot Adapters for the available ones.

If you would like to run a non-Campfire or shell adapter you will need to add
the adapter package as a dependency to the package.json file in the
dependencies section.

Once you've added the dependency and run npm install to install it you can
then run hubot with the adapter.

% bin/hubot -a <adapter>

Where <adapter> is the name of your adapter without the hubot- prefix.

hubot-scripts

There will inevitably be functionality that everyone will want. Instead
of adding it to hubot itself, you can submit pull requests to
hubot-scripts.

To enable scripts from the hubot-scripts package, add the script name with
extension as a double quoted string to the hubot-scripts.json file in this
repo.

external-scripts

Tired of waiting for your script to be merged into hubot-scripts? Want to
maintain the repository and package yourself? Then this added functionality
maybe for you!

Hubot is now able to load scripts from third-party npm packages! To enable
this functionality you can follow the following steps.

  1. Add the packages as dependencies into your package.json
  2. npm install to make sure those packages are installed

To enable third-party scripts that you've added you will need to add the package
name as a double quoted string to the external-scripts.json file in this repo.

Deployment

% heroku create --stack cedar
% git push heroku master
% heroku ps:scale app=1

If your Heroku account has been verified you can run the following to enable
and add the Redis to Go addon to your app.

% heroku addons:add redistogo:nano

If you run into any problems, checkout Heroku's docs.

You'll need to edit the Procfile to set the name of your hubot.

More detailed documentation can be found on the
deploying hubot onto Heroku wiki page.

Deploying to UNIX or Windows

If you would like to deploy to either a UNIX operating system or Windows.
Please check out the deploying hubot onto UNIX and
deploying hubot onto Windows wiki pages.

Campfire Variables

If you are using the Campfire adapter you will need to set some environment
variables. Refer to the documentation for other adapters and the configuraiton
of those, links to the adapters can be found on Hubot Adapters.

Create a separate Campfire user for your bot and get their token from the web
UI.

% heroku config:set HUBOT_CAMPFIRE_TOKEN="..."

Get the numeric IDs of the rooms you want the bot to join, comma delimited. If
you want the bot to connect to https://mysubdomain.campfirenow.com/room/42
and https://mysubdomain.campfirenow.com/room/1024 then you'd add it like this:

% heroku config:set HUBOT_CAMPFIRE_ROOMS="42,1024"

Add the subdomain hubot should connect to. If you web URL looks like
http://mysubdomain.campfirenow.com then you'd add it like this:

% heroku config:set HUBOT_CAMPFIRE_ACCOUNT="mysubdomain"

Restart the bot

You may want to get comfortable with heroku logs and heroku restart
if you're having issues.