More Related Content
Similar to Chatopsのおかけでエンジニアがルーティンワークから解放された話
Similar to Chatopsのおかけでエンジニアがルーティンワークから解放された話 (20)
Chatopsのおかけでエンジニアがルーティンワークから解放された話
- 2. 自己紹介
・名前:葛 飛 (カツ ヒ)
・出身:中国
・職業:インフラエンジニア
・主にAWS中心にインフラ作業を担当
・最近、サーバサイド・フロント開発も参入
・所属:Newspicks2年目
・AWS歴:3年
・Java歴:半年
- 21. 権限管理
checkPrivilege.coffee
class checkPrivilege
administrators = [""]
pushers = [""]
isAdmin: (slackid)->
if slackid in administrators
return true
else
return false
isPusher: (slackid)->
if slackid in pushers
return true
else
return false
module.exports = checkPrivilege
checkPrivilege = require('./checkPrivilege.coffee')
module.exports = (robot) ->
robot.respond /push comfirm (.*)$/i, (msg) ->
userid = msg.envelope.user.id
CheckPrivilege = new checkPrivilege()
if CheckPrivilege.isPusher(userid)
newsid = msg.match[1]
@exec = require('child_process').exec
command = "プッシュコマンド #{newsid}"
msg.send "newsid confirm is starting!"
@exec command, (error, stdout, stderr) ->
msg.send error if error?
msg.send stdout if stdout?
msg.send "<@#{msg.envelope.user.id}>"
msg.send stderr if stderr?
else
msg.send "you can no privilege to do this"
msg.send "<@#{msg.envelope.user.id}>"
msg.finish()