Skip to content

Instantly share code, notes, and snippets.

@nogweii
Created December 17, 2008 23:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nogweii/37295 to your computer and use it in GitHub Desktop.
Save nogweii/37295 to your computer and use it in GitHub Desktop.
#!/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 60 # 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 ' if USER}#{CHANNEL}"
@client.subscribe(:RPL_WELCOME) 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)
@client.info "Joined #{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