Cleverbot
 

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

Cleverbot

Started by BeeR, 13 March, 2005, 17:15:50

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

BeeR

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

-- Thks to Ptaczek for his TrickerBot.lua
-- Thks to Skrollster, for the random synthax (http://lua.bcs-solutions.de/thread.php?t...2a4078fa73ba6be)
-- Thks to MatrixX for some help, too... (http://lua.bcs-solutions.de/thread.php?t...f4cc&page=2)
-- And thks to the others, for their help... ;o)
----------------------------------------------------------------
-- seNsi: the 'clever' Bot :p
-- Description:
-- Each 20 min, Bot is talking alone, with random questions...
-- If someone speaks again on main chat, there is a random answer, and then the timer is starting again.
-- If the user says a known trig (ex: 'hey '), and the bot was feeling alone, Bot will choose the correct answer (ex:'Yessss,...[USER] happy to hear U again,, :))')
-- Sorry for the 'a' synthax (a = 0, a = 1, etc...), but I'm quite nb in lua...
-- Hope u'll enjoy it ! :o)
----------------------------------------------------------------

Bot = "Wiseguy"


trigs = {
bye="See ya [USER]",
["fine u"]="I am lame... ",
["need some"]="Hum... maybe pray for it...",
["loool"]="Yeah, [USER] ! It was really funny...",
["its fine"]="good...",
["take care"]="U 2... :o)"
}

idlequestions = {
"Anybody here?",
"I.am Boored",
"All are sleeping ?!",
"Haaaaaaaaloooooooooo !!! ",
"Don't leave me alone.... :'(",
}

idleanswers = {
"Aaaahh, dear [USER]... i was feeling quite alone.... :o)",
"Yessss,...[USER] happy to hear U again,, :))",
"Sorry to disturb u, [USER], but i was quite upset... :s ",
"Thks, [USER]... i thought something was wrong with ur keyboard...",
"OOhhh, [USER]... i'm not alone at this universe... :))"
}

idlemorninganswers = {
"Wow... [USER]... ur night was certainly short.... :p",
"Yeahh !!! GOOOOOD MORNIIIIIIIIIING [USER] !",
"So, [USER],...coffee for me please, yep... :o)"
}

idlemorning = {
"Driiiiiiing... Time to Wake Uuuuuuuuuuup !! :D",
"GOOOOOD MORNIIIIIIIIIING HUBSTERRRRRRRRRRRRRS !!!!!!!",
"Hmm.....Someone is awake ??!!"
}

idleevening = {
"Time to have a drink, no ? :o)",
"Hum hum... place is really quiet, at this time... :'(",
"At this time, u shouldn't sleep... :-("
}

idleeveninganswers = {
"Well, at least... Some of us are still alive,... cool :D",
"I was upset,... that's all... :(",
"It's time...If u offer me a drink... i couldn't say no.... :p"
}

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

index = nil

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

function DataArrival(user, data)

-- Pm events --

if(strsub(data, 1, 4) == "$To:") then
data=strsub(data,1,strlen(data)-1)
s,e,whoTo = strfind(data,"$To:%s+(%S+)")
if (whoTo == botname) then
s,e,whoTo,from,cmd = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")
if (user.bOperator) then

if (cmd=="!quiet") then
quiet = "true"
talk = "notallow"
StopTimer()
user:SendPM(botname,"Ok,...I'll be quiet now... :s")
end

if (cmd=="!talk") then
talk = "allow"
quiet = "false"
WaitingForAnswerAfterQuiet = "false"
WaitingForAnswerMorning = "false"
WaitingForAnswerEvening = "false"
StartTimer()
user:SendPM(botname, "Ahh... i'm back :)")
end
end
end
end

-- Main Chat events --

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

s,e,cmd = strfind( data, "%b<>%s+(%S+)" )
s,e,mess = strfind(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( strfind( strlower(mess), key) ) or ( strfind( strlower(cmd), key) ) then
answer, x = gsub(value, "%b[]", user.sName)
SendToAll(Bot, answer )
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=="!quiet") then
if user.bOperator then
quiet = "true"
talk = "notallow"
SendToAll(Bot, "Ok,...I'll be quiet now... :s")
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, "hum...hum...")
end
end
end

-- Allow the bot to talk (ops command) --

if (cmd=="!talk") then
if user.bOperator then
talk = "allow"
quiet = "false"
WaitingForAnswerAfterQuiet = "false"
WaitingForAnswerMorning = "false"
WaitingForAnswerEvening = "false"
StartTimer()
SendToAll(Bot, "Ahh... i'm back :)")
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, "hum...")
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 '+'/'!'/'#'/'?'. Bot won't replye - nicest, i think... :o) --

if iscommand(cmd) or iscommand(mess) then
else

-- Answer to chat entries --
index = random(1,getn(idlemorninganswers))
answer, x = gsub(idlemorninganswers[index], "%b[]", user.sName)
SendToAll(Bot, answer)
WaitingForAnswerAfterQuiet = "false"
WaitingForAnswerMorning = "false"
WaitingForAnswerEvening = "false"
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 --
index = random(1,getn(idleeveninganswers))
answer, x = gsub(idleeveninganswers[index], "%b[]", user.sName)
SendToAll(Bot, answer)
WaitingForAnswerAfterQuiet = "false"
WaitingForAnswerMorning = "false"
WaitingForAnswerEvening = "false"
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 --
index = random(1,getn(idleanswers))
answer, x = gsub(idleanswers[index], "%b[]", user.sName)
SendToAll(Bot, answer)
WaitingForAnswerAfterQuiet = "false"
WaitingForAnswerMorning = "false"
WaitingForAnswerEvening = "false"
end
end
end
end
end

end

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

-- Idle trigs, for the morning, and the evening :o) --

if H=="07" then
index = random(1,getn(idlemorning))
SendToAll(Bot, idlemorning[index])
WaitingForAnswerAfterQuiet = "false"
WaitingForAnswerMorning = "true"
WaitingForAnswerEvening = "false"
StartTimer()
trig = "done"
end

if H=="19" then
index = random(1,getn(idleevening))
SendToAll(Bot, idleevening[index])
WaitingForAnswerAfterQuiet = "false"
WaitingForAnswerMorning = "false"
WaitingForAnswerEvening = "true"
StartTimer()
trig = "done"
end

-- Others idle trigs --

if trig == "notdone" then
index = random(1,getn(idlequestions))
SendToAll(Bot, idlequestions[index])
WaitingForAnswerAfterQuiet = "true"
end
end

-- Get Time --

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

function iscommand(str)
return strsub(str, 1, 1) == "!" or strsub(str, 1, 1) == "?" or strsub(str, 1, 1) == "+" or strsub(str, 1, 1) == "#"
end
------------------------------------------------------------------------

Some1 who can convert it to LUA5 for me
i tried with NL's converter but it fails
A cold BeeR is stunning !!

jiten

#1
Hi there.
Well, this one is working. There only a slight problem. When u try to !quiet the bot, he doesn't really stop talking. I could really find where's the bug. Anyone?
Apart from it, it's working perfectly.

Try this:

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

-- Thks to Ptaczek for his TrickerBot.lua 
-- Thks to Skrollster, for the 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 
-- Description: 
-- Each 20 min, Bot is talking alone, with random questions... 
-- If someone speaks again on main chat, there is a random answer, and then the timer is starting again. 
-- If the user says a known trig (ex: 'hey '), and the bot was feeling alone, Bot will choose the correct answer (ex:'Yessss,...[USER] happy to hear U again,, :))') 
-- Sorry for the 'a' synthax (a = 0, a = 1, etc...), but I'm quite nb in lua... 
-- Hope u'll enjoy it ! :o) 
---------------------------------------------------------------- 

Bot = "Wiseguy" 
botname = "Wiseguy"

trigs = { 
bye="See ya [USER]", 
["fine u"]="I am lame... ", 
["need some"]="Hum... maybe pray for it...", 
["loool"]="Yeah, [USER] ! It was really funny...", 
["its fine"]="good...", 
["take care"]="U 2... :o)" 
} 

idlequestions = { 
"Anybody here?", 
"I.am Boored", 
"All are sleeping ?!", 
"Haaaaaaaaloooooooooo !!! ", 
"Don't leave me alone.... :'(", 
} 

idleanswers = { 
"Aaaahh, dear [USER]... i was feeling quite alone.... :o)", 
"Yessss,...[USER] happy to hear U again,, :))", 
"Sorry to disturb u, [USER], but i was quite upset... :s ", 
"Thks, [USER]... i thought something was wrong with ur keyboard...", 
"OOhhh, [USER]... i'm not alone at this universe... :))" 
} 

idlemorninganswers = { 
"Wow... [USER]... ur night was certainly short.... :p", 
"Yeahh !!! GOOOOOD MORNIIIIIIIIIING [USER] !", 
"So, [USER],...coffee for me please, yep... :o)" 
} 

idlemorning = { 
"Driiiiiiing... Time to Wake Uuuuuuuuuuup !! :D", 
"GOOOOOD MORNIIIIIIIIIING HUBSTERRRRRRRRRRRRRS !!!!!!!", 
"Hmm.....Someone is awake ??!!" 
} 

idleevening = { 
"Time to have a drink, no ? :o)", 
"Hum hum... place is really quiet, at this time... :'(", 
"At this time, u shouldn't sleep... :-(" 
} 

idleeveninganswers = { 
"Well, at least... Some of us are still alive,... cool :D", 
"I was upset,... that's all... :(", 
"It's time...If u offer me a drink... i couldn't say no.... :p" 
} 

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

index = nil 

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

function ToArrival(user, data) 
-- Pm events -- 

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=="!quiet") then 
quiet = "true" 
talk = "notallow" 
StopTimer() 
user:SendPM(botname,"Ok,...I'll be quiet now... :s") 
end 

if (cmd=="!talk") then 
talk = "allow" 
quiet = "false" 
WaitingForAnswerAfterQuiet = "false" 
WaitingForAnswerMorning = "false" 
WaitingForAnswerEvening = "false" 
StartTimer() 
user:SendPM(botname, "Ahh... i'm back :)") 
end 
end 
end 
end 
end

function ChatArrival(user, data) 

-- Main Chat events -- 

if( string.sub(data, 1, 1) == "<" ) then 
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) 
SendToAll(Bot, answer ) 
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=="!quiet") then 
if user.bOperator then 
quiet = "true" 
talk = "notallow" 
SendToAll(Bot, "Ok,...I'll be quiet now... :s") 
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, "hum...hum...") 
end 
end 
end 

-- Allow the bot to talk (ops command) -- 

if (cmd=="!talk") then 
if user.bOperator then 
talk = "allow" 
quiet = "false" 
WaitingForAnswerAfterQuiet = "false" 
WaitingForAnswerMorning = "false" 
WaitingForAnswerEvening = "false" 
StartTimer() 
SendToAll(Bot, "Ahh... i'm back :)") 
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, "hum...") 
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 '+'/'!'/'#'/'?'. Bot won't replye - nicest, i think... :o) -- 

if iscommand(cmd) or iscommand(mess) then 
else 

-- Answer to chat entries -- 
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" 
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 -- 
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" 
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 -- 
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" 
end 
end 
end 
end 
end 

end 

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

-- Idle trigs, for the morning, and the evening :o) -- 

if H=="07" then 
index = math.random(1,table.getn(idlemorning)) 
SendToAll(Bot, idlemorning[index]) 
WaitingForAnswerAfterQuiet = "false" 
WaitingForAnswerMorning = "true" 
WaitingForAnswerEvening = "false" 
StartTimer() 
trig = "done" 
end 

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

-- Others idle trigs -- 

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 
------------------------------------------------------------------------


Best regards,

jiten

BeeR

Tnx m8 for your help ,, it seem to work good enough
some nice/weird things happends to me when i test it ,,
it send the trigger to main before my talk is shown up
A cold BeeR is stunning !!

jiten

Here you go. I guess it is working well now:

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

-- converted to LUA 5 by jiten and dessamator
-- Ideas taken from tezlo's retrobot and MultiTimer by OpiumVolage (19/06/2003)

-- Thks to Ptaczek for his TrickerBot.lua 
-- Thks to Skrollster, for the random synthax (http://lua.bcs-solutions.de/thread.php?t...2a4078fa73ba6be) 
-- Thks to MatrixX for some help, too... (http://lua.bcs-solutions.de/thread.php?t...f4cc&page=2) 
-- And thks to the others, for their help... ;o) 
---------------------------------------------------------------- 
-- seNsi: the 'clever' Bot :p 
-- Description: 
-- Each 20 min, Bot is talking alone, with random questions... 
-- If someone speaks again on main chat, there is a random answer, and then the timer is starting again. 
-- If the user says a known trig (ex: 'hey '), and the bot was feeling alone, Bot will choose the correct answer (ex:'Yessss,...[USER] happy to hear U again,, :))') 
-- Sorry for the 'a' synthax (a = 0, a = 1, etc...), but I'm quite nb in lua... 
-- Hope u'll enjoy it ! :o) 
---------------------------------------------------------------- 

Bot = "Wiseguy" 
botname = "Wiseguy"

------------------------------------ timer stuff
tabTimers = {n=0}

-- Time Definition
Sec  = 1000
Min  = 60*Sec
Hour = 60*Min
Day  = 24*Hour

TmrFreq = 1*Sec
---------------------------------------

trigs = { 
bye="See ya [USER]", 
["fine u"]="I am lame... ", 
["need some"]="Hum... maybe pray for it...", 
["loool"]="Yeah, [USER] ! It was really funny...", 
["its fine"]="good...", 
["take care"]="U 2... :o)" 
} 

idlequestions = { 
"Anybody here?", 
"I.am Boored", 
"All are sleeping ?!", 
"Haaaaaaaaloooooooooo !!! ", 
"Don't leave me alone.... :'(", 
} 

idleanswers = { 
"Aaaahh, dear [USER]... i was feeling quite alone.... :o)", 
"Yessss,...[USER] happy to hear U again,, :))", 
"Sorry to disturb u, [USER], but i was quite upset... :s ", 
"Thks, [USER]... i thought something was wrong with ur keyboard...", 
"OOhhh, [USER]... i'm not alone at this universe... :))" 
} 

idlemorninganswers = { 
"Wow... [USER]... ur night was certainly short.... :p", 
"Yeahh !!! GOOOOOD MORNIIIIIIIIIING [USER] !", 
"So, [USER],...coffee for me please, yep... :o)" 
} 

idlemorning = { 
"Driiiiiiing... Time to Wake Uuuuuuuuuuup !! :D", 
"GOOOOOD MORNIIIIIIIIIING HUBSTERRRRRRRRRRRRRS !!!!!!!", 
"Hmm.....Someone is awake ??!!" 
} 

idleevening = { 
"Time to have a drink, no ? :o)", 
"Hum hum... place is really quiet, at this time... :'(", 
"At this time, u shouldn't sleep... :-(" 
} 

idleeveninganswers = { 
"Well, at least... Some of us are still alive,... cool :D", 
"I was upset,... that's all... :(", 
"It's time...If u offer me a drink... i couldn't say no.... :p" 
} 

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"  

--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=="!quiet") then 
quiet = "true" 
talk = "notallow" 
WaitingForAnswerAfterQuiet = "true" 
StopTimer() 
user:SendPM(botname,"Ok,...I'll be quiet now... :s") 
return 1
end 

if (cmd=="!talk") then 
talk = "allow" 
quiet = "false" 
WaitingForAnswerAfterQuiet = "false" 
WaitingForAnswerMorning = "false" 
WaitingForAnswerEvening = "false" 
StartTimer() 
user:SendPM(botname, "Ahh... i'm back :)") 
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=="!quiet") then  
if user.bOperator then  
quiet = "true"  
talk = "notallow"  
WaitingForAnswerAfterQuiet = "true" 
SendToAll(Bot, "Ok,...I'll be quiet now... :s") 
StopTimer()  
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, "hum...hum...") 
return 1
end  
end  
end  
 
-- Allow the bot to talk (ops command) --  
 
if (cmd=="!talk") then  
if user.bOperator then  
talk = "allow"  
quiet = "false"  
WaitingForAnswerAfterQuiet = "false"  
WaitingForAnswerMorning = "false"  
WaitingForAnswerEvening = "false"  
StartTimer()  
SendToAll(Bot, "Ahh... i'm back :)") 
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, "hum...") 
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 '+'/'!'/'#'/'?'. Bot won't replye - nicest, i think... :o) --  
 
if iscommand(cmd) or iscommand(mess) then  
else  
 
-- Answer to chat entries --  
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"  
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 --  
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"  
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 --  
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"  
end  
end  
end  
end  
 
end  
 
function idlechat()  
time()  
trig = "notdone"  
 
-- Idle trigs, for the morning, and the evening :o) --  
 
if H=="07" then  
index = math.random(1,table.getn(idlemorning))  
SendToAll(Bot, idlemorning[index])  
WaitingForAnswerAfterQuiet = "false"  
WaitingForAnswerMorning = "true"  
WaitingForAnswerEvening = "false"  
StartTimer()  
trig = "done"  
end  
 
if H=="19" then  
index = math.random(1,table.getn(idleevening))  
SendToAll(Bot, idleevening[index])  
WaitingForAnswerAfterQuiet = "false"  
WaitingForAnswerMorning = "false"  
WaitingForAnswerEvening = "true"  
StartTimer()  
trig = "done"  
end  
 
-- Others idle trigs --  
 
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--------

SMF spam blocked by CleanTalk