Skip to content

Commit

Permalink
Add UDP netowork messages to Hubot
Browse files Browse the repository at this point in the history
  • Loading branch information
smgt committed Jan 16, 2012
1 parent 4752198 commit 8f169fd
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/scripts/cat.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Send messages to channels via hubot
#
# $ echo "#channel|hello everyone" | nc -u -w1 bot_hostname bot_port
# $ echo "nickname|hello mister" | nc -u -w1 bot_hostname bot_port
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))

0 comments on commit 8f169fd

Please sign in to comment.