Created
December 17, 2008 23:39
-
-
Save nogweii/37296 to your computer and use it in GitHub Desktop.
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/ruby | |
$LOAD_PATH.unshift File.expand_path("#{ENV['HOME']}/Code/Checkout/silverplatter-irc/trunk/lib") | |
$LOAD_PATH.unshift File.expand_path("#{ENV['HOME']}/Code/Checkout/silverplatter-log/lib") | |
require 'silverplatter/irc/client' | |
require 'pp' | |
CHANNEL = ARGV[0] || "#general" | |
USER = ARGV[1] || nil | |
@client = SilverPlatter::IRC::Connection.new do | |
# server data | |
server "irc.freenode.net" | |
port 6667 # 6667 is the norm | |
serverpass nil # Password to access the server (uncommon) | |
# client data | |
nickname "FBI" | |
username "silverp" | |
realname "SilverPlatter-IRC" | |
# pings the server in the given interval, useful for some. | |
# Most people don't need this enabled (set it to 0) | |
ping_interval 45 # in seconds | |
# reconnect so many times on timeouts/sudden disconnects | |
reconnect_tries nil # nil == infinite tries | |
# delay the reconnect for so many seconds | |
reconnect_delay 60 # in seconds | |
# on_nick_error accepts a block that is invoked in case | |
# the server informs you that your nick is erroneous or already in use | |
on_nick_error &SilverPlatter::IRC::Connection::IncrementOnNickError | |
# on_disconnect accepts a block that is invoked in case the connection is interrupted | |
# since termination of the connection can happen for various reasons, the reason is provided | |
# and either FIXME. | |
on_disconnect { |connection, reason| | |
puts "Disconnected due to #{reason}" | |
SilverPlatter::IRC::Connection::OnDisconnect.call(client, connection, reason) | |
} | |
end | |
begin | |
@client.info "Spooking #{USER} on #{CHANNEL}" | |
@client.subscribe(:PRIVMSG) do |listener, message| | |
if USER | |
@client.send_privmsg("#{USER}: We saw that", CHANNEL) | |
else | |
@client.send_privmsg("We saw that", CHANNEL) | |
end | |
@client.quit("Anti-terrorism at it's best!") | |
@client.close | |
exit! | |
end | |
@client.info "Connecting to the IRC server" | |
@client.connect | |
@client.run | |
@client.login | |
@client.send_join(CHANNEL) | |
sleep | |
rescue Interrupt | |
@client.quit("Anti-terrorism at it's best!") | |
end | |
puts | |
puts "Terminated." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment