Hubot可以支持其他适配器,例如Shell / IRC / XMPP。
如果适配器是在环境变量中设置的HUBOT_ADAPTER
,则process.env.HUBOT_ADAPTER
可以进行检查。
if process.env.HUBOT_ADAPTER is "shell"
msg.send "This is Shell adapater"
但它也支持使用options --adapter
,以及如何在hubot脚本中检测到这一点。
我想基于适配器(如聊天室,用户ID)编写不同的逻辑。
否则,我需要为不同的调整器准备单独的脚本。
从github问题获得了两个建议https://github.com/github/hubot/issues/647
[更新]robot.coffee
通过添加在源代码中已解决此问题adapterName
,因此您可以检查robot.adapterName
从2.7.2版开始的情况,查看更改
嗅,它可以用在特殊的信息进行检查adapter
,并低于我的环境中可能的检查shell
,xmpp
,irc
robot.respond /adapter$/i, (msg) ->
#console.log "adapter", robot.adapter
if robot.adapter.client?
if robot.adapter.client.preferredSaslMechanism?
msg.send "this is xmpp adapter"
if robot.adapter.bot?
if robot.adapter.bot.opt?
msg.send "this is irc adapter"
#if robot.adapter.bot?
# msg.send "this is campfire ?"
if robot.adapter.repl?
if robot.adapter.repl.terminal?
msg.send "this is shell adapter"
添加额外的参数中robot.coffee
,它需要这个补丁,它是内部代码参见上面的更新
到目前为止,我选择嗅探
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句