Skip to content

Instantly share code, notes, and snippets.

@hlung
Last active December 9, 2015 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hlung/4317058 to your computer and use it in GitHub Desktop.
Save hlung/4317058 to your computer and use it in GitHub Desktop.
Let's make Hubot say what you want in a particular room! :D
# Description:
# Let's make Hubot say what you want in a particular room! :D
#
# Dependencies:
# -
#
# Configuration:
# -
#
# Commands:
# room <roomname> say <msg>
# room standup say everyone please standup!
#
# Author:
# hlung@oozou.com (Fri 13 Dec 2012)
# MIT License
#
#-------------------------------------------------
_bot = null
# --------------------
# Get robot var for using in sending messages later on.
# --------------------
module.exports = (robot) ->
_bot = robot
robot.respond /room (.+) say (.+)/i, (msg) ->
roomsay(msg.match[1],msg.match[2])
# This also works after bot joins the room.
# So you can call it inside some CronJob or setInterval(fun,dur,obj)
# --------------------
roomsay = (roomname,strings) ->
#ROOM_RPY = { "reply_to": '13184_botlab@conf.hipchat.com' }
ROOM_RPY = { "reply_to": "13184_#{roomname.toLowerCase()}@conf.hipchat.com" }
_bot.send(ROOM_RPY, strings) if strings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment