PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: gemini on 27 May, 2005, 17:33:38

Title: convert lua 5
Post by: gemini on 27 May, 2005, 17:33:38
convert lua 5


--//    DO WHOIS INFO
----------------------------------------------------------------------------------
function doWhois(curUser,curcmd,data,num)
   local _,_,_,str1 = strfind( data,"%b<>%s+(%S+)%s+(%S+)%s*")
   if str1 and GetItemByName(str1) then
      str1 = GetItemByName(str1).sIP
   elseif str1 and not GetItemByName(str1) then
      local _,_,a,b,c,d = strfind(str1,"(%d*).(%d*).(%d*).(%d*)")
      if (a == "" or b == "" or c == "" or d == "") then
         SendToUser(curUser,"Type "..curcmd.." [UserName]/[IP].")
         return 1
      end
   else
      SendToUser(curUser, SyntaxText..": "..curcmd.." [UserName]/[IP].")
      return 1
   end
   local socket,err,Database = "","",""
   if num==1 then
      Database = "RIPE"
      socket, err = connect("whois.ripe.net", 43)
   elseif num==2 then
      Database = "ARIN"
      socket, err = connect("whois.arin.net", 43)
   elseif num==3 then
      Database = "NIC"
      socket, err = connect("whois.nic.br", 43)
   elseif num==4 then
      Database = "APNIC"
      socket, err = connect("whois.apnic.net", 43)
   end
   SendToUser(curUser,WhoisText1.." "..Database.."-Database for  "..str1.."  ...")
   local msg = "\r\n"
   if not err then
      local line,count = "",0
      socket:timeout(3)
      err = socket:send(str1..strchar(13, 10))
      while not err do
         line, err = socket:receive("*l")
         if (line ~= "" and strsub(line, 1, 1) ~= "%" and strsub(line,strlen(line),strlen(line)) ~= strchar(124)) then
            msg = msg.."\t"..line.."\r\n"
         end
         if line == "" then
            count = count + 1
            if count == 2 then
               break
            end
         else
            count = 0
         end
      end
      socket:close()
      if msg ~= "\r\n" then
         msg = msg.."\r\n\t"..WhoisText2.."...\r\n"
         SendToUser(curUser,"\r\n"..msg)
      else
         SendToUser(curUser,WhoisText3)
      end
   else
      SendToUser(curUser,"Server: "..Database.." = "..OfflineText..".")
   end
end

thanks
Title: request
Post by: gemini on 27 May, 2005, 17:40:28
request zright clicker for whois script functionally  
thanks
Title:
Post by: TTB on 27 May, 2005, 17:43:13
Sockets are not (yet) supported in LUA5! Converting not possible!