Skip to content

Commit

Permalink
Enable Malcolm to be turned off with a simple
Browse files Browse the repository at this point in the history
environment variable switch
  • Loading branch information
ocean committed Jun 11, 2018
1 parent 9980653 commit d4c99c8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Your Hubot will now respond with a highly inappropriate, uniquely-Malcolm Tucker

### Configuration variables

- `HUBOT_TUCKER_OFF` - if you need to quickly and simply switch Malcolm off completely, set this to `true` or `1` and this Hubot script will only judge you silently, instead of loudly in public.

- `HUBOT_LESS_MALCOLM` - if you wish Hubot to not respond with a quote when the name "Malc" or "Malcolm" is mentioned (say because you have someone in your team called Malcolm, or because [your country gets a new Prime Minister][5] and your colleagues chat about politics a lot ;-) then set `HUBOT_LESS_MALCOLM` to `true` or `1` and Hubot will ignore these words.

- `HUBOT_TUCKER_BYLINE` - if some members of your chat room are perplexed about the abuse Hubot is hurling and who this Malcolm person is, set this to `true` or `1` and Hubot will sign each pithy general abuse epithet with a byline, "`-- Malcolm Tucker`".
Expand Down
48 changes: 25 additions & 23 deletions src/tucker.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# None
#
# Configuration:
# HUBOT_TUCKER_OFF - quick switch to turn Malcolm off completely, if set to true
# HUBOT_LESS_MALCOLM - if set to true or 1, Hubot will skip mentions of "Malcolm" or "Malc"
# HUBOT_TUCKER_BYLINE - if set to true or 1, Hubot will add a byline to the end of quotes
#
Expand Down Expand Up @@ -78,34 +79,35 @@ restOfQuotes = [
allQuotes = secondPerson.concat thirdPerson, restOfQuotes

module.exports = (robot) ->
robot.respond /tucker (.+)/i, (res) ->
person = res.match[1]
if person is "me"
quote = res.random thirdPerson
res.send "Malcolm was talking about you earlier, he said \"#{quote}\""
else if person.search(/malc|malcolm|tucker|himself/i) > -1
res.send "I'm watching you, you cheeky fucker."
else
quote = res.random secondPerson
res.send "I heard Malcolm talking to #{person}, he said \"#{quote}\""

robot.hear /tucker/i, (res) ->
message = res.message.text
re = new RegExp robot.name, 'i'
if message.search(re) is -1
quote = res.random allQuotes
if process.env.HUBOT_TUCKER_BYLINE
res.send "\"#{quote}\" -- Malcolm Tucker"
unless process.env.HUBOT_TUCKER_OFF
robot.respond /tucker (.+)/i, (res) ->
person = res.match[1]
if person is "me"
quote = res.random thirdPerson
res.send "Malcolm was talking about you earlier, he said \"#{quote}\""
else if person.search(/malc|malcolm|tucker|himself/i) > -1
res.send "I'm watching you, you cheeky fucker."
else
res.send "\"#{quote}\""
quote = res.random secondPerson
res.send "I heard Malcolm talking to #{person}, he said \"#{quote}\""

unless process.env.HUBOT_LESS_MALCOLM
robot.hear /malc(\s*|olm)/i, (res) ->
robot.hear /tucker/i, (res) ->
message = res.message.text
console.dir res
if message.search(/tucker/i) is -1 and message.search(/Malcolm was talking/i) is -1 and message.search(/heard Malcolm talking/i) is -1
re = new RegExp robot.name, 'i'
if message.search(re) is -1
quote = res.random allQuotes
if process.env.HUBOT_TUCKER_BYLINE
res.send "\"#{quote}\" -- Malcolm Tucker"
else
res.send "\"#{quote}\""

unless process.env.HUBOT_LESS_MALCOLM
robot.hear /malc(\s*|olm)/i, (res) ->
message = res.message.text
# console.dir res
if message.search(/tucker/i) is -1 and message.search(/Malcolm was talking/i) is -1 and message.search(/heard Malcolm talking/i) is -1
quote = res.random allQuotes
if process.env.HUBOT_TUCKER_BYLINE
res.send "\"#{quote}\" -- Malcolm Tucker"
else
res.send "\"#{quote}\""

0 comments on commit d4c99c8

Please sign in to comment.