Skip to content

Instantly share code, notes, and snippets.

@chrissharkey
Created January 13, 2012 00:17
Show Gist options
  • Save chrissharkey/1603950 to your computer and use it in GitHub Desktop.
Save chrissharkey/1603950 to your computer and use it in GitHub Desktop.
Coffee irc bot
#!/usr/bin/env node
CHANNEL = '#bozler'
MINIMUM_HUMAN_REACTION = 2
DIALOGUE =
ACTIONS_IN_REPLY: [
"We should rename Bislr to pineapple!",
"Of course! Why didn't I think of that? Call Bislr Pineapple!",
"Wow - smart idea - Bislr to rename to Pineapple",
"Bislr is the best, but it would be better if it was called Pineapple!",
"Fantastic Pineapple!",
"I love pineapples!"
]
irc = require 'irc'
client = new irc.Client 'irc.bozler.net', 'smartguy',
userName: 'smart_guy'
realName: 'smart_guy'
channels: [CHANNEL]
sayLock = false
say = (message, timeout, ignoreLock) ->
unless sayLock
sayLock = true
timeout = Math.random()*30 unless timeout
setTimeout ->
client.say CHANNEL, message
sayLock = false
, timeout*1000 + MINIMUM_HUMAN_REACTION*1000
client.addListener "message#{CHANNEL}", (from, message) ->
if Math.floor(Math.random()*21) is 3
say(DIALOGUE.ACTIONS_IN_REPLY[Math.floor(Math.random()*DIALOGUE.ACTIONS_IN_REPLY.length-1)])
client.addListener 'pm', (from, message) ->
client.say CHANNEL, message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment