hi
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

hi

Started by gizmo, 13 March, 2005, 17:22:37

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

gizmo

is there someone who can convert this to lua5 because its not working with the new ptokax version =(

BotName = "-Yoda-"

kb = 1024
mb = kb*kb
gb = kb*kb*kb

redirect = {}
redirect[1] = {adress = "blabla1.myftp.org", minshare = 130*gb, maxhubs  = 50, minslots = 0}
redirect[2] = {adress = "blabla2.myftp.org", minshare = 100*gb, maxhubs  = 50, minslots = 0}
redirect[3] = {adress = "blabla3.myftp.org", minshare = 60*gb, maxhubs  = 50, minslots = 0}
redirect[4] = {adress = "blabla4.myftp.org", minshare = 45*gb, maxhubs  = 50, minslots = 0}
redirect[5] = {adress = "blabla5.myftp.org", minshare = 20*gb, maxhubs  = 50, minslots = 0}
redirect[6] = {adress = "blabla6.myftp.org", minshare = 5*gb, maxhubs  = 50, minslots = 0}
redirect["RedirectNMDC"] = "bla.mine.nu"
redirect["NetworkRedir"] = "blabla.mine.nu"
redirect["RedirectMLDC"] = "bla.mine.nu"
redirect["Notwanted"] = "bla.mine.nu"

sec = 1000
min = sec*60
h = min*60

tRedirectedusers = {}

function Main()
   frmHub:RegBot(BotName)
   SetTimer(15*min)
   StartTimer()
end

function NewUserConnected(curUser)
   if tRedirectedusers[curUser.sName] and tRedirectedusers[curUser.sName] >= 5 then
      local RedirectAddress = redirect["Notwanted"]
      curUser:SendData(BotName, "You have been redirected too many times and have therfore been redirected to: "..RedirectAddress)
      curUser:SendData("$ForceMove "..RedirectAddress.."|")
      curUser:TimeBan(30)
   else
      local p,d,tempdesc = strfind(curUser.sMyInfoString, "<%+%+ (%S*)>%$")
      if not tempdesc then
         if curUser.sIP == "127.0.0.1" then
            return
         elseif strfind(curUser.sMyInfoString, "mld",1,1) then
            SendToOps(BotName , "*** MLDC REDIR: "..redirect["RedirectMLDC"].." User: "..curUser.sName)
            curUser:SendData(BotName, "You are running mldc. Mldc isnt allowed, you are being redirected.")
            curUser:SendData("$ForceMove "..redirect["RedirectMLDC"].."|")
            tRedirectedusers[curUser.sName] = 5
            curUser:TimeBan(1)
            if curUser then
               curUser:Disconnect()
            end
            return
         else

            local i,j,temp = strfind(curUser.sMyInfoString, "$(%d+)%$")
            local tempshare = tonumber(temp)
            if tempshare then
               local Share = format("%0.2f", tempshare/gb)
               SendToOps(BotName , "*** NMDC REDIR: "..redirect["RedirectNMDC"].."  Share: "..Share.."Gb User "..curUser.sName)
            else
               local _,_,Share = strfind( curUser.sMyInfoString, "^%$MyINFO %$ALL [^ ]+ [^$]*%$ $[^$]+[^$]%$[^$]*%$%s*(%d+)%$" )
               if Share then
                  Share = tonumber(Share)
                  if Share then
                     local Share = format("%0.2f", Share/gb)
                     SendToOps(BotName , "*** NMDC REDIR: "..redirect["RedirectNMDC"].."  Share: "..Share.."Gb User "..curUser.sName)
                  else
                     SendToOps(BotName , "*** NMDC REDIR: "..redirect["RedirectNMDC"].."  Share: *unknown* User "..curUser.sName)
                  end
               else
                  SendToOps(BotName , "*** NMDC REDIR: "..redirect["RedirectNMDC"].."  Share: *unknown* User "..curUser.sName)
               end
            end
            curUser:SendData(BotName, "not running a dc++ client, you are being redirected to our NMDC hub.")
            curUser:SendData("$ForceMove "..redirect["RedirectNMDC"].."|")
            tRedirectedusers[curUser.sName] = 5
            curUser:TimeBan(1)
            return
         end
      end

      local i,j,temp = strfind(curUser.sMyInfoString, "$(%d+)%$")
      local tempshare = tonumber(temp)
      if not tempshare then
         SendToOps(BotName , "*** Notwanted REDIR: "..redirect["Notwanted"].." User: "..curUser.sName.." Because: couldn't decide the share size")
         curUser:SendData(BotName, "Couldn't detect your share size so you are being redirected.")
         curUser:SendData("$ForceMove "..redirect["Notwanted"].."|")
         tRedirectedusers[curUser.sName] = 5
         curUser:TimeBan(1)
         return
      end

      --  V:0.25,M:A,H:1/1/1,S:5 ...

      -- get nr of hubs
      local p,d,th1,th2,th3 = strfind(tempdesc,"H:(%d+)/(%d+)/(%d+),")
      local temphubs = 0
      if p then
         temphubs = tonumber(th1)+tonumber(th2)+tonumber(th3)
      else
         p,d,th = strfind(tempdesc,"H:(%d+)")
         if p then
            temphubs = tonumber(th)
         else
            SendToOps(BotName , "*** Notwanted REDIR: "..redirect["Notwanted"].." User: "..curUser.sName.." Because: couldn't decide how many hubs.")
            curUser:SendData(BotName, "Couldn't detect how many hub you where visiting so you are being redirected.")
            curUser:SendData("$ForceMove "..redirect["Notwanted"].."|")
            tRedirectedusers[curUser.sName] = 5
            curUser:TimeBan(1)
            return
         end
      end
      if temphubs == 0 then
         SendToOps(BotName , "*** Notwanted REDIR: "..redirect["Notwanted"].." User: "..curUser.sName.." Because: couldn't decide how many hubs.")
         curUser:SendData(BotName, "Couldn't detect how many hub you where visiting so you are being redirected.")
         curUser:SendData("$ForceMove "..redirect["Notwanted"].."|")
         tRedirectedusers[curUser.sName] = 5
         curUser:TimeBan(1)
         return
      end

      -- get nr of slots
      local p,d,ts = strfind(tempdesc,"S:(%d+)")
      local tempslots = 0
      if p then
         tempslots = tonumber(ts)
      else
         SendToOps(BotName , "*** Notwanted REDIR: "..redirect["Notwanted"].." User: "..curUser.sName.." Because: couldn't decide how many slots.")
         curUser:SendData(BotName, "Couldn't detect how many slots you got so you are being redirected.")
         curUser:SendData("$ForceMove "..redirect["Notwanted"].."|")
         tRedirectedusers[curUser.sName] = 5
         curUser:TimeBan(1)
         return
      end
      if tempslots == 0 then
         SendToOps(BotName , "*** Notwanted REDIR: "..redirect["Notwanted"].." User: "..curUser.sName.." Because: couldn't decide how many slots.")
         curUser:SendData(BotName, "Couldn't detect how many slots you got so you are being redirected.")
         curUser:SendData("$ForceMove "..redirect["Notwanted"].."|")
         tRedirectedusers[curUser.sName] = 5
         curUser:TimeBan(1)
         return
      end

      local redirected = 0
      local i = 1
      local RedirectAddress  = ""
      while 1 do
         if not redirect then
            break
         elseif tempshare >= redirect["minshare"] then
            if temphubs <= redirect["maxhubs"] then
               if temphubs*redirect["minslots"] <= tempslots then
                  RedirectAddress = redirect["adress"]
                  redirected = 1
                  break
               end
            end
         end
         i = i + 1
      end

      local Share = format("%0.2f", tonumber(tempshare)/gb)
      if redirected == 0 then
         curUser:SendData(BotName, "You are sharing "..Share.."Gb")
         curUser:SendData(BotName, "You are in "..temphubs.." hubs")
         curUser:SendData(BotName, "You have "..tempslots.." slots open")
         curUser:SendData(BotName, "You do not meet the requirements in any of our hubs, redirecting to next network.")
         
                        curUser:SendData("$ForceMove "..redirect["NetworkRedir"].."|")
         if tRedirectedusers[curUser.sName] then
            tRedirectedusers[curUser.sName] = tRedirectedusers[curUser.sName] + 1
         else
            tRedirectedusers[curUser.sName] = 1
         end
         SendToOps(BotName , "*** NETWORKREDIR: "..redirect["NetworkRedir"].."  Share: "..Share.."Gb Hubs:"..temphubs.." Slots:"..tempslots.."  User: "..curUser.sName.." redirected: "..tRedirectedusers[curUser.sName].." times")
         curUser:TimeBan(1)
      else
         curUser:SendData(BotName, "You are sharing "..Share.."Gb")
         curUser:SendData(BotName, "You are in "..temphubs.." hubs")
         curUser:SendData(BotName, "You have "..tempslots.." slots open")
         curUser:SendData(BotName, "This means that you should be in hub "..RedirectAddress.." ... Redirecting.")
         curUser:SendData("$ForceMove "..RedirectAddress.."|")
         if tRedirectedusers[curUser.sName] then
            tRedirectedusers[curUser.sName] = tRedirectedusers[curUser.sName] + 1
         else
            tRedirectedusers[curUser.sName] = 1
         end
         SendToOps(BotName , "*** REDIR: "..RedirectAddress.."  Share: "..Share.."Gb Hubs:"..temphubs.." Slots:"..tempslots.."  User: "..curUser.sName.." redirected: "..tRedirectedusers[curUser.sName].." times")
         curUser:TimeBan(1)
      end
   end
end

function OnTimer()
   tRedirectedusers = {}
end


SMF spam blocked by CleanTalk