PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: Devastator on 10 January, 2004, 20:31:46

Title: Download Gag
Post by: Devastator on 10 January, 2004, 20:31:46
Hey,

i was wonderin if sum1 could make a stand alone download gag script so that misbehaving users can get punished.

i would like this script because for users it would be a dire punishment instead of being kicked.

if someone can make that it would be excellent

thank u

Devastator
Title:
Post by: Intel on 10 January, 2004, 21:55:57
This Should Work
Try it ...

[code]
BotName =  "-Download-Blocker-"

--Txts--
Gags = "gags.txt"

--Txts--
   
function Main()
frmHub:RegBot(BotName)
frmHub:EnableFullData(1)
end
function GetArgsPm(sdata)
   local _,_, arg1 = strfind(sdata,"$To:%s+%S+%s+From:%s+%S+%s+$%S+%s+%S+%s+(%d+.%d+.%d+.%d+)")
return arg1
end
function GetArgsMain(sdata)
   local _,_, arg2 = strfind(sdata,"%s+%S+%s+(%d+.%d+.%d+.%d+)")
return arg2
end      
function DataArrival(curUser,sdata)
if strsub(sdata,1,12) == "$ConnectToMe" then
         local _,_, From,ToIp = strfind(sdata,"$ConnectToMe%s+(%S+)%s+(%d+.%d+.%d+.%d+):.*")         
               readfrom(Gags)               
   while 1 do
      local line = read()
      
      if line then         
         ip = strsub(line, strfind(line, "|") + 1)
         if ip == ToIp then
         return 1         
         end
         

      else      
         break
      end
   end
end

   readfrom()             
if (strsub(sdata,1,4) == "$To:") or strfind(sdata,"<")  then
   sdata = strsub(sdata,1,-2)
   local _,_,   check,command = strfind(sdata,"$To:+%s+(%S+)%s+From:+%s+%S+%s+$+%S+%s+(%S+)")
   local _,_,   command = strfind(sdata,"%b<>%s+(%S+)")      
   if (check == BotName) or (strsub(sdata,1,1) ~= "$")  then      
   
--commandes--

if curUser.bOperator then
if (command=="!addgag") then
SendAddGag(curUser,sdata)
return 1
elseif (command=="!delgag") then
SendDelGag(curUser,sdata)
return 1
elseif (command=="!getgag") then
SendGetGag(curUser,sdata)
return 1
end
end
end
end
end

--commandes--

   function SendAddGag(curUser,sdata)
      if strsub(sdata,1,4) == "$To:" then
      arg1=GetArgsPm(sdata)
      else
      arg1=GetArgsMain(sdata)      
      end
      if arg1~=nil then
       appendto(Gags)
         write("-|"..arg1.."\r\n")
         writeto()
         SendToOps(BotName,"Ipt "..arg1.." canr connect too any one")
         else
         curUser:SendData(BotName,"Command is !addgag ..")
         end
      
end
      function  SendDelGag(curUser,sdata)   
         writeto(Gags)      
         write("-|Gags ips.\r\n")
         writeto()
         curUser:SendPM(BotName,"Download gag list is delited!")

         end         
         function SendGetGag(curUser)
            readfrom(Gags)
            local message = ""
            while 1 do
            local line = read()
            if (line == nil) then  break  else   
            message = message.."\r\nIps gagged "..gsub(line,"-|"," @ ")..""
            end
            end
            curUser:SendPM(BotName,message)
         end   


[\CODE]
Title:
Post by: c h i l l a on 10 January, 2004, 22:40:11
not bad intel,
Only thing is one also needs to block the RevConnectToMe.

plus reading out a file one each ConnectToMe is quite disk intense, okey, depending on the filesize.. well anyways, a nonassocciative table where you have added the curUser.sName  is a bit better in the performance. If you wanted to block ceratain IP's then, I would also only check the curUser.sIP if it matches a IP in the table. Dunno just keep trying.

Keep goin' intel
Title:
Post by: Intel on 11 January, 2004, 12:52:53
Hi Chilla, Could then make the Modified part and repost it... it would be very nice
Title:
Post by: Spyro on 11 January, 2004, 13:10:03
The PtokaX has the !gag command. Why don?t you just use that one ?
Title:
Post by: c h i l l a on 11 January, 2004, 14:39:02
Spyro its a chat gag command.

Intel, I don't think it will help, I think plop is right it won't help, if I code it for you, but if you look at phattie's How To's you will find all info you need, and most of it is already in your script, so happy coding.
Title:
Post by: Tuben on 11 January, 2004, 18:22:48
It is not Intel that have done that script ;))
It is meeeee ;)))))
Hehe.
Dosnt mather .
Title:
Post by: Intel on 11 January, 2004, 22:30:36
Its Not me who Coded It, Its Tuben I think, But I understand the Script now, soon I will repost the modified part :) Unless Tuben is faster than me :P
Title:
Post by: plop on 12 January, 2004, 00:18:37
QuoteOriginally posted by Intel
Its Not me who Coded It, Its Tuben I think, But I understand the Script now, soon I will repost the modified part :) Unless Tuben is faster than me :P
still post it no mather tuben is faster or not.
you can only learn from it and thats a good thing.
and i always like 2 see multiple scripts doing the same thing, it can show diferent ways of doing things.

plop
Title:
Post by: Tuben on 12 January, 2004, 10:59:29
I dont code scripts any more..;))