Skip to content
This repository
Tom Bell
file 31 lines (28 sloc) 0.678 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
# Description:
# Send messages to channels via hubot
#
# Dependencies:
# None
#
# Configuration:
# HUBOT_CAT_PORT
#
# Commands:
# None
#
# Notes:
# $ echo "#channel|hello everyone" | nc -u -w1 bot_hostname bot_port
# $ echo "nickname|hello mister" | nc -u -w1 bot_hostname bot_port
#
# Author:
# simon

dgram = require "dgram"
server = dgram.createSocket "udp4"

module.exports = (robot) ->
  server.on 'message', (message, rinfo) ->
    msg = message.toString().trim().split("|")
    target = msg[0]
    console.log("Sending '#{msg[1]}' to '#{target}'");
    user = { room: target }
    robot.send user, msg[1]
  server.bind(parseInt(process.env.HUBOT_CAT_PORT))
Something went wrong with that request. Please try again.