0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

hubot-slackをv3からv4にあげたやつ(今更)

Last updated at Posted at 2018-10-16

経緯

daemonにぶちこんだはずのhubotが気付いたら息をしなくなる
ログを見ている限り「一定数以上msg.send走った瞬間に即死している」ようにしか見えず、原因が不明
https://kakakakakku.hatenablog.com/entry/2016/11/05/133008
この辺みたらアプデすりゃええよって書いてあったのでとりあえずあげてみようと思った

環境

$ cat /etc/redhat-release
CentOS release 6.2 (Final)

$ npm list --depth=0 | grep hubot-slack
├── hubot-slack@3.4.2

v4導入手順

$ npm info hubot-slack versions
4.5.5が最新なのでそれ使う
package.json
-    "hubot-slack": "^3.3.0",
+    "hubot-slack": "^4.5.5",
$ npm install
npm WARN engine https-proxy-agent@2.2.1: wanted: {"node":">= 4.5.0"} (current: {"node":"0.12.18","npm":"2.15.11"})
npm WARN engine request@2.88.0: wanted: {"node":">= 4"} (current: {"node":"0.12.18","npm":"2.15.11"})
npm WARN engine agent-base@4.2.1: wanted: {"node":">= 4.0.0"} (current: {"node":"0.12.18","npm":"2.15.11"})
npm WARN engine har-validator@5.1.0: wanted: {"node":">=4"} (current: {"node":"0.12.18","npm":"2.15.11"})
npm WARN engine har-schema@2.0.0: wanted: {"node":">=4"} (current: {"node":"0.12.18","npm":"2.15.11"})

nodeがクソ古い

SyntaxError: Use of const in strict mode.

というエラーが発生するようになるので、いつものコマンドでnodeも更新しておく(0.12.18て・・・)

$ nvm ls-remote
$ nvm install v4.9.1 # 4以上を要求されてたのでひとまず4系最新
$ nvm use v4.9.1
$ nvm alias default 4.9.1
$ node -v
v4.9.1
$ npm -v
2.15.11

npm install が通ることを確認しておわり

coffee-script側対応

ほとんど触ってない
よくある「特定roomでのみ喋らせる」やつでの部屋名取得方法が変わってたのでその対応
https://qiita.com/Mahito/items/31e02160ecbdff810a52

script/1_room_limit.coffee
_ = require 'lodash'
module.exports = (robot) ->
  robot.hear /.*/, (msg) ->
   join_channels = [
      'general',
      'hubot',
      ...
   ]
   channel = msg.envelope.room
   robot.adapter.client.web.conversations.info(channel)
     .then((response) ->
       room_name = response.channel.name
       unless _.contains join_channels, room_name
         msg.finish()
     )

上記qiitaでは robot.adapter.client.web.channels.info ですが、
channels.info だと共有chとかプライベートchで動かない、
groups.info は非推奨なので
conversations.info にしてます。

その後

hubotちゃんは生まれつきメモリパワーが弱く1ヶ月以内に増設が必要です
しかしメモリ増設には10,798円という莫大な費用がかかります。
hubotちゃんを救うためにどうか協力をよろしくお願いします。

hubotちゃん 生存時間 今の所は48時間ほど

参考

hubot-slack v4移行時のハマりどころ
https://www.slideshare.net/knjcode/hubotslack-v4-hubotchatops

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?