Skip to content

Instantly share code, notes, and snippets.

@manaten
Last active August 29, 2015 14:10
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 manaten/2c2df56accfe590df215 to your computer and use it in GitHub Desktop.
Save manaten/2c2df56accfe590df215 to your computer and use it in GitHub Desktop.
hubot で configで指定している以外のチャンネルでhearした場合につぶやかないスクリプト。最初に読まれるように _ とかでファイル名を始める
# Description:
# Force hubot hearing messages only in rooms.
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# None
#
config = require 'config'
_ = require 'lodash'
module.exports = (robot) ->
robot.hear /.*/, (msg) ->
if _.contains config.roomLimit.specialUsers, msg.envelope.user.name
return
unless _.contains config.roomLimit.rooms, msg.envelope.room
# see https://github.com/github/hubot/issues/200
msg.finish()
if /bot/.test msg.envelope.user.name
msg.finish()
@manaten
Copy link
Author

manaten commented Jan 7, 2015

configはこんなかんじ

roomLimit:
  specialUsers:
    - 'manaten'
  rooms:
    - 'room1'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment