Created
March 20, 2009 13:16
-
-
Save darashi/82355 to your computer and use it in GitHub Desktop.
irc say bot (for OSX)
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
#!/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