slackに書き込まれたものをhubotでLINE Notifyで送る
TL;DR
- slackの特定のchannelに書き込まれたテキストをLINE NotifyでLINEにおくる
- LINE Notifyのaccess_tokenは適宜取得する
script
line_notify.coffee
# Description:
# Line Notify bot
#
# Commands:
# target channel hear
#
# Author:
# tknzk
module.exports = (robot) ->
robot.hear /.*/, (res) ->
room = res.envelope.room
text = res.message.text
console.log room
console.log text
if room == 'TARGET CHANNEL'
request = res.http("https://notify-api.line.me/api/notify")
.headers("Authorization": "Bearer " + process.env.HUBOT_LINE_NOTIFY_API_TOKEN)
.headers("Content-Type": 'application/x-www-form-urlencoded')
.post("message=" + text)
request (err, resp, body) ->
if err
res.send err
else
if body.length == 0
res.send "Failed "
else
res.send body
line_notify.coffee
# Description:
# Line Notify bot
#
# Commands:
# target channel hear
#
# Author:
# tknzk
module.exports = (robot) ->
robot.hear /.*/, (res) ->
room = res.envelope.room
text = res.message.text
console.log room
console.log text
if room == 'TARGET CHANNEL'
request = res.http("https://notify-api.line.me/api/notify")
.headers("Authorization": "Bearer " + process.env.HUBOT_LINE_NOTIFY_API_TOKEN)
.headers("Content-Type": 'application/x-www-form-urlencoded')
.post("message=" + text)
request (err, resp, body) ->
if err
res.send err
else
if body.length == 0
res.send "Failed "
else
res.send body
Author And Source
この問題について(slackに書き込まれたものをhubotでLINE Notifyで送る), 我々は、より多くの情報をここで見つけました https://qiita.com/tknzk/items/7e75e32b183b138f9202著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .