PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: Ubikk on 21 May, 2005, 12:56:30

Title: converting some little scripts part2 :)
Post by: Ubikk on 21 May, 2005, 12:56:30
Hello again :)

These are the remaining scripts that i need to convert to lua 5  8)


Firste one:


QuoteBotName = "robotzel"
SeenTrigger = "!seen"


minLen = 2

maxLen = 50

seenArray={}



function Main()

frmHub:RegBot(BotName)

end



function NewUserConnected(curUser)

local boolDisc = 0

if strlen(curUser.sName) < minLen then

curUser:SendPM(BotName, "Your nick is to short, a minimum of "..minLen.." chars is required!")

curUser:SendPM(BotName, "Disconnecting...")

curUser:Disconnect()

boolDisc = 1

elseif strlen(curUser.sName) > maxLen then

curUser:SendPM(BotName, "Your nick is to long, a maximum of "..maxLen.." chars is required!")

curUser:SendPM(BotName, "Disconnecting...")

curUser:Disconnect()

boolDisc = 1

elseif ( strfind (curUser.sName, " ", 1, 1) ) then

curUser:SendPM(BotName, " fara spatii libere pt nickname uri ;)")

curUser:SendPM(BotName, "Disconnecting...")

curUser:Disconnect()

boolDisc = 1

end

if (boolDisc == 0) then

seenArray[strlower(curUser.sName)]=date(curUser.sName.." s-a conectat la ora %d/%m/%Y %T si inca mai este printre noi :)")

end

end



function OpConnected(curUser)

seenArray[strlower(curUser.sName)]=date(curUser.sName.." a intrat pe hub la ora %d/%m/%Y %T si inca mai pierde vremea pe aici :)")

end



function OpDisconnected(curUser)

seenArray[strlower(curUser.sName)]=date(curUser.sName.." ne-a parasit la ora %d/%m/%Y %T ... imi pare atat de rau :_( ")

end



function UserDisconnected(curUser)

seenArray[strlower(curUser.sName)]=date(curUser.sName.." a plecat la ora %d/%m/%Y %T ... deja ti-e dor? :)")

end



function DataArrival(curUser, data)

seenArray[strlower(curUser.sName)]=date(curUser.sName.." a fost vazut(a) ultima oara la %d/%m/%Y %T frecand menta :P")

if( strsub(data, 1, 1) == "<" ) then

data=strsub(data,1,strlen(data)-1)

_,_,cmd,arg = strfind( data, "%b<>%s+(%S+)%s+(%S+)" )

if (cmd == SeenTrigger) then

if (strlower(arg) == strlower(curUser.sName)) then

SendToAll(BotName, " iar te-ai pierdut, "..arg.." ? :D" )

elseif (seenArray[strlower(arg)] ~= nil) then

SendToAll(BotName, "User: "..seenArray[strlower(arg)] )

else

SendToAll(BotName, " nush, eu nu l-am zarit inca pe "..arg.." ... du-te si intreaba pe altcineva :)" )

end

end

end

end


That's a very useful script  :rolleyes:

And the last one:


Quote-- TrickerBot2.lua, created by Ptaczek Dec-24, 2002
-- Just see how to implement the NMDC TriggerBot in LUA :)   
-- changes
-- Feb-24, 2003, v2.0 Modification for DataArrival return value.
-- Tiny changes by VidFamne with lot of help by Piglja
-- VidFamne added Pigljas time-function, and some more trigs
-- A bug-fix by VidFamne, hopefully. And added some more triggs ;)
-- A new bug-fix ( for the "!me-command" ) by VidFamne, added ( 09.04.2003 ).
-- Added MatrixX On/Off function. Just type +quiet in mainchat to stop the Bot,
-- and +talk to start the Bot again. By VidFamne ( 05.05.2003 )
-- Bug-fix by [AF]Mike

botname = "robotzel"

trigall=1

trigs = {
             


         ["lol"]={
     "Yeah, [CURUSER] ... Hahahaha .. :P",
     "Hmmmm... lol si eu :D",
     "huh? [CURUSER]  ce-i asa de amuzant ?",
     ":D",
     "incepe sa-mi placa de tine [CURUSER] ... razi cam des :)"           
             
   }


function Main()
frmHub:RegBot(botname)
end

function DataArrival(curUser, data)

status=strsub(data,1,strlen(data)-1)
-- parse the command
s,e,cmd = strfind( status, "%b<>%s+(%S+)" )

if (cmd=="!st") then
trigall=0
SendToAll(botname, " ok.. promit sa fiu cuminte :( ")
return 1
elseif (cmd=="!go") then
trigall=1
SendToAll(botname, " guess who's back? >:)")
return 1
end

       
   if( strsub(data, 1, 1) == "<" ) then
      -- get the msg only using regular expression
      s,e,msg = strfind(data, "%b<>([%a ]+)")                                        
      -- look in the table
                if trigall==1 then
      for key, value in trigs do
                for key2, value2 in value do
                     
   if( strfind( strlower(msg), key) ) then
                 else break  
   end

        if( strfind( strlower(msg), "!me") ) then
                  t="**"..curUser.sName
                  data=gsub (msg, "!me", t, 1 )
   end

      SendToAll( data ) -- send the original data
                   
            SetTimer(1800)
                  StartTimer()
      answer, x = gsub(value[random(1,getn(value))], "%b[]", curUser.sName)

   return 1; -- tell the hub we have processed the data
   end
   end  
   end
end

function OnTimer()
   SendToAll( botname, answer ) -- send bot's answer
   StopTimer()
end
end

I removed all the triggs from this script except the first one to save up space :)

I would really apreciate if someone would help me with all this scripts. They're very small and i don't think they require so much work.  :D

Thank you for your time  8)
Title:
Post by: Dessamator on 21 May, 2005, 13:02:13
for the first script, use nl's lua4 to 5 converter , for the second one, click my signature on my link!
Title:
Post by: Ubikk on 21 May, 2005, 13:12:16
Thanks a lot for the fast reply my friend :)
Oh, i also forgot this little one :)

Quote--ScreenCleaner.lua 1.1 by yepyepyep4711 and Hawk
--!cls will wipe the main chat clean (does that remind you of something? ;) )
--the command will be added to the rightclick menu of the OPs (optional)



botname = "robotzel"

rightclick = 0 -- if anything else than 1 rightclick menu won't appear

function DataArrival (curUser, sData)
command=strsub(sData,1,strlen(sData)-1)
s,e,cmd = strfind(command,"%b<>%s+(%S+)")
   if curUser.bOperator then
      if cmd=="!cls" then
         temp = "\r\n"
         for i=1,200,1 do
            temp = temp.."\r\n"
         end
         SendToAll(botname, temp)
      end
   end

        if curUser.bVip then
      if cmd=="!cls" then
         temp = "\r\n"
         for i=1,200,1 do
            temp = temp.."\r\n"
         end
         SendToAll(botname, temp)
      end
   end
end



function OpConnected(curUser)
   if rightclick == 1 then
      curUser:SendData("$UserCommand 255 7")
      curUser:SendData("$UserCommand 0 3")
      curUser:SendData("$UserCommand 1 2 Clear Screen$<%[mynick]> !cls|")
   end
end

Title:
Post by: blackwings on 21 May, 2005, 13:38:22
here you go = --ScreenCleaner.lua 1.1 by yepyepyep4711 and Hawk
--!cls will wipe the main chat clean (does that remind you of something? ;) )
--the command will be added to the rightclick menu of the OPs (optional)
--converted & more compact by blackwings


botname = "robotzel"

rightclick = 0 -- if anything else than 1 rightclick menu won't appear

function ChatArrival (curUser, sData)
command=string.sub(sData,1,string.len(sData)-1)
s,e,cmd = string.find(command,"%b<>%s+(%S+)")
if curUser.bOperator or curUser.bVip then
if cmd=="!cls" then
temp = "\r\n"
for i=1,200,1 do
temp = temp.."\r\n"
end
SendToAll(botname, temp)
end
end
end

function OpConnected(curUser)
if rightclick == 1 then
curUser:SendData("$UserCommand 255 7")
curUser:SendData("$UserCommand 0 3")
curUser:SendData("$UserCommand 1 2 Clear Screen$<%[mynick]> !cls|")
end
end
Title:
Post by: 6Marilyn6Manson6 on 21 May, 2005, 14:06:48
QuoteOriginally posted by blackwings
here you go = --ScreenCleaner.lua 1.1 by yepyepyep4711 and Hawk
--!cls will wipe the main chat clean (does that remind you of something? ;) )
--the command will be added to the rightclick menu of the OPs (optional)
--converted & more compact by blackwings


botname = "robotzel"

rightclick = 0 -- if anything else than 1 rightclick menu won't appear

function ChatArrival (curUser, sData)
command=string.sub(sData,1,string.len(sData)-1)
s,e,cmd = string.find(command,"%b<>%s+(%S+)")
if curUser.bOperator or curUser.bVip then
if cmd=="!cls" then
temp = "\r\n"
for i=1,200,1 do
temp = temp.."\r\n"
end
SendToAll(botname, temp)
end
end
end

function OpConnected(curUser)
if rightclick == 1 then
curUser:SendData("$UserCommand 255 7")
curUser:SendData("$UserCommand 0 3")
curUser:SendData("$UserCommand 1 2 Clear Screen$<%[mynick]> !cls|")
end
end



This script don't clear really mainchat but send 200lines of button "sending" ;)
Title:
Post by: Ubikk on 21 May, 2005, 14:11:23
yes i know :)

Is there another way of clearing the mainchat? :P
Title:
Post by: 6Marilyn6Manson6 on 21 May, 2005, 14:19:55
QuoteOriginally posted by Ubikk
yes i know :)

Is there another way of clearing the mainchat? :P

mm i don't things exist other Clear MainChat but you can change line 17

to:

for i=1,200,1 do
in:

for i=1,20000,1 do
and you sending 20000 lines and not 200 :P
Title:
Post by: blackwings on 21 May, 2005, 14:20:26
QuoteOriginally posted by Ubikk
yes i know :)

Is there another way of clearing the mainchat? :P
I dont think so.
Title:
Post by: blackwings on 21 May, 2005, 14:21:59
QuoteOriginally posted by 6Marilyn6Manson6
and you sending 20000 lines and not 200 :P
500 should be enough ;)
Title:
Post by: 6Marilyn6Manson6 on 21 May, 2005, 14:27:09
QuoteOriginally posted by blackwings
QuoteOriginally posted by 6Marilyn6Manson6
and you sending 20000 lines and not 200 :P
500 should be enough ;)
yeah :)
Title:
Post by: Ubikk on 21 May, 2005, 15:29:43
i've added 400, thanks :)
Title:
Post by: ??????Hawk?????? on 21 May, 2005, 17:00:56


--ScreenCleaner.lua 1.1 by yepyepyep4711 and ??????Hawk??????
--!cls will wipe the main chat clean (does that remind you of something? ;) )
--the command will be added to the rightclick menu of the OPs (optional)
--converted & more compact by blackwings


botname = "robotzel"

rightclick = 0 -- if anything else than 1 rightclick menu won't appear

function ChatArrival (curUser, sData)
command=string.sub(sData,1,string.len(sData)-1)
s,e,cmd = string.find(command,"%b<>%s+(%S+)")
if curUser.bOperator or curUser.bVip then
if cmd=="!cls" then
SendToAll(botname, string.rep("\r\n", 10000))
end
end
end

function OpConnected(curUser)
if rightclick == 1 then
curUser:SendData("$UserCommand 255 7")
curUser:SendData("$UserCommand 0 3")
curUser:SendData("$UserCommand 1 2 Clear Screen$<%[mynick]> !cls|")
end
end

rid that Ugly Loop...  lol
Title:
Post by: Dessamator on 21 May, 2005, 17:52:16
hmm, indeed much more clean , :)
Title:
Post by: Ubikk on 22 May, 2005, 10:57:49
10000 lines? You must be joking :)
it takes the bot 3 seconds to clear the screan.. at least with 400 lines the process is done instantly :P