PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: jiten on 25 August, 2004, 12:23:00

Title: trigger control
Post by: jiten on 25 August, 2004, 12:23:00
is it possible to control this kind of triggers (one or more symbols in between the words)?
for example, the name of the hub is "ptzone" and ppl advert it like:

- P.....T....Z....O....N...E
- P::::T::::Z::::O::::N::::E
- P****T****Z****O****N*****E

can someone make some changes in this code to check those trigs?

code:

BotName = "?bot?"

advtrigs = {"hub" }

controltrigs={["hub"]=1,["ptzone"]=2}

validtrigs = {"none"}

tabAdvert = {}
supervip = {}
fSuperVip = "logs/svip.txt"   

function Main()
   frmHub:RegBot(BotName)
   SetTimer(60000)
   StartTimer()
end

function OnTimer()
   for key, value in tabAdvert do
      if (tabAdvert[key].iClock > clock()+60) then
         tabAdvert[key]=nil
      end
   end
end

function DataArrival(user, data)
   if not user.bOperator then
      LoadFromFile(fSuperVip)
      if strsub(data, 1, 1) == "<" then
         local _, _, msg = strfind(data, "^%b<>%s+(.*)|")
         if Verify(user.sName, msg) then
            local Lines = Verify(user.sName, msg)
            tabAdvert = nil
            tabAdvert = {}
            local s,e,onlymes = strfind(data, "%b<> (.*)")
            catch=strsub(user.sName,1,14)
            if catch=="'??SemiDeus??'" then                  
            else
               SendPmToOps (BotName,"Report: <"..user.sName.."> ("..user.sIP..") is advertising in main: "..msg)
               SendToVips("Report: <"..user.sName.."> ("..user.sIP..") is advertising in main: "..msg)
               user:SendPM(BotName,"Advertising Censored. Sorry.")
            end
            return 1
         end
         for key, value in controltrigs do
            if( strfind( strlower(data), key) ) then
               s,e,onlymes = strfind(data, "%b<> (.*)")
               SendPmToOps (BotName, "Control: <"..user.sName.."> ("..user.sIP..") told in main: "..onlymes.."")
               SendToVips("Report: <"..user.sName.."> ("..user.sIP..") is advertising in main: "..onlymes)
            end
         end

         spam=0
         if( strfind( strlower(data), "no",1,1) ) and ( strfind( strlower(data), "ip.",1,1) ) then
            if ( strfind( strlower(data), "com",1,1) ) or ( strfind( strlower(data), "org",1,1) ) or ( strfind( strlower(data), "info",1,1) ) then
         spam=spam+1; end; end;

         if( strfind( strlower(data), "dns",1,1) ) and ( strfind( strlower(data), "2",1,1) ) and ( strfind( strlower(data), "go",1,1) ) then
         spam=spam+1; end

         if( strfind( strlower(data), "dy",1,1) ) and ( strfind( strlower(data), "nu",1,1) ) then
            if( strfind( strlower(data), ".net",1,1) ) or ( strfind( strlower(data), ".com",1,1) ) then
         spam=spam+1;end; end

         if( strfind( strlower(data), "d n s a",1,1) ) or ( strfind( strlower(data), "d n s .",1,1) ) or ( strfind( strlower(data), "d n s 2",1,1) ) or ( strfind( strlower(data), "o d s .",1,1) ) or ( strfind( strlower(data), "d y n",1,1) ) then
         spam=spam+1;end


      elseif strsub(data, 1, 4) == "$To:" then
         local _, _, to, from, msg = strfind(data, "^%$To:%s+(%S+)%s+From:%s+(%S+)%s-%$%b<>%s+(.*)|")
         local nick = GetItemByName(to)
         if not user.bOperator then
            local userdata = to.." "..from
            if Verify(userdata, msg) then
               local Lines = Verify(userdata, msg)
               tabAdvert = nil
               tabAdvert = {}
               local s,e,whoTo,from,mes = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(.*)")  
               if catch=="['??SemiDeus??']" then
               else
                  SendPmToOps (BotName,"Report: <"..user.sName.."> ("..user.sIP..") said in PVT this: "..msg)
                  SendToVips("Report: <"..user.sName.."> ("..user.sIP..") is advertising in PVT: "..msg)
                  user:SendPM(BotName,"Advertising Censored. Sorry.")
               end
               return 1
            end
            for key, value in controltrigs do
               if( strfind( strlower(data), key) ) then
                  s,e,whoTo,from,mes = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(.*)")  
                  SendPmToOps (BotName, "Control: <"..user.sName.."> ("..user.sIP..") said in PVT this: "..mes.."")
                  SendToVips("Report: <"..user.sName.."> ("..user.sIP..") is advertising in PVT: "..mes)
               end
            end

            spam=0
            if( strfind( strlower(data), "no",1,1) ) and ( strfind( strlower(data), "ip.",1,1) ) then
               if ( strfind( strlower(data), "com",1,1) ) or ( strfind( strlower(data), "org",1,1) ) or ( strfind( strlower(data), "info",1,1) ) then
            spam=spam+1; end; end;

            if( strfind( strlower(data), "dns",1,1) ) and ( strfind( strlower(data), "2",1,1) ) and ( strfind( strlower(data), "go",1,1) ) then
            spam=spam+1; end
   
            if( strfind( strlower(data), "dy",1,1) ) and ( strfind( strlower(data), "nu",1,1) ) then
               if( strfind( strlower(data), ".net",1,1) ) or ( strfind( strlower(data), ".com",1,1) ) then
            spam=spam+1;end; end
   
            if( strfind( strlower(data), "d n s a",1,1) ) or ( strfind( strlower(data), "d n s .",1,1) ) or ( strfind( strlower(data), "d n s 2",1,1) ) or ( strfind( strlower(data), "o d s .",1,1) ) or ( strfind( strlower(data), "d y n",1,1) ) then
            spam=spam+1;end
      
         end
      end
   end
end

function Verify(userdata, msg)
   if not msg then return end
   tmp =""
   gsub(strlower(msg), "([a-z0-9.:%-])", function(x) tmp = tmp..x end)
   if not tabAdvert[userdata] then
      tabAdvert[userdata] = { iClock = clock(), l1 = "", l2 = "", l3 = "", l4= "", l5= "",l6= "",l7= "",l8= "",l9 = tmp}
   else
      tabAdvert[userdata].iClock = clock()
      tabAdvert[userdata].l1 = tabAdvert[userdata].l2
      tabAdvert[userdata].l2 = tabAdvert[userdata].l3
      tabAdvert[userdata].l3 = tabAdvert[userdata].l4
      tabAdvert[userdata].l4 = tabAdvert[userdata].l5
      tabAdvert[userdata].l5 = tabAdvert[userdata].l6
      tabAdvert[userdata].l6 = tabAdvert[userdata].l7
      tabAdvert[userdata].l7 = tabAdvert[userdata].l8
      tabAdvert[userdata].l8 = tabAdvert[userdata].l9
      tabAdvert[userdata].l9 = tmp
   end
   local Lines = tabAdvert[userdata].l1..tabAdvert[userdata].l2..tabAdvert[userdata].l3..tabAdvert[userdata].l4..tabAdvert[userdata].l5..tabAdvert[userdata].l6..tabAdvert[userdata].l7..tabAdvert[userdata].l8..tabAdvert[userdata].l9
   for key, value in advtrigs do
      if (strfind(Lines, strlower(value), 1, 1)) then
         for key2, value2 in validtrigs do
            if (strfind(Lines, strlower(value2), 1, 1)) then
               return nil
            end
         end
         return 1
      end
   end
end

function LoadFromFile(file)
   if (readfrom(file) ~= nil) then
      readfrom(file)
      dostring(read("*all"))
      readfrom()
   end
end

function SendToVips(msg)
   local usr,aux
   for usr, aux in supervip do
      if (GetItemByName(usr) ~= nil) then
         GetItemByName(usr):SendPM(BotName, msg)
      end
   end
end
Title:
Post by: nErBoS on 25 August, 2004, 14:41:47
Hi,

Try to search for NightLitch anti-pub in the Finished Scripts section. It will solve that i believe.

Best regards, nErBoS