Skip to content

Instantly share code, notes, and snippets.

@darashi
Created March 20, 2009 13:16
Show Gist options
  • Save darashi/82355 to your computer and use it in GitHub Desktop.
Save darashi/82355 to your computer and use it in GitHub Desktop.
irc say bot (for OSX)
#!/usr/bin/env ruby1.9
require 'logger'
require 'rubygems'
require 'net/irc'
class IrcClient < Net::IRC::Client
def initialize(*args)
super
end
def on_rpl_welcome(m)
@opts.channels.each do |channel|
post JOIN, channel
end
super(m)
end
def on_privmsg(msg)
if msg[1] =~ /^say (.*)$/
s = $1
open('|say -f -', "w") do |f|
f.puts s
end
end
end
end
logger = Logger.new(STDOUT)
client = IrcClient.new('c.ustream.tv', 6667,
{:nick => 'nick', # FIXME
:user => 'user', # FIXME
:real => 'real',
:logger => logger,
:channels => %w(#channel) #FIXME
})
client.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment