在 Linux 上搭建 Hubot 聊天机器人服务器

1. 先确定安装了 Node.js
如果还没安装Node.js,就先安装Node.js。Node.js是绿色软件,只要解压安装包即可。这里假设已经在/data/node-v5.12.0/目录下安装了 node-v5.12.0 。

2. 安装 Hubot 框架
# npm install -g yo generator-hubot

3. 创建 Hubot 项目
# mkdir myHubot
# cd myHubot
# yo hubot

如果出现错误:
/usr/bin/node: No such file or directory

软连接解决:
# ln -s /data/node-v5.12.0/bin/node /usr/bin/node
# ln -s /data/node-v5.12.0/bin/npm /usr/bin/npm

再试:
# yo hubot
/data/node-v5.12.0/lib/node_modules/yo/node_modules/mkdirp/index.js:90
                    throw err0;
                    ^
Error: EACCES: permission denied, mkdir '/root/.config'
    at Error (native)
    at Object.fs.mkdirSync (fs.js:842:18)
    at sync (/data/node-v5.12.0/lib/node_modules/yo/node_modules/mkdirp/index.js:71:13)
    at Function.sync (/data/node-v5.12.0/lib/node_modules/yo/node_modules/mkdirp/index.js:77:24)
    at Object.create.all.get (/data/node-v5.12.0/lib/node_modules/yo/node_modules/configstore/index.js:38:13)
    at Object.Configstore (/data/node-v5.12.0/lib/node_modules/yo/node_modules/configstore/index.js:27:44)
    at new Insight (/data/node-v5.12.0/lib/node_modules/yo/node_modules/insight/lib/index.js:37:34)
    at Object.<anonymous> (/data/node-v5.12.0/lib/node_modules/yo/lib/cli.js:172:11)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)

如果出现上面错误,就执行:
# chmod g+rwx /root

然后再试:
# yo hubot
==========================================================================
We're constantly looking for ways to make yo better! 
May we anonymously report usage statistics to improve the tool over time? 
More info: https://github.com/yeoman/insight & http://yeoman.io
==========================================================================
                     _____________________________  
                    /                             \ 
   //\              |      Extracting input for    |
  \    _____    |   self-replication process   |
 //\  /_____\   \                             / 
 ======= |[^_/\_]|   /----------------------------  
  |   | _|___@@__|__                                
  +===+/  ///     \_\                               
   | |_\ /// HUBOT/\\                             
   |___/\//      /  \\                            
         \      /   +---+                            
          \____/    |   |                            
           | //|    +===+                            
            \//      |xx|

? Owner Paul
? Bot name myhubot
? Description A simple helpful robot for your Company
? Bot adapter campfire
...

出现了上面安装提示界面,输入所有者、Hubot 名称和描述等。输好后会根据输入的创建对应的配置文件,然后进行处理,并且安装一些模块文件等。
等待安装完成就可以使用了,执行下面命令。

# ./bin/hubot
...      
[Tue May 02 2017 22:11:16 GMT+0800 (CST)] ERROR Error: listen EADDRINUSE 0.0.0.0:8080
  at Object.exports._errnoException (util.js:893:11)
  at exports._exceptionWithHostPort (util.js:916:20)
  at Server.__dirname.Server.Server._listen2 (net.js:1246:14)
  at listen (net.js:1282:10)
  at net.js:1391:9
  at _combinedTickCallback (internal/process/next_tick.js:77:11)
  at process._tickCallback (internal/process/next_tick.js:98:9)
myhubot>

上面提示 8080 端口被占用了,可以指定端口执行,比如换 8100 端口:
# PORT=8100 ./bin/hubot
normalizeTree             ?
loadCurrentTree           
myhubot> [Sun May 07 2017 15:13:29 GMT+0800 (CST)] WARNING Loading scripts from hubot-scripts.json is deprecated and will be removed in 3.0 (https://github.com/github/hubot-scripts/issues/1113) in favor of packages for each script.

Your hubot-scripts.json is empty, so you just need to remove it.
[Sun May 07 2017 15:13:29 GMT+0800 (CST)] INFO hubot-redis-brain: Using default redis on localhost:6379
[Sun May 07 2017 15:13:29 GMT+0800 (CST)] INFO hubot-redis-brain: Data for hubot brain retrieved from Redis
myhubot>

出现上面显示,说明机器人正常启动。

4. 验证 Hubot 是否安装完成
在命令行里输入 myHubot ping ,如果能看到回复 PONG,说明 Hubot 就安装完成了。
如下:
myhubot> myHubot ping
myhubot> PONG

注:myHubot ping 中的 myHubot 是你的机器人名称。

5. 查看可以使用哪些命令
想查看可以使用哪些命令,在命令行里输入 myHubot help 。
如下:
myhubot> myHubot help
myhubot> Shell: myhubot adapter - Reply with the adapter
myhubot animate me <query> - The same thing as `image me`, except adds a few parameters to try to return an animated GIF instead.
myhubot echo <text> - Reply back with <text>
myhubot help - Displays all of the help commands that Hubot knows about.
myhubot help <query> - Displays all help commands that match <query>.
myhubot image me <query> - The Original. Queries Google Images for <query> and returns a random top result.
myhubot map me <query> - Returns a map view of the area returned by `query`.
myhubot mustache me <url|query> - Adds a mustache to the specified URL or query result.
myhubot ping - Reply with pong
myhubot pug bomb N - get N pugs
myhubot pug me - Receive a pug
myhubot the rules - Make sure hubot still knows the rules.
myhubot time - Reply with current time
myhubot translate me <phrase> - Searches for a translation for the <phrase> and then prints that bad boy out.
myhubot translate me from <source> into <target> <phrase> - Translates <phrase> from <source> into <target>. Both <source> and <target> are optional
ship it - Display a motivation squirrel

myhubot>

安装完毕。

参考:

1. http://blog.csdn.net/wang1144/article/details/53442155

2. http://blog.csdn.net/yaoyasong/article/details/51425601

3. http://www.tuicool.com/articles/IjmuIre

在 Linux 上搭建 Hubot 聊天机器人服务器相关推荐

  1. linux中央服务器,如何在Linux上搭建一个Git中央仓库

    前言:本教程只面向那些个人开发者,想要自己在linux上搭建一个git中央仓库用来上传发布自己的项目.但是对于团队来说可能有更高的要求,可以使用gitlab搭建一个可视化的类似github的版本管理系 ...

  2. 在Linux上搭建TCP通信测试服务器

    在Linux上搭建TCP通信测试服务器 前言 在 Linux平台上搭建TCP通信测试服务器的方法多种多样,本文就列举出来非常简单的服务器搭建方法. 搭建TCP通信测试服务器的主要作用就是为了验证TCP ...

  3. linux java web.pdf,Linux上搭建Java_Web服务器.pdf

    Linux上搭建Java_Web服务器.pdf 建立Java Web服务器 技术:Apache+Tomcat+JDK+Mysql 由于Apache 整合了Tomcat,所以这个直接拿来用 首先上传上去 ...

  4. 在Linux上搭建ftp服务器

    ftp服务器搭建 FTP(File Transfer Protocol,文件传输协议) 是 TCP/IP 协议组中的协议之一.使用起来还是挺方便的,偶尔可以用来在同一局域网的两台主机互传文件.下面介绍 ...

  5. 使用LVS(Linux Virtual Server)在Linux上搭建负载均衡的集群服务

    使用LVS(Linux Virtual Server)在Linux上搭建负载均衡的集群服务 一.基于于NAT的LVS的安装与配置. 1. 硬件需求和网络拓扑                       ...

  6. 飞凌 修改ip地址 linux,linux上搭建DHCP服务

    linux上搭建DHCP服务 1.首先安装DHCP服务需要的软件包 yum install dhcp* 2.手工编译DHCP主配置文件/etc/dhcp/dhcpd.conf 配置内容如下 ddns- ...

  7. Linux上搭建Hadoop2.6.3集群以及WIN7通过Eclipse开发MapReduce的demo

    随笔 - 70  文章 - 0  评论 - 88 Linux上搭建Hadoop2.6.3集群以及WIN7通过Eclipse开发MapReduce的demo 近期为了分析国内航空旅游业常见安全漏洞,想到 ...

  8. 利用tinyproxy在Linux上搭建HTTP Proxy Server

    之所以需要用到HTTP Proxy Server并不是为了要***,而是为了让没有公网IP地址的内网主机通过有公网IP地址的外网主机访问Internet.举个例子,阿里云ECS在购买时可以不购买公网I ...

  9. 【NLP实战】如何基于Tensorflow搭建一个聊天机器人

    实战是学习一门技术最好的方式,也是深入了解一门技术唯一的方式.因此,NLP专栏计划推出一个实战专栏,让有兴趣的同学在看文章之余也可以自动动手试一试. 本篇介绍如何基于tensorflow快速搭建一个基 ...

最新文章

  1. 给 Javascript 加上面向对象的属性:Class.js
  2. 命令行编译 WRK ,windbg 调试
  3. SLF4J: Failed to load class org.slf4j.impl.StaticLoggerBinder
  4. Java学习的快速入门:10行代码学JQuery
  5. scrum项目协作是什么_什么是小型Scrum?
  6. 关于最近Vue3+ Vue-CLI3+比较热门的十几篇文章
  7. 白话Word2Vec
  8. elasticsearch 海选功能
  9. 学习JavaScript原型应用
  10. 透過 OpenNI / NITE 分析人體骨架(上)
  11. think php5关联模型,thinkphp5 关联模型
  12. 华硕aura完全卸载_这把键盘,或是顶级光轴键盘!华硕TUF GAMING K7光轴机械键盘...
  13. Python每日一练——第5天:闰年问题升级版
  14. CLIP-对比图文多模态预训练的读后感
  15. 简单的前端文件预览下载功能
  16. 简记_PSpice仿真软件学习笔记(二)
  17. 图像的仿射变换:cv2.warpAffine()
  18. token令牌的含义和操作
  19. SSL安全证书生成及概念解释
  20. BeanUtils.populate()封装bean属性为null的四种失效原因

热门文章

  1. RS232 RS485 MODBUS RTU转PROFINET PROFIBUS网关将G120XA变频器接入西门子1500 PROFINET网络配置方法
  2. 从零开始学matplotlib画图(五): 饼图及环形图
  3. java计算机毕业设计体育论坛网站源码+系统+数据库+lw文档+mybatis+运行部署
  4. C++ 从入门到放弃,资料整合(1)—— C++ 入门
  5. 【Python | opencv+PIL】常见操作(创建、添加帧、绘图、读取等)的效率对比及其优化
  6. vue项目中如何引入阿里矢量图
  7. 好用的数据恢复软件记录
  8. 使用容器方式进行编译的经验和技巧小结
  9. 全国省市区及其编码React、Vue、小程序通用
  10. 湘潭大学自考计算机,湘潭大学自考专业