I like this bot a lot but i need some help here.
It is changed from lua4 2 lua5
The triggers doesnt work and the after quiet/morning and evening are timed and sould respond on the main but are not responding.
Any body a id ?( ?(
----------------------------------------------------
-- code:
-- Thks to Ptaczek for his TrickerBot.lua
-- Thks to Skrollster, for the math.random synthax ([URL]http://lua.bcs-solutions.de/thread.php?threadid=291&boardid=15&sid=d4de5272887ab85292a4078fa73ba6be[/URL])
-- Thks to MatrixX for some help, too... ([URL]http://lua.bcs-solutions.de/thread.php?threadid=3&boardid=7&sid=6541fa822c277b66330f5bc1f409f4cc&page=2[/URL])
-- And thks to the others, for their help... ;o)
----------------------------------------------------------------
-- seNsi: the 'clever' Bot :p
-- Description:
-- Each 20 math.min, Bot is talking alone, with math.random questions...
-- If someone speaks again on main chat, there is a math.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 = "?Zenia?"
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 sleemath.ping ?!",
"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
math.min = 60 * sec
hour = 60 * math.min
index = nil
function Main()
quiet = "false"
talk = "allow"
WaitingForAnswerAfterQuiet = "false"
WaitingForAnswerMorning = "false"
WaitingForAnswerEvening = "false"
SetTimer(30*math.min)
StartTimer()
frmHub:RegBot(botname)
end
function DataArrival(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
-- 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 math.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
----------------------------------------------------
-- code:
-- Thks to Ptaczek for his TrickerBot.lua
-- Thks to Skrollster, for the math.random synthax ([URL]http://lua.bcs-solutions.de/thread.php?threadid=291&boardid=15&sid=d4de5272887ab85292a4078fa73ba6be[/URL])
-- Thks to MatrixX for some help, too... ([URL]http://lua.bcs-solutions.de/thread.php?threadid=3&boardid=7&sid=6541fa822c277b66330f5bc1f409f4cc&page=2[/URL])
-- And thks to the others, for their help... ;o)
----------------------------------------------------------------
-- seNsi: the 'clever' Bot :p
-- Description:
-- Each 20 math.min, Bot is talking alone, with math.random questions...
-- If someone speaks again on main chat, there is a math.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 = "?Zenia?"
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 sleemath.ping ?!",
"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
math.min = 60 * sec
hour = 60 * math.min
index = nil
function Main()
quiet = "false"
talk = "allow"
WaitingForAnswerAfterQuiet = "false"
WaitingForAnswerMorning = "false"
WaitingForAnswerEvening = "false"
SetTimer(30*math.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
-- Main Chat events --
function ChatArrival(user, data)
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 math.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
\Ptokax\scripts\Wiseguy.lua:22: function arguments expected near `='
bye="See ya [USER]",
Changed in
["bye"]="See ya [USER]",
next error is
\Ptokax\scripts\Sensi2.lua:18: function arguments expected near `='
cant find that one ?(
hi m8
edited above post .. works ok this end
??????Hawk??????
my my .. this script is really a mess after so many years ...
modding on top of modding, mods that took their way and never looked back and mods that followed the route backwards.. /me just making observations & comments ...
heheheh yeh it is a mess ..
but couldnt be bothered trying to do any more with it giving the none tabbed format :P
how many time do we need to ask ppl to use the [ code] blahh blahh [ /code] tabs ???
??????Hawk??????
Wel got it running
Thx for the help ??????Hawk?????? and i like your Xsthetic NetServer it is running in my hub a couple of days now Great work.
Herodes nice scripting work on wiseguy like to see some more of those :p
QuoteThx for the help ??????Hawk?????? and i like your Xsthetic NetServer it is running in my hub a couple of days now Great work.
you welcome m8 ..
BTW.. do a script update through the Xsthetic NetServer gui before you update Ptokax.. :)
??????Hawk??????
You could have had a look at Clever Janinha (http://board.univ-angers.fr/thread.php?threadid=3982&boardid=26&styleid=1&sid=5a35d28841ab2faed22bf20a2d092ce9) .
It does the same and it is in LUA 5.
Best regards.
I couldn't stand seeing it in such a mess... there is a heavily optimised version ...
-- Thks to Ptaczek for his Trickerbotname.lua
-- Thks to Skrollster, for the math.random synthax ([URL]http://lua.bcs-solutions.de/thread.php?threadid=291&boardid=15&sid=d4de5272887ab85292a4078fa73ba6be[/URL])
-- Thks to MatrixX for some help, too... ([URL]http://lua.bcs-solutions.de/thread.php?threadid=3&boardid=7&sid=6541fa822c277b66330f5bc1f409f4cc&page=2[/URL])
-- And thks to the others, for their help... ;o)
----------------------------------------------------------------
-- seNsi: the 'clever' botname :p
-- Description:
-- Each 20 math.min, botname is talking alone, with math.random questions...
-- If someone speaks again on main chat, there is a math.random answer, and then the timer is starting again.
-- If the user says a known trig (ex: 'hey '), and the bot was feeling alone, botname 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)
----------------------------------------------------------------
--- heavily touched by Herodes :: 28/3/2005 ( 16.08 compliant too )
--- many optimizations .. couldn't count them .. just enjoy..
botname = "SenSi"
botemail = "petsagouris@hotmail.com"
botdesc = "I am the cleverest bot around ..."
Interval = 1 -- every how many hours ?
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)",
}
idle ={} -- don't touch pls .. if you do don't blame it on me ..
idle.questions = {
"Anybody here?",
"I'am Boored",
"All are sleeping ?!",
"Haaaaaaaaloooooooooo !!! ",
"Don't leave me alone.... :'(",
}
idle.answers = {
"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... :))"
}
idle.morninganswers = {
"Wow... [USER]... ur night was certainly short.... :p",
"Yeahh !!! GOOOOOD MORNIIIIIIIIIING [USER] !",
"So, [USER],...coffee for me please, yep... :o)"
}
idle.morning = {
"Driiiiiiing... Time to Wake Uuuuuuuuuuup !! :D",
"GOOOOOD MORNIIIIIIIIIING HUBSTERRRRRRRRRRRRRS !!!!!!!",
"Hmm.....Someone is awake ??!!"
}
idle.evening = {
"Time to have a drink, no ? :o)",
"Hum hum... place is really quiet, at this time... :'(",
"At this time, u shouldn't sleep... :-("
}
idle.eveninganswers = {
"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"
}
function Main()
talk = true
frmHub:RegBot(botname, 1, botdesc, botemail)
w = {
["quiet"] = false,
["morn"] = false,
["even"] = false,
}
SetTimer(Interval*3600000)
StartTimer()
end
function ToArrival(user, data)
-- Pm events --
if(string.sub(data, 1, string.len(botname)+5 ) == "$To: "..botname ) then
local s,e,cmd = string.find(string.sub(data,1, -2),"%$%b<>%s+(%S+)")
if (user.bOperator and cmd) then
if (cmd=="!quiet") then
talk = false
StopTimer()
user:SendPM(botname,"Ok,...I'll be quiet now... :s")
elseif (cmd=="!talk") then
talk = true
SetWait(false,false,false)
StartTimer()
user:SendPM(botname, "Ahh... i'm back :)")
end
end
end
end
-- Main Chat events --
function ChatArrival(user, data)
local data = string.sub(data,1, -2)
local s,e,cmd = string.find( data, "%b<>%s+(%S+)" )
if ( cmd ) then
if ( user.bOperator ) then
if (cmd == "!quiet" ) then
SendToAll( "ok its here" )
talk = false
user:SendData(botname, "Ok,...I'll be quiet now... :s")
StopTimer()
elseif ( cmd=="!talk" ) then
talk = true
SetWait(false,false,false)
StartTimer()
SendToAll(botname, "Ahh... i'm back :)")
elseif ( talk and w.quiet ) then
user:SendData(botname, "hum...hum...")
end
end
local s,e,mess = string.find( data, "%b<>%s+(.*)")
if ( mess ) then
-- Trigs Answers --
for key, value in trigs do
-- Answer to mess command if bot is allowed to speak --
if ( ( not w.quiet ) and (( string.find( string.lower(mess), key) ) or ( string.find( string.lower(cmd), key) )) ) then
SendToAll(botname, string.gsub(value, "%[USER%]", user.sName) )
break;
end
end
end
end
-- Restart the timer each time someone is talking on the main chat, if bot is allowed to talk --
if talk then
if ( (not iscommand(cmd)) and (not iscommand(mess)) ) then
StopTimer()
StartTimer()
end
-- Receiving entries on the main chat --
if ( (not iscommand(cmd)) and (not iscommand(mess)) ) then
if ( w.morn or w.even ) then
SendToAll(botname, string.gsub(idle.morninganswers[math.random(1,table.getn(idle.morninganswers))], "%[USER%]", user.sName))
SetWait(false,false,false)
elseif w.quiet then
SendToAll(botname, string.gsub(idle.answers[math.random(1,table.getn(idle.answers))], "%[USER%]", user.sName))
end
end
end
end
function OnTimer()
local h, trig = tonumber(os.date("%H")), nil
-- Idle trigs, for the morning, and the evening :o) --
if H == 7 then
SendToAll(botname, idle.morning[math.random(1,table.getn(idle.morning))])
SetWait(false,true,false)
StartTimer()
trig = true
elseif H == 19 then
SendToAll(botname, idle.evening[math.random(1,table.getn(idle.evening))])
SetWait(false,false,true)
StartTimer()
trig = true
end
-- Others idle trigs --
if trig then
SendToAll(botname, idle.questions[math.random(1,table.getn(idle.questions))])
SetWait(true)
end
SendToAll( "tic tac")
end
function SetWait( afterquiet, morning , evening )
w.quiet = afterquiet or w.quiet
w.morn = morning or w.morn
w.even = evening or w.even
end
function iscommand(str)
local t = { ["!"] = 1, ["?"] = 1, ["+"] = 1, ["#"] = 1 }
if ( t[string.sub(str, 1, 1)] ) then
return true
else
return false
end
end
[*edit*] some debug code removed...
Nice job cleaning got it running thanks ;)
QuoteOriginally posted by T?M??r?V?ll?R
Nice job cleaning got it running thanks ;)
you're welcome tt ;)
Removed some debug code in the script... thx TimeTraveler for the report.. ;) the script is here (http://board.univ-angers.fr/thread.php?threadid=4058&boardid=29&styleid=1&page=1#10)
Nice one Herodes.
I tested ur script some hours ago, and it wasn't working well in PtokaX 16.06.
It wasn't responding to any trigger and replying to all inputs with something like my info.
Is it OK now? and compatible with 16.05+ ?
Best regards.
Now, I get this one:
Syntax ...ktop\16.06.test\scripts\cleverbot.lua_5.0.lua:193: bad argument #1 to `sub' (string expected, got nil)
thx for the report.. I'll try posting a fixed ver later ...
Cool.
Got the same error
hoop to see the clean lua soon. in till than running the script of ??????Hawk?????? running nice till now :]
Btw Herodes, could u check if the trigs appear after the text and not before? (that's why Janinha had a timer).
QuoteOriginally posted by jiten
Btw Herodes, could u check if the trigs appear after the text and not before? (that's why Janinha had a timer).
Putting a timer for such a thing is plainly the longest way to Rome...
Thanks for pointing out the (bug) though...
there it is ...
--[[
Thks to Ptaczek for his Trickerbot.lua
Thks to Skrollster, for the math.random synthax
Thks to MatrixX for some help, too...
And thks to the others, for their help... ;o)
----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
seNsi: the 'clever' bot :p
Description:
- Each 20 math.min, bot is talking alone, with math.random questions...
- If someone speaks again on main chat, there is a math.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)
----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
- heavily touched by Herodes :: 28/3/2005 ( 16.08 compliant too )
- many optimizations .. couldn't count them .. just enjoy..
--]]
bot = {
["name"] = "SenSi",
["email"] = "petsagouris@hotmail.com",
["desc"] = "I am the cleverest bot around ...",
}
Interval = 1 -- every how many minutes ?
s = {}
s.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)",
}
s.idle ={} -- don't touch this line pls .. if you do don't blame it on me ..
s.idle.questions = {
"Anybody here?",
"I'am Boored",
"All are sleeping ?!",
"Haaaaaaaaloooooooooo !!! ",
"Don't leave me alone.... :'(",
}
s.idle.answers = {
"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... :))"
}
s.idle.morninganswers = {
"Wow... [USER]... ur night was certainly short.... :p",
"Yeahh !!! GOOOOOD MORNIIIIIIIIIING [USER] !",
"So, [USER],...coffee for me please, yep... :o)"
}
s.idle.morning = {
"Driiiiiiing... Time to Wake Uuuuuuuuuuup !! :D",
"GOOOOOD MORNIIIIIIIIIING HUBSTERRRRRRRRRRRRRS !!!!!!!",
"Hmm.....Someone is awake ??!!"
}
s.idle.evening = {
"Time to have a drink, no ? :o)",
"Hum hum... place is really quiet, at this time... :'(",
"At this time, u shouldn't sleep... :-("
}
s.idle.eveninganswers = {
"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"
}
function Main()
talk = true
frmHub:RegBot(bot.name, 1, bot.desc, bot.email)
bot = bot.name
w = { ["quiet"] = false,["morn"] = false,["even"] = false }
SetTimer(Interval*60000)
StartTimer()
end
function ParseCommands(user, data, pm_start)
local findstr = (pm_start or "").."%b<>%s+[!#?+](%S+)"
local _,_, cmd = string.find ( data, findstr )
if cmd then
if cmd == "quiet" then
Talk(false)
SendToAll(bot, "Ok,... "..user.sName.." told me to be quiet ... that's what I'll do... :s")
StopTimer()
elseif cmd == "talk" then
Talk(true)
SetWait(false,false,false)
StartTimer()
SendToAll(bot, "Ahh... i'm back :)")
end
return true
else
return false
end
end
function Talk(b)
if b then talk = b end
return talk
end
function ToArrival(user, data)
if (string.sub(data, 1, string.len(bot)+5 ) == "$To: "..bot ) then
if user.bOperator then
if ParseCommands(user, string.sub(data,1, -2), "%$") then
return 1
end
end
end
end
-- Main Chat events --
function ChatArrival(user, data)
if ( user.bOperator and ParseCommands( user, string.sub(data,1, -2) ) ) then return 1 end
local _,_,msg = string.find( data, "%b<>%s*(.*)|")
local talked = nil
msg = string.lower(msg)
for trig, replace in s.trigs do
if ( w.quiet == false ) then
if string.find( msg, trig ) then
talked = (Produce( replace, "%[USER%]", user.sName))
break;
end
end
end
if talked then
SendToAll( user.sName, msg)
SendToAll( bot, talked )
return 1
end
-- Restart the timer each time someone is talking on the main chat, if bot is allowed to talk --
if Talk() then
StopTimer()
StartTimer()
if ( w.morn or w.even ) then
SendToAll(bot, Produce( s.s.idle.morninganswers, "%[USER%]", user.sName) )
SetWait(false,false,false)
elseif w.quiet then
SendToAll(bot, Produce( s.idle.answers, "%[USER%]", user.sName) )
end
end
end
function OnTimer()
local h, trig = tonumber(os.date("%H")), nil
-- Idle trigs, for the morning, and the evening :o) --
if h == 7 then
SendToAll( bot, Produce(s.idle.morning) )
SetWait(false,true,false)
StartTimer()
trig = true
elseif h == 19 then
SendToAll( bot, Produce(s.idle.evening) )
SetWait(false,false,true)
StartTimer()
trig = true
end
-- Others idle trigs --
if not trig then
SendToAll( bot, Produce(s.idle.questions))
SetWait(true)
end
end
function Produce( val, what, with )
if what then
if type(val) == "table" then
return string.gsub( val[math.random(1,table.getn(val))], what, with )
end
return string.gsub( val, what, with )
end
return val[math.random(1,table.getn(val))]
end
function SetWait( q, m, e )
if q then w.quiet = q end
if m then w.morn = m end
if e then w.even = e end
end
You're right, Herodes eheh
It's working flawlessly till now.
Btw, nice idea for the trigger after the text. Why didn?t I think about it? :]
Best regards,
jiten
Jupz runs ok at my place thxie Herodes.
Nice job :]
--------EDIT----------
Was to early.
There is no resons after a quiet period when someone is talking in main.
[09:12:50]
Anybody here?
[09:13:50] Don't leave me alone.... :'(
[09:15:02] <[CC][MA]kuipie> yah sure i am
[09:16:02] Anybody here?
Found a posible script error and fixed it but still no resonse
Quote-- Restart the timer each time someone is talking on the main chat, if bot is allowed to talk --
if Talk() then
StopTimer()
StartTimer()
if ( w.morn or w.even ) then
SendToAll(bot, Produce( s.s.idle.morninganswers, "%[USER%]", user.sName) )
SetWait(false,false,false)
elseif w.quiet then
SendToAll(bot, Produce( s.idle.answers, "%[USER%]", user.sName) )
s.s.idle.morninganswers, changed in to s.idle.morninganswers,
But still no answer
[EDIT] Got it running thx to T?M??r?V?ll?R
[/EDIT]
I cant give any promises about fixing this script quickly .. but I hope I will at some point ;)
Does anybody has the good working wiseguy????????
QuoteOriginally posted by Syphrone-NL
Does anybody has the good working wiseguy????????
Well, there's a working one. Search the forum for "Clever Janinha" and then see if it suits ur needs :]
Best regards,
jiten
QuoteOriginally posted by jiten
QuoteOriginally posted by Syphrone-NL
Does anybody has the good working wiseguy????????
Well, there's a working one. Search the forum for "Clever Janinha" and then see if it suits ur needs :]
Best regards,
jiten
cant find it
Check this (http://board.univ-angers.fr/thread.php?threadid=3982&boardid=26&sid=9e9aa8db4c8110308c0f497bce2e2b81) thread.
Cheers
--[[
Thks to Ptaczek for his Trickerbot.lua
Thks to Skrollster, for the math.random synthax
Thks to MatrixX for some help, too...
And thks to the others, for their help... ;o)
----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
seNsi: the 'clever' bot :p
Description:
- Each 20 math.min, bot is talking alone, with math.random questions...
- If someone speaks again on main chat, there is a math.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)
----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
- heavily touched by Herodes :: 28/3/2005 ( 16.08 compliant too )
- many optimizations .. couldn't count them .. just enjoy..
- some fixes by Dessamator
--]]
bot = {
["name"] = "SenSi",
["email"] = "petsagouris@hotmail.com",
["desc"] = "I am the cleverest bot around ...",
}
Interval = 1 -- every how many minutes ?
s = {}
s.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)",
}
s.idle ={} -- don't touch this line pls .. if you do don't blame it on me ..
s.idle.questions = {
"Anybody here?",
"I'am Boored",
"All are sleeping ?!",
"Haaaaaaaaloooooooooo !!! ",
"Don't leave me alone.... :'(",
}
s.idle.answers = {
"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... :))"
}
s.idle.morninganswers = {
"Wow... [USER]... ur night was certainly short.... :p",
"Yeahh !!! GOOOOOD MORNIIIIIIIIIING [USER] !",
"So, [USER],...coffee for me please, yep... :o)"
}
s.idle.morning = {
"Driiiiiiing... Time to Wake Uuuuuuuuuuup !! :D",
"GOOOOOD MORNIIIIIIIIIING HUBSTERRRRRRRRRRRRRS !!!!!!!",
"Hmm.....Someone is awake ??!!"
}
s.idle.evening = {
"Time to have a drink, no ? :o)",
"Hum hum... place is really quiet, at this time... :'(",
"At this time, u shouldn't sleep... :-("
}
s.idle.eveninganswers = {
"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"
}
function Main()
talk = true
frmHub:RegBot(bot.name, 1, bot.desc, bot.email)
bot = bot.name
w = { ["quiet"] = false,["morn"] = false,["even"] = false }
SetTimer(Interval*60000)
StartTimer()
end
function ParseCommands(user, data, pm_start)
local findstr = (pm_start or "").."%b<>%s+[!#?+](%S+)"
local _,_, cmd = string.find ( data, findstr )
if cmd then
if cmd == "quiet" then
Talk(false)
SendToAll(bot, "Ok,... "..user.sName.." told me to be quiet ... that's what I'll do... :s")
StopTimer()
elseif cmd == "talk" then
Talk(true)
SetWait(false,false,false)
StartTimer()
SendToAll(bot, "Ahh... i'm back :)")
end
return true
else
return false
end
end
function Talk(b)
if b then talk = b end
return talk
end
function ToArrival(user, data)
if (string.sub(data, 1, string.len(bot)+5 ) == "$To: "..bot ) then
if user.bOperator then
if ParseCommands(user, string.sub(data,1, -2), "%$") then
return 1
end
end
end
end
-- Main Chat events --
function ChatArrival(user, data)
if ( user.bOperator and ParseCommands( user, string.sub(data,1, -2) ) ) then return 1 end
local _,_,msg = string.find( data, "%b<>%s*(.*)|")
local talked = nil
msg = string.lower(msg)
for trig, replace in s.trigs do
if ( w.quiet == false) then
if string.find( msg, trig ) then
talked = (Produce( replace, "%[USER%]", user.sName))
-- break;
end
end
end
if talked then
SendToAll( user.sName, msg)
SendToAll( bot, talked )
return 1
end
-- Restart the timer each time someone is talking on the main chat, if bot is allowed to talk --
if Talk() then
local function idleresponce(idle)
dostuff=Produce( idle, "%[USER%]", user.sName)
return dostuff
end
StopTimer()
StartTimer()
if w.quiet then
SendToAll(bot, idleresponce(s.idle.answers ))
SetWait(false)
elseif (w.morn) then
SendToAll(bot, idleresponce(s.idle.morninganswers))
SetWait(false,false)
elseif w.even then
SendToAll(bot, idleresponce(s.idle.eveninganswers))
SetWait(false,false,false)
end
end
end
function OnTimer()
local h, trig = tonumber(os.date("%H")), nil
-- Idle trigs, for the morning, and the evening :o) --
if h == 7 then
SendToAll( bot, Produce(s.idle.morning) )
SetWait(false,true,false)
StartTimer()
trig = true
elseif h == 19 then
SendToAll( bot, Produce(s.idle.evening) )
SetWait(false,false,true)
StartTimer()
trig = true
end
-- Others idle trigs --
if not trig then
SendToAll( bot, Produce(s.idle.questions))
SetWait(true)
end
end
function Produce( val, what, with )
if what then
if type(val) == "table" then
return string.gsub( val[math.random(1,table.getn(val))], what, with )
end
return string.gsub( val, what, with )
end
return val[math.random(1,table.getn(val))]
end
function SetWait( q, m, e )
w.quiet = q --quiet
w.morn = m --morning
w.even = e --evening
end--------------------------------------------------------------------------------
all errors fixed, debugged, and tested 100%, ;)
Why does the bot reply before my comment?
04:01:47] All are sleeping ?!
[04:02:44] Aaaahh, dear bcdc... i was feeling quite alone.... :o)
[04:02:44] no
The red reply should be here!?
Tried also janinha...same.
QuoteOriginally posted by yoonohoo
Why does the bot reply before my comment?
04:01:47] All are sleeping ?!
[04:02:44] Aaaahh, dear bcdc... i was feeling quite alone.... :o)
[04:02:44] no
The red reply should be here!?
Tried also janinha...same.
Well, search the forum for "senSi" by Dessamator. It should solve that problem.
Btw, that report of yours seems strange to me. I had already fixed that in Janinha. Anyway....
Cheers