Last active
August 29, 2015 14:12
-
-
Save beco-ippei/7f8269a0b1af395082da to your computer and use it in GitHub Desktop.
hubot ignores messages from not permitted room (or user)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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