All pastes #765651 Raw Edit

Mine

public lua v1 · immutable
·published 2007-11-08 06:31 UTC
rendered paste body
local function regexp(string, exp)   local ret   string.gsub(string, exp, function(...) ret = arg end)   if(ret) then      return unpack(ret)   else      return nil   endendfunction parseline(line)   local nl   local prefix,command   prefix,ln = regexp(line, "^%:([^ ]+) +(.+)$")   if(prefix) then line = ln end   command,ln = regexp(line, "^([^ ]+)(.*)$")   if(not command) then      command,ln = regexp(line, "^([0-9][0-9][0-9])( +.+)$")      if(not command) then return nil end   else      if(string.gsub(command, "[^-A-Za-z0-9_]", "") ~= command) then return nil end   end   line = ln   local ret = {prefix=prefix, command=command}   repeat      local param      param,ln = regexp(line, "^ +([^:\10\13 ][^\10\13 ]*)(.*)$")      if(not param) then	 param = regexp(line, "^ +:([^\10\13]*)$")	 if(not param) then	    return ret	 end	 table.insert(ret, param)	 return ret      else	 table.insert(ret, param)	 line = ln      end   until false   return retendsocket = require("socket")-- Connect to IRC, make sure the nick is free, give IRC our credentialsprint("Connecting to IRC...")socket = socket.connect("irc.ascentemu.com",6667)-- socket:send("PRIVMSG NickServ :ghost CDC panstarefun\n") This was just to ghost nicks using ourssocket:send("NICK BurkBOT\n")socket:send("USER CDC bogus. this.is.ignored :CDC\n")-- [[ Display all the crap IRC sends back; we're looking for the PING and for the moment to ID the nick. When we find the PING we PONG back. A debugging line allows us to see what commands we're getting from the IRC server. ]]repeat    feedback = socket:receive("*l")    print(feedback)    cmd = parseline(feedback)--  printtable(cmd)    if (cmd["command"] == "PING") then        print("Found PING!!!")        socket:send("PONG "..cmd[1].."\n")    enduntil (feedback == "Hi my name is Jeffrey and I like apples")--[[ until ( feedback == ":NickServ!services@services.slashnet.org NOTICE CDC :If you do not change your nickname within one minute, it will be changed automatically.") --]]-- End of the intro crap, we now deliver the nick ID commandprint("Sending IDENTIFY command.")-- socket:send("PRIVMSG NickServ :IDENTIFY pantsarefun\n") Not registered nick yetfeedback = socket:receive("*l")print(feedback)-- We're now connected, and enter #cdc on command-- io.input()print("Connected. Ready to join the channel")x = io.read("*l")print(x)socket:send("JOIN #moon++\n")