All pastes #763391 Raw Edit

Something

public ruby v1 · immutable
·published 2007-11-06 12:28 UTC
rendered paste body
#!/usr/bin/ruby####      an experimental irc bot##require 'socket'channel = '#novus'server = 'chat.us.freenode.net'port = 6667username = 'erlBot'hostname = 'hackdmz.net'servername = 'ircd.hackdmz.net'realname = ':erlBot'nick = 'erlBot'TCPSocket.open(server, port) do |sock|        sock.puts "USER #{username} #{hostname} #{servername} #{realname}\r\n"        sock.puts "Nick #{nick}\r\n"        sock.puts "JOIN #{channel}\r\n"        while !sock.closed?                line = sock.readline.chomp                puts "#{line}\n"                # Support PING                sock.puts "PONG #{$1}\r\n" if line =~ /PING :(.*)/                # echo what people !say me to do                sock.puts "PRIVMSG #{channel} :#{$1}\r\n" if line =~ /.*?PRIVMSG #{channel} :!say (.*)/                # Try to get the nowlistening track of a lastfm user                if line =~ /.*?PRIVMSG #{channel} :!lfm_last (.*)/                        user = $1                        page = %x[wget -O - http://www.last.fm/user/'#{user}']                        flag = 0                        page.each_line do |line|                                if flag == 0                                        if line =~ /<a.*>(.*)<\/a> .* <a.*>(.*)<\/a>/                                                sock.puts "PRIVMSG #{channel} :Latest track for #{user}: #{$1} - #{$2}\r\n"                                                flag = 1                                        end                                end                        end                        sock.puts "PRIVMSG #{channel} :Unable to find last.fm information for #{user}.\r\n" if flag == 0                end                # !nick functionality                sock.puts "Nick #{$1}\r\n" if line =~ /.*?PRIVMSG #{channel} :!nick (.*)/        endend