process (Irc::IrcClient)

    # File rbot/rfc2812.rb, line 857
        def process(serverstring)
          data = Hash.new
          data["SERVERSTRING"] = serverstring
          case serverstring
             when (/^PING\s+(\S+)/)
               data["PINGID"] = $1
               handle("PING", data)
             when (/^:(\S+)\s+(\d+)\s+(.*)/)
               # numeric server message
               data["SOURCE"] = $1
               num=$2.to_i
               params=$3
               case num
                 when ERR_NICKNAMEINUSE
                   # "* <nick> :Nickname is already in use"
                   if(params =~ /^\s*\*\s+(\S+)\s+:?(.*)/)
                     data["NICK"] = $1
                     data["MESSAGE"] = $2
                   end
                   handle("NICKTAKEN", data)
                 when ERR_ERRONEUSNICKNAME
                   # "* <nick> :Erroneous nickname"
                   if(params =~ /^\s*\*\s+(\S+)\s+:?(.*)/)
                     data["NICK"] = $1
                     data["MESSAGE"] = $2
                   end
                   handle("BADNICK", data)
                 when RPL_TOPIC
                   if(params =~ /^(\S+)\s+:(.*)$/)
                     data["CHANNEL"] = $1
                     data["TOPIC"] = $2
                   end
                   handle("TOPIC", data)
                 when RPL_TOPIC_INFO
                   if(params =~ /^(\S+)\s+:(.*)$/)
                     data["CHANNEL"] = $1
                     data["NICK"] = $2
                     data["UNIXTIME"] = $3
                   end
                   handle("TOPICINFO", data)
                 when RPL_NAMREPLY
                   # "( "=" / "*" / "@" ) <channel>
                   # :[ "@" / "+" ] <nick> *( " " [ "@" / "+" ] <nick> )
                   # - "@" is used for secret channels, "*" for private
                   # channels, and "=" for others (public channels).
                   if(params =~ /^(\S+)\s+([=*@])\s+(\S+)\s+:(.*)$/)
                     $4.split(" ").each {|u|
                       if(u =~ /^([@+])(.*)$/)
                         umode = $1
                         user = $2
                         @users << [user, umode]
                       else
                         @users << [u, ""]
                       end
                     }
                   end
                 when RPL_ENDOFNAMES
                   if(params =~ /^(\S+)\s+(\S+)\s+.*$/)
                     data["CHANNEL"] = $2
                     data["USERS"] = @users
                     handle("NAMES", data)
                   end
                   @users = Array.new
                 when RPL_WELCOME
                   # "Welcome to the Internet Relay Network
                   # <nick>!<user>@<host>"
                   if(params =~ /((\S+)!(\S+))/)
                     data["NETMASK"] = $1
                     data["NICK"] = $2
                     data["ADDRESS"] = $3
                   elsif(params =~ /Welcome to the Internet Relay Network\s(\S+)/)
                     data["NICK"] = $1
                   elsif(params =~ /Welcome.*Network\s+(\S+)/)
                     data["NICK"] = $1
                   end
                   handle("WELCOME", data)
                 when RPL_MOTDSTART
                   # "<nick> :- <server> Message of the Day -"
                   if(params =~ /^(\S+)\s+:-\s+(\S+)\s+(.*)$/)
                     server = $2
                     @motd = ""
                   end
                 when RPL_MOTD
                   if(params =~ /^(\S+)\s+:-\s+(.*)$/)
                     @motd += $2 + "\n"
                   end
                 when RPL_ENDOFMOTD
                   data["MOTD"] = @motd
                   handle("MOTD", data)
                 else
                   handle("UNKNOWN", data)
               end
             when (/^:((\S+)!(\S+))\s+PRIVMSG\s+(\S+)\s+:?(.*)/)
               # you can either bind to "PRIVMSG", to get every one and
               # parse it yourself, or you can bind to "MSG", "PUBLIC",
               # etc and get it all nicely split up for you.
               data["SOURCE"] = $1
               data["SOURCENICK"] = $2
               data["SOURCEADDRESS"] = $3
               data["TARGET"] = $4
               data["MESSAGE"] = $5
               handle("PRIVMSG", data)

               # Now we split it
               if(data["TARGET"] =~ /^(#|&).*/)
                 handle("PUBLIC", data)
               else
                 handle("MSG", data)
               end
             when (/^:((\S+)!(\S+))\s+KICK\s+(\S+)\s+(\S+)\s+:?(.*)/)
               data["SOURCE"] = $1
               data["SOURCENICK"] = $2
               data["SOURCEADDRESS"] = $3
               data["CHANNEL"] = $4
               data["TARGET"] = $5
               data["MESSAGE"] = $6
               handle("KICK", data)
             when (/^:((\S+)!(\S+))\s+PART\s+(\S+)\s+:?(.*)/)
               data["SOURCE"] = $1
               data["SOURCENICK"] = $2
               data["SOURCEADDRESS"] = $3
               data["CHANNEL"] = $4
               data["MESSAGE"] = $5
               handle("PART", data)
             when (/^:((\S+)!(\S+))\s+QUIT\s+:?(.*)/)
               data["SOURCE"] = $1
               data["SOURCENICK"] = $2
               data["SOURCEADDRESS"] = $3
               data["MESSAGE"] = $4
               handle("QUIT", data)
             when (/^:((\S+)!(\S+))\s+JOIN\s+:?(\S+)/)
               data["SOURCE"] = $1
               data["SOURCENICK"] = $2
               data["SOURCEADDRESS"] = $3
               data["CHANNEL"] = $4
               handle("JOIN", data)
             when (/^:((\S+)!(\S+))\s+TOPIC\s+(\S+)\s+:(.*)$/)
               data["SOURCE"] = $1
               data["SOURCENICK"] = $2
               data["SOURCEADDRESS"] = $3
               data["CHANNEL"] = $4
               data["TOPIC"] = $5
               handle("CHANGETOPIC", data)
             when (/^:((\S+)!(\S+))\s+INVITE\s+(\S+)\s+:(\S+)$/)
               data["SOURCE"] = $1
               data["SOURCENICK"] = $2
               data["SOURCEADDRESS"] = $3
               data["TARGET"] = $4
               data["CHANNEL"] = $5
               handle("INVITE", data)
             when (/^:((\S+)!(\S+))\s+NICK\s+:(\S+)$/)
               data["SOURCE"] = $1
               data["SOURCENICK"] = $2
               data["SOURCEADDRESS"] = $3
               data["NICK"] = $4
               handle("NICK", data)
             when (/^:((\S+)!(\S+))\s+MODE\s+(\S+)\s+(\S+)\s+(.*)$/)
               data["SOURCE"] = $1
               data["SOURCENICK"] = $2
               data["SOURCEADDRESS"] = $3
               data["CHANNEL"] = $4
               data["MODESTRING"] = $5
               data["TARGETS"] = $6
               handle("MODE", data)
             when (/^:(\S+)\s+NOTICE\s+(\S+)\s+:?(.*)/)
               data["SOURCE"] = $1
               data["TARGET"] = $2
               data["MESSAGE"] = $3
               if($1 =~ /(\S+)!(\S+)/)
                 data["SOURCENICK"] = $1
                 data["SOURCEADDRESS"] = $2
               end
               handle("NOTICE", data)
             else
               handle("UNKNOWN", data)
          end
        end