PtokaX forum

Archive => Archived 4.0 boards => Finished Lua 4 scripts => Topic started by: pHaTTy on 12 October, 2003, 16:25:31

Title: JokeBot : Edited
Post by: pHaTTy on 12 October, 2003, 16:25:31
Here we go


-- JokeBot .lua by Cloud
-- Some more content by [ANCIENT]Klismo :P
-- Edited by Phatty for -mr-bill-
-- Double timer by klownietklowniet [30-09-2003]
-- ReAdded on command by phatty
-- On/Off switch by phatty

botname = "JokeBot"

Botstatus=0

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

TimeSpanInMinutes = 1
QuestionTimeInSec = 5



Command = "+Joke"
Command2 = "+shush"
Command3 = "+tell"
which = "q"  -- start with a question

jokes = {
"How can you tell if a blonde has been using the computer?",
"Why is it okay for blondes to catch cold?",
"Did you hear about the blonde who tried to blow up her husband's car?",
}

answers = {
"The joystick is wet.",
"They don't have to worry about blowing their brains out.",
"She burned her lips on the tailpipe.",
}



function Main()
   frmHub:RegBot(botname)
   SetTimer(TimeSpanInMinutes*min)
   StartTimer()
end



function OnTimer()
if Botstatus==1 then return 1 else
if which == "q" then
local number = random(1,getn(jokes))
local Joke = jokes[number]
SendToAll(botname, Joke)
which = tostring(number)
SetTimer(QuestionTimeInSec*sec)
else
local Answer = answers[tonumber(which)]
SendToAll(botname, Answer)
which = "q"
SetTimer(TimeSpanInMinutes*min)
end
end
end

function DataArrival(user, data)
if (strsub(data, 1, 1) == "<") or ( strsub(data, 1, 4) == "$To:" ) then
data = strsub(data,1,strlen(data)-1)
if (strfind(strlower(data), strlower(Command))) then
OnTimer()
elseif (strfind(strlower(data), strlower(Command2))) then
SendToAll(botname, "Joke bot is switched off")
Botstatus=1
return 1
elseif (strfind(strlower(data), strlower(Command3))) then
SendToAll(botname, "Joke bot is switched on")
Botstatus=0
return 1
end
end
end


l8rr,,

-phatty
Title:
Post by: Millsy on 03 June, 2004, 07:01:53
Anyone got this script with more jokes in it.

 :P Thanks  :P
      Millsy
Title:
Post by: Sudds on 03 June, 2004, 23:06:52
Hey grate script. Can i just add jokes and answers to it as long as i add them like this
jokes = {
"the joke.",
}

answers = {
"the answers.",

IS this ok?
Sudds