Skip to content

Instantly share code, notes, and snippets.

@beco-ippei
Last active August 29, 2015 14:12
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 beco-ippei/7f8269a0b1af395082da to your computer and use it in GitHub Desktop.
Save beco-ippei/7f8269a0b1af395082da to your computer and use it in GitHub Desktop.
hubot ignores messages from not permitted room (or user)
# Description:
# ignore not permitted messages.
permitted_rooms = process.env.HUBOT_PERMITTED_ROOMS?.split(',') || []
permitted_users = process.env.HUBOT_PERMITTED_USERS?.split(',') || []
permitted = (room) ->
room in permitted_rooms || room in permitted_users
module.exports = (robot) ->
receive_org = robot.receive
robot.receive = (msg)->
user = msg.user?.name?.trim().toLowerCase()
room = msg.room?.trim().toLowerCase()
if permitted room # allow permitted room or user (direct message)
receive_org.bind(robot)(msg)
else
console.log "ignored messge, from #{user} at #{room}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment