PtokaX forum

Archive => Archived 5.0 boards => Finished Scripts => Topic started by: jiten on 16 March, 2005, 18:25:52

Title: Clever Janinha
Post by: jiten on 16 March, 2005, 18:25:52
----------------------------------------------------
-- code:

-- modded to LUA 5 by jiten and dessamator (some killing :P)
-- Ideas taken from tezlo's retrobot and MultiTimer by OpiumVolage (19/06/2003)
---------------------------------------------------------------

Bot = "Janine"  
botname = "?bot?"

tabTimers = {n=0}

Sec  = 1000
Min  = 60*Sec
Hour = 60*Min
Day  = 24*Hour

TmrFreq = 1*Sec

 trigs = {  
   filme="Filmes? oohh [USER], chega de filmes dramaticos, assiste la algo com acc?o :D!",  
   cinema="Oba oba, cinema, vamos assistir o RAMBO, mas [USER], tu pagas! ",  
   jantar="oooh [USER], eu ja jantei mas n?o te preocupes deixei os restos pra ti, :D" ,
   raiva="Tas com raiva, vai para guerra precisam d gajos como tu la",  
   slots="slots?, vou te dar so se beijares meus pes!!!!",  
   sono="Sono, ? isso que da, passas toda noite a roubar carros, e depois reclamas",  
   fome="Fome?, tenho 1 dica para ti, pc n?o alimenta , vai la COMER! ",
   porca="Hey [USER], leva a tua porca e vao la banhar, t?o a fazer o hub cheirar mal,:P",  
      xau="arriverdeci [USER]",  
      cya="We told him to go away, and away he goes Precious, goone... goone... goone..., Janinha is FREEEEE",  
      foda="[USER], so pensas nisso, tas frustado ou o que?",  
      janinha="OOH [USER],? obvio que n?o tou interesada em ti, tenta outra!!!!",    
      adeus="adi?s [USER]!",  
      adios="cya [USER]",
      virus="virus?, queres infectar-me, tsk, tou a ser protegida pelo (K.V.A) Kanimambo Virus Annihilator v.10000!",      
      ["cala te"]="cala-te, cala-te, cala-te. Grande parvoide, depois vais reclamar que n?o se fala nada",
      ["alguem tem"]="hmm, talvez sim , talvez n?o, procure e descobre sozinho(a)",  
      ["algum op"]="Ops, sao aqueles com chaves nos nicks, tenta hablar(falar) com eles no pvt!",  
      ["firewall"]="hmm, voces ainda usam isso, evoluem la, usem o LAZERWALL, e melhor!",
      ["bug"]="damn, Insectos aqui deixa la ir buscar o meu tanque!",  
      ["quem tem"]="ooh [USER],olhe pra cima, e tente usar o Search(lupa)! ",  
      ["Ol?"]= "hola [USER]!",  
      ["hola"]="?hola usuario, es usted un var?n o una hembra?",
      ["bon jour"]= "bonjour [USER], tout bien?",
      ["good morning"] = "Gooood Morning [USER]!!",
      ["wazzup"] ="WAZZZZZZZZZZZZZZZZZZUHHHH :P ",
}  
 
idlequestions = {  
"This place looks like a grave,did the Grim Reaper pass by ?",
"Ta mesmo morto isto, hmm, restou algum 'zombie'?",
"Hmm, parece que o Bin Laden fez bem o seu trabalho, espantou todo mundo do main chat",  
"Ai ai ai, ta mau isto, houve 1 attake nuclear por aqui e ninguem me contou?!",  
"Hmm, anybody there?...(doesnt seem so). At last the main is mine all mine!,hehe :D ",  
"Onde ta o ppl?, morreram todos e foram parar na casa mortuaria?",
"Iih, isto ta t?o silencioso, sera que ate fantasmas tem medo de passar por aqui?",
"Sera que todos fofokeiros t?o nos pvts?",
"Damn, a minha beleza espantou o ppl?",
"Bonjour mes ami, tout bien?",
"?Hola los usuarios queridos, c?mo son usted?",
"Ziss place is Cursed!!",
"Quem mandou 1 peido e espantou os users??",
"Quem ? o Fedorento que espantou os Hubbers(users)",
"Come out, come out, Wherever u are !",
}  
 
idleanswers = {  
"Ate que enfim [USER], conseguiste parar de bater 1 ..., pra bater 1 papo!",  
"Hmm, [USER]!, o sobrevivente do attake do Bin laden, ",  
"Wow, [USER],attakes nucleares n?o devem afectar-te(deves ser 1 barata) ",  
"Damn, there goes the neighbourhood, the main is no longer mine!, :|",  
"Ate que enfim, voltaste[USER], tua casa de banho ja deve tar a cheirar mal!",
"Hmm, [USER], vejo que escapaste da casa mortuaria",
"[USER], Ja acabou a Fofoca?",
"[USER], Vieste confirmar se sou 1 beleza ou n?o? claro q sou!! , :P",
"Bonjour [USER]",
"hola [USER]",
"Do not attempt to adjust the monitor, I CONTROL the transmission, mwuhahaha",
"Pikaboooo, I C U!",
}  
 
idlemorninganswers = {  
"Welcome back to the land of the living, [USER]!",  
"Iiiih, tens mau halito va la escovar os dentes, :P" ,
"Hmm, acordaste e ja tas aqui?, ? obvio que sonhaste comigo, :P",
"Iiih, ainda nem lavaste a cara e ja tas aqui?"
}  
 
idlemorning = {  
"Good Morning ,Buenos dias, bom dia, e bon jour, mes amis!",  
"Ent?o quem ta aqui pra parlar comigo?",
"Arise puny Mortals and Greet your Goddess Janinha" ,
"Are All creatures in the Underworld?"
}  
 
idleevening = {  
"Bonne nuit !!",
"Ta cheio de medrosos neste hub, fugiram todos do ''boogie man''",
"It Seems the sandman came early today",  
"Hmm, isto ta t?o silencioso que ate da pra ouvir os grilos",
}  
 
idleeveninganswers = {  
"Buonas noches,[USER] ",
"Hmm, ent?o [USER], que fazes nesta bela noite , bater 1 ... batuke? " ,
"It seems the Sandman didnt visit you, [USER]",
}  
---- TRIGS END-----
sec = 1000  
min = 60 * sec  
hour = 60 * min  
 
index = nil  

------------------------------MAIN FUNCTION ------------------------
function Main()  
frmHub:RegBot(botname)
quiet = "false"  
talk = "allow"  
WaitingForAnswerAfterQuiet = "false"  
WaitingForAnswerMorning = "false"  
WaitingForAnswerEvening = "false"  

--timerS
RegTimer(TrigAnswer, 1*sec)
RegTimer(idlechat, 30*min)
SetTimer(TmrFreq)
StartTimer()
--
end  
----------------------------------------------------------------------

 
-- Pm events --
function ToArrival(user,data)
if(string.sub(data, 1, 4) == "$To:") then
data=string.sub(data,1,string.len(data)-1)
s,e,whoTo = string.find(data,"$To:%s+(%S+)")
if (whoTo == botname) then
s,e,whoTo,from,cmd = string.find(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")
if (user.bOperator) then

if (cmd=="!bico") then
chatcheck(stuff,4)
SendToAll(Bot, "Remember my words,"..user.sName..", ill be BACK!  ")
end

if (cmd=="!fala") then
chatcheck(stuff,3)
SendToAll(Bot, "Guess whos back, back again, no its not slim, its Janinha !!!!... :o)")
end
end
end
end
end
 
-- Main Chat events --  
function ChatArrival(user,data)
data=string.sub(data,1,string.len(data)-1)  
  s,e,cmd = string.find( data, "%b<>%s+(%S+)" )  
s,e,mess = string.find(data, "%b<> ([%w ]*)")  
 
-- Trigs Answers --  
for key, value in trigs do  

-- Answer to mess command if bot is allowed to speak --  
if mess or cmd and talk == "allow" then  

-- Answer to the trig, with 1 trig response, if bot wasn't quiet since a while --  
if WaitingForAnswerAfterQuiet == "false" then  
if( string.find( string.lower(mess), key) ) or ( string.find( string.lower(cmd), key) ) then  
answer, x = string.gsub(value, "%b[]", user.sName)  

--Bot answers after the trig not b4, 1 sec delay !
StopTimer()
StartTimer() -- restarting timer , to allow idlechat
break  
end  
end  
end  
end  
 
-- Restart the timer each time someone is talking on the main chat, if bot is allowed to talk --  
if mess or cmd then  
if talk == "allow" then  
  if iscommand(cmd) or iscommand(mess) then  
else  
StopTimer()  
StartTimer()  
end  
end  
end  
 
-- Quiet the bot (ops command) --  
if (cmd=="!bico") then  
if user.bOperator then  
chatcheck(stuff,4)
SendToAll(Bot, "Epa vou cuidar da minha vida, ate mais logo, seus improductivos !!")  
return 1
else  

-- Answer if a user try to use the command !quiet and if it is allowed to talk - then, check if the bot was quiet or not before --  

if talk == "allow" and WaitingForAnswerAfterQuiet == "false" then  
SendToAll(Bot,"hahaha, You dont have the cojones to shut me up!!!!")  
return 1
end  
end  
end  
 
-- Allow the bot to talk (ops command) --  
 
if (cmd=="!fala") then  
if user.bOperator then  
chatcheck(stuff,3)
SendToAll(Bot, "Your Queen Janinha is back, worship me you foul mortals !!!")  
return 1
else  
 
-- Answer if a user try to use the command !talk and if it is allowed to talk - then, check if the bot was quiet or not before --  
 
if talk == "allow" and WaitingForAnswerAfterQuiet == "false" then  
SendToAll(Bot, "Ohh user tu n?o podes mandar me falar(no cojones)")  
return 1
end  
end  
end  
 
-- Receiving entries on the main chat --  
 
if cmd or mess then  
if talk == "allow" then  
 
-- Morning Answer --  
if WaitingForAnswerMorning == "true" then  
 
-- Ignore the line commands begining with '+'/'!'/'#'/'?'.
 
if iscommand(cmd) or iscommand(mess) then  
else  

-- Answer to chat entries --  
chatcheck(idlemorninganswers, 2)
answer, x = string.gsub(idlemorninganswers[index], "%b[]", user.sName)  
end  
end  
 
-- Evening Answer --  
if WaitingForAnswerEvening == "true" then  
 
-- Ignore the line commands begining with '+'/'!'/'#'/'?'.
 
if iscommand(cmd) or iscommand(mess) then  
else  
 
-- Answer to chat entries --  
chatcheck(idleeveninganswers, 2)
answer, x = string.gsub(idleeveninganswers[index], "%b[]", user.sName)  
end  
end  
 
-- Answer after the bot was too quiet --  
 
if WaitingForAnswerAfterQuiet == "true" then  
 
-- Ignore the line commands begining with '+'/'!'/'#'/'?'. Bot won't replye - nicest, i think... :o) --  
 
if iscommand(cmd) or iscommand(mess) then  
else  
 
-- Answer to chat entries --  
chatcheck(idleanswers, 2)
answer, x = string.gsub(idleanswers[index], "%b[]", user.sName)  
end  
end  
end  
end  
end  
 
function idlechat()  
time()  
--trig = "notdone"  
 
-- Idle trigs, for the morning, and the evening :o) --  
 
if H=="09" then  
chatcheck(idlemorning, 1)
WaitingForAnswerMorning = "true"  
WaitingForAnswerEvening = "false"  

 
elseif H=="19" then  
chatcheck(idleevening, 1)
WaitingForAnswerMorning = "false"  
WaitingForAnswerEvening = "true"  
 
-- Others idle trigs --  
 
else --if trig == "notdone" then  
index = math.random(1,table.getn(idlequestions))  
SendToAll(Bot, idlequestions[index])  
WaitingForAnswerAfterQuiet = "true"  
end  
end
 
-- Get Time --  
 
function time()  
S = os.date("%S")  
H = os.date("%H")  
M = os.date("%M")  
D = os.date("%d")  
MM = os.date("%m")  
Y = os.date("%y")  
return H  
end  
 
function iscommand(str)  
return string.sub(str, 1, 1) == "!" or string.sub(str, 1, 1) == "?" or string.sub(str, 1, 1) == "+" or string.sub(str, 1, 1) == "#"  
end

--Timer Functions--
function TrigAnswer()
if not(answer== "") then
SendToAll(Bot, answer )
answer=""
end
end

function OnTimer()
for i=1, table.getn(tabTimers) do
tabTimers[i].count = tabTimers[i].count + 1
if tabTimers[i].count > tabTimers[i].trig then
tabTimers[i].count=1
tabTimers[i]:func()
end
end
end

function RegTimer(f, Interval)
local tmpTrig = Interval / TmrFreq
assert(Interval >= TmrFreq , "RegTimer(): Please Adjust TmrFreq")
local Timer = {n=0}
Timer.func=f
Timer.trig=tmpTrig
Timer.count=1
table.insert(tabTimers, Timer)
end

-- Timer Functions--------


function chatcheck(stuff, option)

if option ==1 then

-- check for idle main chat at 09:00 and 19:00
index = math.random(1,table.getn(stuff))  
SendToAll(Bot, stuff[index])  
StartTimer()  
WaitingForAnswerAfterQuiet = "false"  
trig = "done"  

elseif option ==2 then

-- Answer after the bot was too quiet --  
index = math.random(1,table.getn(stuff))  
killrepetition()

elseif option==3 then

-- allow bot to talk
talk = "allow"  
quiet = "false"  
StartTimer()
killrepetition()

elseif option ==4 then

-- shutup bot
quiet = "true"
talk = "notallow"
WaitingForAnswerAfterQuiet = "true"
StopTimer()
end
end

function killrepetition()
WaitingForAnswerAfterQuiet = "false"  
WaitingForAnswerMorning = "false"  
WaitingForAnswerEvening = "false"
end
Title:
Post by: jiten on 23 March, 2005, 09:31:44
Fixed some bugs with the idleanswers and idlequestions.
First post edited.

Best regards,

jiten
Title:
Post by: BeeR on 23 March, 2005, 15:53:08
QuoteOriginally posted by jiten
Fixed some bugs with the idleanswers and idlequestions.
First post edited.

Best regards,

jiten

hi ,,
is it possible to speed up the answers on this bot ??
the delay feels little to long when users chat ,,
Title:
Post by: jiten on 23 March, 2005, 16:26:16
Try this one:

----------------------------------------------------
-- code:

-- modded to LUA 5 by jiten and dessamator (some killing :P)
-- Ideas taken from tezlo's retrobot and MultiTimer by OpiumVolage (19/06/2003)
---------------------------------------------------------------

Bot = "Janinha"  
botname = "?bot?"

tabTimers = {n=0}

Mil = 1
Sec  = 1000
Min  = 60*Sec
Hour = 60*Min
Day  = 24*Hour

TmrFreq = 1*Mil

 trigs = {  
   filme="Filmes? oohh [USER], chega de filmes dramaticos, assiste la algo com acc?o :D!",  
   cinema="Oba oba, cinema, vamos assistir o RAMBO, mas [USER], tu pagas! ",  
   jantar="oooh [USER], eu ja jantei mas n?o te preocupes deixei os restos pra ti, :D" ,
   raiva="Tas com raiva, vai para guerra precisam d gajos como tu la",  
   slots="slots?, vou te dar so se beijares meus pes!!!!",  
   sono="Sono, ? isso que da, passas toda noite a roubar carros, e depois reclamas",  
   fome="Fome?, tenho 1 dica para ti, pc n?o alimenta , vai la COMER! ",
   porca="Hey [USER], leva a tua porca e vao la banhar, t?o a fazer o hub cheirar mal,:P",  
      xau="arriverdeci [USER]",  
      cya="We told him to go away, and away he goes Precious, goone... goone... goone..., Janinha is FREEEEE",  
      foda="[USER], so pensas nisso, tas frustado ou o que?",  
      janinha="OOH [USER],? obvio que n?o tou interesada em ti, tenta outra!!!!",    
      adeus="adi?s [USER]!",  
      adios="cya [USER]",
      virus="virus?, queres infectar-me, tsk, tou a ser protegida pelo (K.V.A) Kanimambo Virus Annihilator v.10000!",      
      ["cala te"]="cala-te, cala-te, cala-te. Grande parvoide, depois vais reclamar que n?o se fala nada",
      ["alguem tem"]="hmm, talvez sim , talvez n?o, procure e descobre sozinho(a)",  
      ["algum op"]="Ops, sao aqueles com chaves nos nicks, tenta hablar(falar) com eles no pvt!",  
      ["firewall"]="hmm, voces ainda usam isso, evoluem la, usem o LAZERWALL, e melhor!",
      ["bug"]="damn, Insectos aqui deixa la ir buscar o meu tanque!",  
      ["quem tem"]="ooh [USER],olhe pra cima, e tente usar o Search(lupa)! ",  
      ["Ol?"]= "hola [USER]!",  
      ["hola"]="?hola usuario, es usted un var?n o una hembra?",
      ["bon jour"]= "bonjour [USER], tout bien?",
      ["good morning"] = "Gooood Morning [USER]!!",
      ["wazzup"] ="WAZZZZZZZZZZZZZZZZZZUHHHH :P ",
}  
 
idlequestions = {  
"This place looks like a grave,did the Grim Reaper pass by ?",
"Ta mesmo morto isto, hmm, restou algum 'zombie'?",
"Hmm, parece que o Bin Laden fez bem o seu trabalho, espantou todo mundo do main chat",  
"Ai ai ai, ta mau isto, houve 1 attake nuclear por aqui e ninguem me contou?!",  
"Hmm, anybody there?...(doesnt seem so). At last the main is mine all mine!,hehe :D ",  
"Onde ta o ppl?, morreram todos e foram parar na casa mortuaria?",
"Iih, isto ta t?o silencioso, sera que ate fantasmas tem medo de passar por aqui?",
"Sera que todos fofokeiros t?o nos pvts?",
"Damn, a minha beleza espantou o ppl?",
"Bonjour mes ami, tout bien?",
"?Hola los usuarios queridos, c?mo son usted?",
"Ziss place is Cursed!!",
"Quem mandou 1 peido e espantou os users??",
"Quem ? o Fedorento que espantou os Hubbers(users)",
"Come out, come out, Wherever u are !",
}  
 
idleanswers = {  
"Ate que enfim [USER], conseguiste parar de bater 1 ..., pra bater 1 papo!",  
"Hmm, [USER]!, o sobrevivente do attake do Bin laden, ",  
"Wow, [USER],attakes nucleares n?o devem afectar-te(deves ser 1 barata) ",  
"Damn, there goes the neighbourhood, the main is no longer mine!, :|",  
"Ate que enfim, voltaste[USER], tua casa de banho ja deve tar a cheirar mal!",
"Hmm, [USER], vejo que escapaste da casa mortuaria",
"[USER], Ja acabou a Fofoca?",
"[USER], Vieste confirmar se sou 1 beleza ou n?o? claro q sou!! , :P",
"Bonjour [USER]",
"hola [USER]",
"Do not attempt to adjust the monitor, I CONTROL the transmission, mwuhahaha",
"Pikaboooo, I C U!",
}  
 
idlemorninganswers = {  
"Welcome back to the land of the living, [USER]!",  
"Iiiih, tens mau halito va la escovar os dentes, :P" ,
"Hmm, acordaste e ja tas aqui?, ? obvio que sonhaste comigo, :P",
"Iiih, ainda nem lavaste a cara e ja tas aqui?"
}  
 
idlemorning = {  
"Good Morning ,Buenos dias, bom dia, e bon jour, mes amis!",  
"Ent?o quem ta aqui pra parlar comigo?",
"Arise puny Mortals and Greet your Goddess Janinha" ,
"Are All creatures in the Underworld?"
}  
 
idleevening = {  
"Bonne nuit !!",
"Ta cheio de medrosos neste hub, fugiram todos do ''boogie man''",
"It Seems the sandman came early today",  
"Hmm, isto ta t?o silencioso que ate da pra ouvir os grilos",
}  
 
idleeveninganswers = {  
"Buonas noches,[USER] ",
"Hmm, ent?o [USER], que fazes nesta bela noite , bater 1 ... batuke? " ,
"It seems the Sandman didnt visit you, [USER]",
}  
---- TRIGS END-----
mil = 1
sec = 1000  
min = 60 * sec  
hour = 60 * min  
 
index = nil  

------------------------------MAIN FUNCTION ------------------------
function Main()  
frmHub:RegBot(botname)
quiet = "false"  
talk = "allow"  
WaitingForAnswerAfterQuiet = "false"  
WaitingForAnswerMorning = "false"  
WaitingForAnswerEvening = "false"  

--timerS
RegTimer(TrigAnswer, 1*mil)
RegTimer(idlechat, 30*min)
SetTimer(TmrFreq)
StartTimer()
--
end  
----------------------------------------------------------------------

 
-- Pm events --
function ToArrival(user,data)
if(string.sub(data, 1, 4) == "$To:") then
data=string.sub(data,1,string.len(data)-1)
s,e,whoTo = string.find(data,"$To:%s+(%S+)")
if (whoTo == botname) then
s,e,whoTo,from,cmd = string.find(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")
if (user.bOperator) then

if (cmd=="!bico") then
chatcheck(stuff,4)
SendToAll(Bot, "Remember my words,"..user.sName..", ill be BACK!  ")
end

if (cmd=="!fala") then
chatcheck(stuff,3)
SendToAll(Bot, "Guess whos back, back again, no its not slim, its Janinha !!!!... :o)")
end
end
end
end
end
 
-- Main Chat events --  
function ChatArrival(user,data)
data=string.sub(data,1,string.len(data)-1)  
  s,e,cmd = string.find( data, "%b<>%s+(%S+)" )  
s,e,mess = string.find(data, "%b<> ([%w ]*)")  
 
-- Trigs Answers --  
for key, value in trigs do  

-- Answer to mess command if bot is allowed to speak --  
if mess or cmd and talk == "allow" then  

-- Answer to the trig, with 1 trig response, if bot wasn't quiet since a while --  
if WaitingForAnswerAfterQuiet == "false" then  
if( string.find( string.lower(mess), key) ) or ( string.find( string.lower(cmd), key) ) then  
answer, x = string.gsub(value, "%b[]", user.sName)  

--Bot answers after the trig not b4, 1 sec delay !
StopTimer()
StartTimer() -- restarting timer , to allow idlechat
break  
end  
end  
end  
end  
 
-- Restart the timer each time someone is talking on the main chat, if bot is allowed to talk --  
if mess or cmd then  
if talk == "allow" then  
  if iscommand(cmd) or iscommand(mess) then  
else  
StopTimer()  
StartTimer()  
end  
end  
end  
 
-- Quiet the bot (ops command) --  
if (cmd=="!bico") then  
if user.bOperator then  
chatcheck(stuff,4)
SendToAll(Bot, "Epa vou cuidar da minha vida, ate mais logo, seus improductivos !!")  
return 1
else  

-- Answer if a user try to use the command !quiet and if it is allowed to talk - then, check if the bot was quiet or not before --  

if talk == "allow" and WaitingForAnswerAfterQuiet == "false" then  
SendToAll(Bot,"hahaha, You dont have the cojones to shut me up!!!!")  
return 1
end  
end  
end  
 
-- Allow the bot to talk (ops command) --  
 
if (cmd=="!fala") then  
if user.bOperator then  
chatcheck(stuff,3)
SendToAll(Bot, "Your Queen Janinha is back, worship me you foul mortals !!!")  
return 1
else  
 
-- Answer if a user try to use the command !talk and if it is allowed to talk - then, check if the bot was quiet or not before --  
 
if talk == "allow" and WaitingForAnswerAfterQuiet == "false" then  
SendToAll(Bot, "Ohh user tu n?o podes mandar me falar(no cojones)")  
return 1
end  
end  
end  
 
-- Receiving entries on the main chat --  
 
if cmd or mess then  
if talk == "allow" then  
 
-- Morning Answer --  
if WaitingForAnswerMorning == "true" then  
 
-- Ignore the line commands begining with '+'/'!'/'#'/'?'.
 
if iscommand(cmd) or iscommand(mess) then  
else  

-- Answer to chat entries --  
chatcheck(idlemorninganswers, 2)
answer, x = string.gsub(idlemorninganswers[index], "%b[]", user.sName)  
end  
end  
 
-- Evening Answer --  
if WaitingForAnswerEvening == "true" then  
 
-- Ignore the line commands begining with '+'/'!'/'#'/'?'.
 
if iscommand(cmd) or iscommand(mess) then  
else  
 
-- Answer to chat entries --  
chatcheck(idleeveninganswers, 2)
answer, x = string.gsub(idleeveninganswers[index], "%b[]", user.sName)  
end  
end  
 
-- Answer after the bot was too quiet --  
 
if WaitingForAnswerAfterQuiet == "true" then  
 
-- Ignore the line commands begining with '+'/'!'/'#'/'?'. Bot won't replye - nicest, i think... :o) --  
 
if iscommand(cmd) or iscommand(mess) then  
else  
 
-- Answer to chat entries --  
chatcheck(idleanswers, 2)
answer, x = string.gsub(idleanswers[index], "%b[]", user.sName)  
end  
end  
end  
end  
end  
 
function idlechat()  
time()  
--trig = "notdone"  
 
-- Idle trigs, for the morning, and the evening :o) --  
 
if H=="09" then  
chatcheck(idlemorning, 1)
WaitingForAnswerMorning = "true"  
WaitingForAnswerEvening = "false"  

 
elseif H=="19" then  
chatcheck(idleevening, 1)
WaitingForAnswerMorning = "false"  
WaitingForAnswerEvening = "true"  
 
-- Others idle trigs --  
 
else --if trig == "notdone" then  
index = math.random(1,table.getn(idlequestions))  
SendToAll(Bot, idlequestions[index])  
WaitingForAnswerAfterQuiet = "true"  
end  
end
 
-- Get Time --  
 
function time()  
S = os.date("%S")  
H = os.date("%H")  
M = os.date("%M")  
D = os.date("%d")  
MM = os.date("%m")  
Y = os.date("%y")  
return H  
end  
 
function iscommand(str)  
return string.sub(str, 1, 1) == "!" or string.sub(str, 1, 1) == "?" or string.sub(str, 1, 1) == "+" or string.sub(str, 1, 1) == "#"  
end

--Timer Functions--
function TrigAnswer()
if not(answer== "") then
SendToAll(Bot, answer )
answer=""
end
end

function OnTimer()
for i=1, table.getn(tabTimers) do
tabTimers[i].count = tabTimers[i].count + 1
if tabTimers[i].count > tabTimers[i].trig then
tabTimers[i].count=1
tabTimers[i]:func()
end
end
end

function RegTimer(f, Interval)
local tmpTrig = Interval / TmrFreq
assert(Interval >= TmrFreq , "RegTimer(): Please Adjust TmrFreq")
local Timer = {n=0}
Timer.func=f
Timer.trig=tmpTrig
Timer.count=1
table.insert(tabTimers, Timer)
end

-- Timer Functions--------


function chatcheck(stuff, option)

if option ==1 then

-- check for idle main chat at 09:00 and 19:00
index = math.random(1,table.getn(stuff))  
SendToAll(Bot, stuff[index])  
StartTimer()  
WaitingForAnswerAfterQuiet = "false"  
trig = "done"  

elseif option ==2 then

-- Answer after the bot was too quiet --  
index = math.random(1,table.getn(stuff))  
killrepetition()

elseif option==3 then

-- allow bot to talk
talk = "allow"  
quiet = "false"  
StartTimer()
killrepetition()

elseif option ==4 then

-- shutup bot
quiet = "true"
talk = "notallow"
WaitingForAnswerAfterQuiet = "true"
StopTimer()
end
end

function killrepetition()
WaitingForAnswerAfterQuiet = "false"  
WaitingForAnswerMorning = "false"  
WaitingForAnswerEvening = "false"
end
Title:
Post by: BeeR on 12 April, 2005, 17:49:19
QuoteOriginally posted by jiten
Fixed some bugs with the idleanswers and idlequestions.
First post edited.

Best regards,

jiten
Hi jiten
runs clever janinha on PX 16.09 and there is something weird
------------------------------MAIN FUNCTION ------------------------
function Main()  
frmHub:RegBot(botname)
quiet = "false"  
talk = "allow"  
WaitingForAnswerAfterQuiet = "false"  
WaitingForAnswerMorning = "false"  
WaitingForAnswerEvening = "false"  

--timerS
   RegTimer(TrigAnswer, 1*mil)
   RegTimer(idlechat, 30*min) <-- every min is in realtime 15min
   SetTimer(TmrFreq)
   StartTimer()
--
end  
----------------------------------------------------------------------
2 min = 30min ,, weird :]
but it works as long i can see
Title:
Post by: Dessamator on 12 April, 2005, 18:50:56
QuoteOriginally posted by BeeR
QuoteOriginally posted by jiten
Fixed some bugs with the idleanswers and idlequestions.
First post edited.

Best regards,

jiten
Hi jiten
runs clever janinha on PX 16.09 and there is something weird
------------------------------MAIN FUNCTION ------------------------
function Main()  
frmHub:RegBot(botname)
quiet = "false"  
talk = "allow"  
WaitingForAnswerAfterQuiet = "false"  
WaitingForAnswerMorning = "false"  
WaitingForAnswerEvening = "false"  

--timerS
   RegTimer(TrigAnswer, 1*mil)
   RegTimer(idlechat, 30*min) <-- every min is in realtime 15min
   SetTimer(TmrFreq)
   StartTimer()
--
end  
----------------------------------------------------------------------
2 min = 30min ,, weird :]
but it works as long i can see

theres an error there it should be ::

RegTimer(idlechat, 30*Min)

instead of
RegTimer(idlechat, 30*min)

the "M" should b in upper case
Title:
Post by: jiten on 12 April, 2005, 20:28:30
Well, Dessamator has given you the response  ;)

Btw, I modded the script so that it looks more like the Lua 4 version one.
I suppose it's way less buggy than the firsts I posted and with time i'll optimize it.

Here it goes:
----------------------------------------------------
-- Clever Janinha v1.0 (more Lua4 alike)

-- modded to LUA 5 by jiten and dessamator (some killing :P)

-- Ideas taken from:
-- Thks to Ptaczek for his TrickerBot.lua
-- Thks to Skrollster, for the math.random synthax ([URL]http://lua.bcs-solutions.de/thread.php?t...2a4078fa73ba6be[/URL])
-- Thks to MatrixX for some help, too... ([URL]http://lua.bcs-solutions.de/thread.php?t...f4cc&page=2[/URL])
-- And thks to the others, for their help... ;o)
-- seNsi: the 'clever' Bot :p
---------------------------------------------------------------


Bot = "Janinha"
botname = "?bot?"

trigs = {
   filme="Filmes? oohh [USER], chega de filmes dramaticos, assiste la algo com accao :D!",
   cinema="Oba oba, cinema, vamos assistir o RAMBO, mas [USER], tu pagas! ",
   jantar="oooh [USER], eu ja jantei mas n?o te preocupes deixei os restos pra ti, :D" ,
   raiva="Tas com raiva, vai para guerra precisam d gajos como tu la",
   slots="hmm, queres slots, quanto pagas por cada?",
   sono="Sono, ? isso que da, passas toda noite a roubar carros, e depois reclamas",
   fome="Fome?, tenho 1 dica para ti, pc n?o alimenta , vai la COMER! ",
   porca="Hey [USER], leva a tua porca e vao la banhar, t?o a fazer o hub cheirar mal,:P",
      xau="arriverdeci [USER]",
      asta="asta la vista [USER]",
      cya="We told him to go away, and away he goes Precious, goone... goone... goone..., Janinha is FREEEEE",
      foda="[USER], so pensas nisso, tas frustado ou o que?",
      janinha="Eu sei que sou irresistivel, mas n?o te quero, tenta outra!",
      adeus="adi?s [USER]!",
      virus="virus?, queres infectar-me, tsk, tou a ser protegida pelo (K.V.A) Kanimambo Virus Annihilator v.10000!",    
      ["cala te"]="cala-te, cala-te, cala-te. Grande parvoide, depois vais reclamar que n?o se fala nada",
      ["alguem tem"]="hmm, talvez sim , talvez n?o, procure e descobre sozinho(a)",
      ["algum op"]="Ops, sao aqueles com chaves nos nicks, tenta hablar(falar) com eles no pvt!",
      ["firewall"]="hmm, voces ainda usam isso, evoluem la, usem o LAZERWALL, e melhor!",
      ["bug"]="damn, Insectos aki deixa la ir buscar minha bazooka!",  
      ["quem tem"]="ooh [USER],Tente usar o Search (lupa que ta la em cima)! ",
      ["Ol?"]= "hola [USER]!",
      ["hola"]="?hola usuario, es usted un var?n o una hembra?",
      ["sup"]= "Aloha [USER]!",
      ["bon jour"]= "bonjour [USER], tout bien?",
      ["good morning"] = "Gooood Morning [USER]!!",
      ["wazzup"] ="WAZZZZZZZZZZZZZZZZZZUHHHH :P ",
      ["kanimambo"] = "hmm, o que queres com meu marido?",
      killer="O que queres com o ze grand BIG CHEESE? hein? j? agora, onde est? ele? hum.... vendo scrubs?",
}

idlequestions = {
"This place looks like a grave,did the Grim Reaper pass by ?",
"Ta mesmo morto isto, hmm, restou algum 'zombie'?",
"Hmm, parece que o Bin Laden fez bem o seu trabalho, espantou todo mundo do main chat",
"Ai ai ai, ta mau isto, houve 1 attake nuclear por aqui e ninguem me contou?!",
"Hmm, anybody there?...(doesnt seem so). At last the main is mine all mine!,hehe :D ",
"Onde ta o ppl?, morreram todos e foram parar na casa mortuaria?",
"Iih, isto ta t?o silencioso, sera que ate fantasmas tem medo de passar por aqui?",
"Sera que todos fofokeiros t?o nos pvts?",
"Damn, a minha beleza espantou o ppl?",
"Bonjour mes ami, tout bien?",
"?Hola los usuarios queridos, c?mo son usted?",
"Ziss place is Cursed!!",
"Quem mandou 1 peido e espantou os users??",
"Quem ? o Fedorento que espantou os Hubbers(users)",
"Come out, come out, Wherever u are !",
}

idleanswers = {
"Ate que enfim [USER], conseguiste parar de bater 1 ..., pra bater 1 papo!",
"Hmm, [USER]!, o sobrevivente do attake do Bin laden, ",
"Wow, [USER],attakes nucleares n?o devem afectar-te(deves ser 1 barata) ",
"Damn, there goes the neighbourhood, the main is no longer mine!, :|",
"Ate que enfim, tua casa de banho ja deve tar a cheirar mal!",
"Hmm, [USER], vejo que escapaste da casa mortuaria",
"[USER], Ja acabou a Fofoca?",
"[USER], Vieste confirmar se sou 1 beleza ou n?o? claro q sou!! , :P",
"Bonjour [USER]",
"hola [USER]",
"Do not attempt to adjust the monitor, I CONTROL the transmission, mwuhahaha",
"Pikaboooo, I C U!",
}

idlemorninganswers = {
"Welcome back to the land of the living, [USER]!",
"Iiiih, tens mau halito va la escovar os dentes, :P" ,
"Hmm, acordaste e ja tas aqui?, ? obvio que sonhaste comigo, :P",
"Iiih, ainda nem lavaste a cara e ja tas aqui?"
}

idlemorning = {
"Good Morning ,Buenos dias, bom dia, e bon jour, mes amis!",
"Ent?o quem ta aqui pra parlar comigo?",
"Arise puny Mortals and Greet your Goddess Janinha" ,
"Are All creatures in the Underworld?"
}

idleevening = {
"Bonne nuit !!",
"Ta cheio de medrosos neste hub, fugiram todos do ''boogie man''",
"It Seems the sandman came early today",
"Hmm, isto ta t?o silencioso que ate da pra ouvir os grilos",
}

idleeveninganswers = {
"Buonas noches,[USER] ",
"Hmm, ent?o [USER], que fazes nesta bela noite , bater 1 ... batuke? " ,
"It seems the Sandman didnt visit you, [USER]",
}

sec = 1000
min = 60 * sec
hour = 60 * min

index = nil

function Main()
frmHub:RegBot(botname)
quiet = "false"
talk = "allow"
WaitingForAnswerAfterQuiet = "false"
WaitingForAnswerMorning = "false"
WaitingForAnswerEvening = "false"
SetTimer(30*min)
StartTimer()
end

function ToArrival(user, data)
data=string.sub(data,1,string.len(data)-1)
s,e,whoTo = string.find(data,"$To:%s+(%S+)")
if (whoTo == botname) then
s,e,whoTo,from,cmd = string.find(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")
if (user.bOperator) then
if (cmd=="!bico") then
quiet = "true"
talk = "notallow"
StopTimer()
SendToAll(Bot, "Remember my words,"..user.sName..", ill be BACK!  ")
end
if (cmd=="!fala") then
talk = "allow"
quiet = "false"
WaitingForAnswerAfterQuiet = "false"
WaitingForAnswerMorning = "false"
WaitingForAnswerEvening = "false"
StartTimer()
SendToAll(Bot, "Guess whos back, back again, no its not slim, its Janinha !!!!... :o)")
end
end
end
end

function ChatArrival(user, data)
data=string.sub(data,1,string.len(data)-1)
s,e,cmd = string.find( data, "%b<>%s+(%S+)" )
s,e,mess = string.find(data, "%b<> ([%w ]*)")

-- Trigs Answers --
for key, value in trigs do
-- Answer to mess command if bot is allowed to speak --
if mess or cmd and talk == "allow" then
-- Answer to the trig, with 1 trig response, if bot wasn't quiet since a while --
if WaitingForAnswerAfterQuiet == "false" then
if( string.find( string.lower(mess), key) ) or ( string.find( string.lower(cmd), key) ) then
SendToAll(user.sName, mess)
answer, x = string.gsub(value, "%b[]", user.sName)
SendToAll(Bot, answer )
return 1
end
end
end

end

-- Restart the timer each time someone is talking on the main chat, if bot is allowed to talk --
if mess or cmd then
if talk == "allow" then
if iscommand(cmd) or iscommand(mess) then
else
StopTimer()
StartTimer()
end
end
end

-- Quiet the bot (ops command) --
if (cmd=="!bico") then
if user.bOperator then
quiet = "true"
talk = "notallow"
SendToAll(Bot, "Remember my words,"..user.sName..", ill be BACK!  ")
StopTimer()
else
-- Answer if a user try to use the command !quiet and if it is allowed to talk - then, check if the bot was quiet or not before --
if talk == "allow" and WaitingForAnswerAfterQuiet == "false" then
SendToAll(Bot,"hahaha, You dont have the cojones to shut me up!!!!")
end
end
return 1
end

-- Allow the bot to talk (ops command) --
if (cmd=="!fala") then
if user.bOperator then
talk = "allow"
quiet = "false"
WaitingForAnswerAfterQuiet = "false"
WaitingForAnswerMorning = "false"
WaitingForAnswerEvening = "false"
StartTimer()
SendToAll(Bot, "Yiiiiiisa, Voltei!!")
else
-- Answer if a user try to use the command !talk and if it is allowed to talk - then, check if the bot was quiet or not before --
if talk == "allow" and WaitingForAnswerAfterQuiet == "false" then
SendToAll(Bot, "Ohh user tu n?o podes mandar me falar(no cojones)")
end
end
return 1
end

-- Receiving entries on the main chat --
if cmd or mess then
if talk == "allow" then
-- Morning Answer --
if WaitingForAnswerMorning == "true" then
-- Ignore the line commands begining with '+'/'!'/'#'/'?'. Bot won't replye - nicest, i think... :o) --
if iscommand(cmd) or iscommand(mess) then
else
-- Answer to chat entries --
SendToAll(user.sName, mess)
index = math.random(1,table.getn(idlemorninganswers))
answer, x = string.gsub(idlemorninganswers[index], "%b[]", user.sName)
SendToAll(Bot, answer)
WaitingForAnswerAfterQuiet = "false"
WaitingForAnswerMorning = "false"
WaitingForAnswerEvening = "false"
return 1
end
end

-- Evening Answer --
if WaitingForAnswerEvening == "true" then
-- Ignore the line commands begining with '+'/'!'/'#'/'?'. Bot won't replye - nicest, i think... :o) --
if iscommand(cmd) or iscommand(mess) then
else
-- Answer to chat entries --
SendToAll(user.sName, mess)
index = math.random(1,table.getn(idleeveninganswers))
answer, x = string.gsub(idleeveninganswers[index], "%b[]", user.sName)
SendToAll(Bot, answer)
WaitingForAnswerAfterQuiet = "false"
WaitingForAnswerMorning = "false"
WaitingForAnswerEvening = "false"
return 1
end
end

-- Answer after the bot was too quiet --
if WaitingForAnswerAfterQuiet == "true" then
-- Ignore the line commands begining with '+'/'!'/'#'/'?'. Bot won't replye - nicest, i think... :o) --
if iscommand(cmd) or iscommand(mess) then
else
-- Answer to chat entries --
SendToAll(user.sName, mess)
index = math.random(1,table.getn(idleanswers))
answer, x = string.gsub(idleanswers[index], "%b[]", user.sName)
SendToAll(Bot, answer)
WaitingForAnswerAfterQuiet = "false"
WaitingForAnswerMorning = "false"
WaitingForAnswerEvening = "false"
return 1
end
end
end
end
end

function OnTimer()
time()
trig = "notdone"

-- Idle trigs, for the morning, and the evening :o) --
if H=="09" then
SendToAll(user.sName, mess)
index = math.random(1,table.getn(idlemorning))
SendToAll(Bot, idlemorning[index])
WaitingForAnswerAfterQuiet = "false"
WaitingForAnswerMorning = "true"
WaitingForAnswerEvening = "false"
StartTimer()
trig = "done"
return 1
end

if H=="19" then
SendToAll(user.sName, mess)
index = math.random(1,table.getn(idleevening))
SendToAll(Bot, idleevening[index])
WaitingForAnswerAfterQuiet = "false"
WaitingForAnswerMorning = "false"
WaitingForAnswerEvening = "true"
StartTimer()
trig = "done"
return 1
end

-- Others idle trigs --
if trig == "notdone" then
SendToAll(Bot, mess)
index = math.random(1,table.getn(idlequestions))
SendToAll(Bot, idlequestions[index])
WaitingForAnswerAfterQuiet = "true"
return 1
end
end

-- Get Time --

function time()
S = os.date("%S")
H = os.date("%H")
M = os.date("%M")
D = os.date("%d")
MM = os.date("%m")
Y = os.date("%y")
return H
end

function iscommand(str)
return string.sub(str, 1, 1) == "!" or string.sub(str, 1, 1) == "?" or string.sub(str, 1, 1) == "+" or string.sub(str, 1, 1) == "#"
end

Cheers
Title:
Post by: BeeR on 12 April, 2005, 20:59:29
theres an error there it should be ::


code:--------------------------------------------------------------------------------RegTimer(idlechat, 30*Min) --------------------------------------------------------------------------------


instead of

code:--------------------------------------------------------------------------------RegTimer(idlechat, 30*min) --------------------------------------------------------------------------------


the "M" should b in upper case

sorry to say this but i have already test that and there is no differens in the timer (idlechat)

i give jitens new bot a try :]
Title:
Post by: johny on 21 April, 2005, 17:03:15
hmm wierd, i get this error

Syntax D:\Robocop 10.01c\scripts\Talking-Xena2.lua5.lua:467: attempt to index global `user' (a nil value)

script part is:
-- Others idle trigs --
if trig == "notdone" then
SendToAll(user.sName, mess)
index = math.random(1,table.getn(idlequestions))
SendToAll(Bot, idlequestions[index])
WaitingForAnswerAfterQuiet = "true"
return 1
end

any idee what coold be wrong??
Title:
Post by: jiten on 21 April, 2005, 17:08:54
Just change:
SendToAll(user.sName, mess)

to
SendToAll(Bot, mess)
First post updated :]

Cheers
Title: same one can to convert to lua 5?
Post by: (-=TrIp-iN-SuN=-) on 28 April, 2005, 12:26:05
who can to convert TrigChat 1.0 ?
Title:
Post by: jiten on 28 April, 2005, 14:00:28
QuoteOriginally posted by (-=TrIp-iN-SuN=-)
who can to convert TrigChat 1.0 ?
Check this (http://board.univ-angers.fr/thread.php?threadid=3666&boardid=26&sid=16e57a708bb83f608eaf8cc5387b2dbf) thread.

Cheers
Title: ?
Post by: (-=TrIp-iN-SuN=-) on 28 April, 2005, 14:09:12
hi it's bot answer before i type same thing how i doing i type same thing and bot answer

it's what happned :

[14:06] Yeah ']['rIp?iN??uN, that was some funny shit :), hahahaha! :D
[14:06] <']['rIp?iN??uN> lol

and i want to see this like this :

[14:06] <']['rIp?iN??uN> lol
[14:06] Yeah ']['rIp?iN??uN, that was some funny shit :), hahahaha! :D
Title:
Post by: jiten on 28 April, 2005, 15:01:10
Check that thread again.

Cheers
Title: tnx bro
Post by: (-=TrIp-iN-SuN=-) on 28 April, 2005, 15:06:48
tnx bro ;)
Title:
Post by: jiten on 29 April, 2005, 13:56:51
yw :]
Title:
Post by: Jerry on 06 May, 2005, 21:42:46
Hi jiten,

Janinha is good script!
But I have two suggestions:
1. don't you want to give to script, the command to add phrase with command (for ex. +addphrase hi="hello [USER]")?

2. don't you want to give all Janinha phrases from script to  individual .txt files?

This is onky my suggestion for Janinha's modification! ;)
Title:
Post by: jiten on 06 May, 2005, 22:06:11
QuoteOriginally posted by Jerry
Hi jiten,

Janinha is good script!
But I have two suggestions:
1. don't you want to give to script, the command to add phrase with command (for ex. +addphrase hi="hello [USER]")?

2. don't you want to give all Janinha phrases from script to  individual .txt files?

This is onky my suggestion for Janinha's modification! ;)
Thanks for ur comments, Jerry.
About ur request, I'm going to do a rewrite of this one. Not really sure when but, I'll add ur ideas onto it.

Cheers
Title:
Post by: Jerry on 06 May, 2005, 22:22:29
QuoteOriginally posted by jiten
Thanks for ur comments, Jerry.
About ur request, I'm going to do a rewrite of this one. Not really sure when but, I'll add ur ideas onto it.

Cheers

:]