looking for a joke script that will play in main screen not send PM
and users can add jokes to the list anybody help
i have tryed a few jokebots in and around but they only send PMs to users that put in +joke i would like to be able to just type +joke or whatever and it will display a joke every few mins
2000man(kevin)
i am running robocopv8 and ptokax
i have seen a few script but don't know how to use them in ptokax only lua files i can get to work
hi m8
try Xsthetic netserver with security disabled..
joke bot built in
Click here for more details (http://board.univ-angers.fr/thread.php?threadid=2711&boardid=12&sid=6aa40fabc83390d57f2992a69220f767&page=1#22)
my 2? cents:
:D
--//Joke Bot v0.2
--//By: BottledHate
--//Requested by: 2000man
--//19/09/04(first release)
--//if using new pto w/ lua 5 erase this stuff...
string = {}
string.sub = strsub
string.find = strfind
string.gsub = gsub
string.len = strlen
string.lower = strlower
string.type = type
string.format = format
io = {}
io.open = openfile
io.close = closefile
io.write = write
os={}
os.execute = execute
table= {}
table.getn = getn
table.insert = tinsert
table.remove = tremove
math = {}
math.random = random
--// ok stop erasing!
jUserDefined = {--//don't touch
--//edit the stuff in quotes to your liking:
Botname = "JokeBot",
regBot = 1, --// 1 = reg Botname.. 0 = don't reg Botname.
---------
jInvoke = "!Joke", --//invoke a random joke at any time.
aJoke = "!aJoke", --//
rJoke = "!rJoke", --//OPS ONLY!--// ( = joke index #.. use the view command to get index.)
jHelp = "!jHelp", --//displays the help list
jView = "!jView", --//OPS ONLY!--//displays the current list of jokes.
jsInterval = "!jInt", --//OPS ONLY!--// (number = time in minutes between joke posts)
jSett = "!jDispSet", --//OPS ONLY!--// display the current settings.
jOff = "!jokesOff", --//OPS ONLY!
jOn = "!jokesOn" ,--//OPS ONLY!
--//OK STOP EDITING!
}
----------------------------------------
jFileName = "JokeBot.dat"
jJokesFile = "Jokes.txt"
jJokes = {}
jTable = {}
jTable.Interval = 3
jTable.On = 1
jVer = "v0.2"
min = 60000
function DataArrival(user, data)
if (string.sub(data, 1, 1) == "<" ) then
data= string.sub(data,1,string.len(data)-1)
------------
local _,_,c =strfind(data, "%b<>%s+(%S+)")
if jcmdF[c] then
local _,_,c,p1=strfind(data, "%b<>%s+(%S+)%s*(.*)")
jcmdF[c](user,p1)
return 1
end
------------
end
end
-------------------------
function Main()
local r = jFunctions.VerifyFile(jFileName)
if r ==1 then
dofile(jFileName)
end
r = jFunctions.VerifyFile(jJokesFile)
if r ==1 then
dofile(jJokesFile)
end
if jTable.On == 1 then
jTime = jTable.Interval * min
SetTimer(tonumber(jTime))
StartTimer()
end
if regBot == 1 then
frmHub:RegBot(jUserDefined.Botname)
end
end
-------------------------
function OnTimer()
jFunctions.doStuff()
end
----------------------------------------
jFunctions = {
doStuff = function()
joke = jJokes[math.random(table.getn(jJokes))]
if joke then
SendToAll(jUserDefined.Botname,joke)
end
end,
-------------------------
saveData = function(t,tn,file)
local data = jFunctions.Serialize(t, tn, "")
local f,e = io.open( file, "w+" )
if f then
io.write(f, data )
io.close(f)
end
end,
-------------------------
VerifyFile = function(file)
local f,e = io.open(file, "a+" )
if f then io.close(f) return 1
else
local _,_,path = string.find(file, "(.+[/_\\]).+$")
if path ~= nil then os.execute("mkdir ".."\""..string.gsub(path, "/", "\\").."\"") end
f,e = io.open( file, "a+" )
if f then io.close(f) return 2
else return 0 end
end
end,
-------------------------
Serialize = function(jTable, sTableName, sTab)
sTab = sTab or "";
sTmp = ""
sTmp = sTmp..sTab..sTableName.."={"
local tStart = 0
for key, value in jTable do
if tStart == 1 then
sTmp = sTmp..",\r\n"
else
sTmp = sTmp.."\r\n"
tStart = 1
end
local sKey = (string.type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
if(type(value) == "table") then
sTmp = sTmp..jFunctions.Serialize(value, sKey, sTab.."\t");
else
local sValue = (string.type(value) == "string") and string.format("%q",value) or tostring(value);
sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
end
end
sTmp = sTmp.."\r\n"..sTab.."}"
return sTmp
end,
}
---------------------------------------
jcmdF = {
[jUserDefined.jInvoke] = function()
jFunctions.doStuff()
end,
-------------------------
[jUserDefined.aJoke]= function(u,p1)
if p1 ~= "" then
table.insert(jJokes, p1)
u:SendData("*** Joke Bot "..jVer..": The Joke '"..p1.."' was added. ***")
jFunctions.saveData(jJokes, "jJokes", jJokesFile)
else
u:SendData("*** Joke Bot "..jVer..": Syntax Error. "..jHelp.." for help. ***")
end
end,
-------------------------
[jUserDefined.rJoke]= function(u,p1)
if not u.bOperator then return end
p1 = tonumber(p1)
if string.type(p1) =="number" then
if jJokes[p1] then
table.remove(jJokes, p1)
u:SendData("*** Joke Bot "..jVer..": Joke number '"..p1.."' was removed from the Jokes list. ***")
jFunctions.saveData(jJokes, "jJokes", jJokesFile)
else
u:SendData("*** Joke Bot "..jVer..": Error '"..p1.."' is not a valid Joke number. "..jView.." to view the Jokes list. ***")
end
else
u:SendData("*** Joke Bot "..jVer..": Syntax Error. "..jHelp.." for help. ***")
end
end,
-------------------------
[jUserDefined.jHelp] = function(u)
x = "*** Joke Bot "..jVer.." ***\r\n\r\n"..
"\t\t\t\t-=Help Menu=-\r\n\r\n"..
"\t"..jUserDefined.aJoke.." \t\tAdds a Joke to the list.\r\n"..
"\t"..jUserDefined.jInvoke.."\t\t\t\tInvoke a random joke.\r\n"
if u.bOperator then
x = x.."\t"..jUserDefined.rJoke.." \t\tRemoves a Joke from the list. ( = the index number from "..jUserDefined.jView.." to reomve)\r\n"..
"\t"..jUserDefined.jsInterval.." \t\t\tSet the interval in minutes for main chat jokes.\r\n"..
"\t"..jUserDefined.jOn.." / "..jUserDefined.jOff.."\t\tTurn Main Chat jokes On / Off\r\n"..
"\t"..jUserDefined.jView.."\t\t\t\tShows the current Jokes list index.\r\n"..
"\t"..jUserDefined.jSett.."\t\t\tShows the current Settings\r\n"..
"\t"..jUserDefined.jHelp.."\t\t\t\tTHIS.\r\n\r\n"
end
u:SendData(x)
end,
-------------------------
[jUserDefined.jView] = function(u)
if not u.bOperator then return end
x = "*** Joke Bot "..jVer.." ***\r\n\r\n"..
"\t-=Current Jokes List=-\r\n"..
"[Index Number] - Joke\r\n"..
"------------------------------------------------------------\r\n"
for i = 1,table.getn(jJokes) do
x = x.."["..i.."] - "..jJokes[i].."\r\n"
end
u:SendData(x)
end,
-------------------------
[jUserDefined.jSett] = function(u)
if not u.bOperator then return end
y = {[1] = "ON", [0] = "OFF"}
x = "*** Joke Bot "..jVer.." ***\r\n\r\n"..
"\t\t-=Settings=-\r\n\r\n"..
"\tJoke Bot is currently: "..y[jTable.On].."\r\n"..
"\tMain Chat Interval: "..jTable.Interval.." minute(s)\r\n"..
"\tNumber of Jokes: "..table.getn(jJokes).."\r\n\r\n"
u:SendData(x)
end,
-------------------------
[jUserDefined.jOn] = function(u)
if not u.bOperator then return end
jTable.On = 1
u:SendData("*** Joke Bot "..jVer.." Turned On ***")
jFunctions.saveData(jTable, "jTable", jFileName)
jTime = jTable.Interval * min
SetTimer(tonumber(jTime))
StartTimer()
end,
[jUserDefined.jOff] = function(u)
if not u.bOperator then return end
jTable.On = 0
u:SendData("*** Joke Bot "..jVer.." Turned Off ***")
jFunctions.saveData(jTable, "jTable", jFileName)
StopTimer()
end,
-------------------------
[jUserDefined.jsInterval] = function(u,p1)
if not u.bOperator then return end
p1 = tonumber(p1)
if string.type(p1) =="number" then
jTable.Interval = p1
u:SendData("*** Joke Bot "..jVer..": Main Chat interval set to '"..p1.."' minutes. ***")
jFunctions.saveData(jTable, "jTable", jFileName)
jTime = jTable.Interval * min
SetTimer(tonumber(jTime))
else
u:SendData("*** Joke Bot "..jVer..": Syntax Error. "..jHelp.." for help. ***")
end
end,
-------------------------
}
--//Joke Bot v0.2, by BottledHate (19/09/04)
-BH
edit: making all my bots play nice together sticking all
functions in tables... no no matter if 1 or 100 of them
loaded. finished lua5 compat...
i cant start that jokebot whatever i type it won't start....
i've tryed !jokeson
!joke +jokeson a.jokeson it wont start plzz help me with it......
and another thing.... i can't seem to vind the cmd for adding jokes to it......
Quotei can't seem to vind the cmd for adding jokes to it......
Dunno ehether case-sensitive, had 2 minutes:
aJoke = "!aJoke", --//
Try this quick-and-dirty mod for new PX.
--//Joke Bot v0.2
--//By: BottledHate
--//Requested by: 2000man
--//19/09/04(first release)
--//Did stuff to make it work with new px - bastya_elvtars
jUserDefined = {--//don't touch
--//edit the stuff in quotes to your liking:
Botname = "JokeBot",
regBot = 1, --// 1 = reg Botname.. 0 = don't reg Botname.
---------
jInvoke = "!Joke", --//invoke a random joke at any time.
aJoke = "!aJoke", --//
rJoke = "!rJoke", --//OPS ONLY!--// ( = joke index #.. use the view command to get index.)
jHelp = "!jHelp", --//displays the help list
jView = "!jView", --//OPS ONLY!--//displays the current list of jokes.
jsInterval = "!jInt", --//OPS ONLY!--// (number = time in minutes between joke posts)
jSett = "!jDispSet", --//OPS ONLY!--// display the current settings.
jOff = "!jokesOff", --//OPS ONLY!
jOn = "!jokesOn" ,--//OPS ONLY!
--//OK STOP EDITING!
}
----------------------------------------
jFileName = "JokeBot.dat"
jJokesFile = "Jokes.txt"
jJokes = {}
jTable = {}
jTable.Interval = 3
jTable.On = 1
jVer = "v0.2"
min = 60000
function ChatArrival(user, data)
data= string.sub(data,1,string.len(data)-1)
------------
local _,_,c =strfind(data, "%b<>%s+(%S+)")
if jcmdF[c] then
local _,_,c,p1=strfind(data, "%b<>%s+(%S+)%s*(.*)")
jcmdF[c](user,p1)
return 1
end
------------
end
-------------------------
function Main()
local r = jFunctions.VerifyFile(jFileName)
if r ==1 then
dofile(jFileName)
end
r = jFunctions.VerifyFile(jJokesFile)
if r ==1 then
dofile(jJokesFile)
end
if jTable.On == 1 then
jTime = jTable.Interval * min
SetTimer(tonumber(jTime))
StartTimer()
end
if regBot == 1 then
frmHub:RegBot(jUserDefined.Botname)
end
end
-------------------------
function OnTimer()
jFunctions.doStuff()
end
----------------------------------------
jFunctions = {
doStuff = function()
joke = jJokes[math.random(table.getn(jJokes))]
if joke then
SendToAll(jUserDefined.Botname,joke)
end
end,
-------------------------
saveData = function(t,tn,file)
local data = jFunctions.Serialize(t, tn, "")
local f,e = io.open( file, "w+" )
if f then
io.write(f, data )
io.close(f)
end
end,
-------------------------
VerifyFile = function(file)
local f,e = io.open(file, "a+" )
if f then io.close(f) return 1
else
local _,_,path = string.find(file, "(.+[/_\\]).+$")
if path ~= nil then os.execute("mkdir ".."\""..string.gsub(path, "/", "\\").."\"") end
f,e = io.open( file, "a+" )
if f then io.close(f) return 2
else return 0 end
end
end,
-------------------------
Serialize = function(jTable, sTableName, sTab)
sTab = sTab or "";
sTmp = ""
sTmp = sTmp..sTab..sTableName.."={"
local tStart = 0
for key, value in jTable do
if tStart == 1 then
sTmp = sTmp..",\r\n"
else
sTmp = sTmp.."\r\n"
tStart = 1
end
local sKey = (string.type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
if(type(value) == "table") then
sTmp = sTmp..jFunctions.Serialize(value, sKey, sTab.."\t");
else
local sValue = (string.type(value) == "string") and string.format("%q",value) or tostring(value);
sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
end
end
sTmp = sTmp.."\r\n"..sTab.."}"
return sTmp
end,
}
---------------------------------------
jcmdF = {
[jUserDefined.jInvoke] = function()
jFunctions.doStuff()
end,
-------------------------
[jUserDefined.aJoke]= function(u,p1)
if p1 ~= "" then
table.insert(jJokes, p1)
u:SendData("*** Joke Bot "..jVer..": The Joke '"..p1.."' was added. ***")
jFunctions.saveData(jJokes, "jJokes", jJokesFile)
else
u:SendData("*** Joke Bot "..jVer..": Syntax Error. "..jHelp.." for help. ***")
end
end,
-------------------------
[jUserDefined.rJoke]= function(u,p1)
if not u.bOperator then return end
p1 = tonumber(p1)
if string.type(p1) =="number" then
if jJokes[p1] then
table.remove(jJokes, p1)
u:SendData("*** Joke Bot "..jVer..": Joke number '"..p1.."' was removed from the Jokes list. ***")
jFunctions.saveData(jJokes, "jJokes", jJokesFile)
else
u:SendData("*** Joke Bot "..jVer..": Error '"..p1.."' is not a valid Joke number. "..jView.." to view the Jokes list. ***")
end
else
u:SendData("*** Joke Bot "..jVer..": Syntax Error. "..jHelp.." for help. ***")
end
end,
-------------------------
[jUserDefined.jHelp] = function(u)
x = "*** Joke Bot "..jVer.." ***\r\n\r\n"..
"\t\t\t\t-=Help Menu=-\r\n\r\n"..
"\t"..jUserDefined.aJoke.." \t\tAdds a Joke to the list.\r\n"..
"\t"..jUserDefined.jInvoke.."\t\t\t\tInvoke a random joke.\r\n"
if u.bOperator then
x = x.."\t"..jUserDefined.rJoke.." \t\tRemoves a Joke from the list. ( = the index number from "..jUserDefined.jView.." to reomve)\r\n"..
"\t"..jUserDefined.jsInterval.." \t\t\tSet the interval in minutes for main chat jokes.\r\n"..
"\t"..jUserDefined.jOn.." / "..jUserDefined.jOff.."\t\tTurn Main Chat jokes On / Off\r\n"..
"\t"..jUserDefined.jView.."\t\t\t\tShows the current Jokes list index.\r\n"..
"\t"..jUserDefined.jSett.."\t\t\tShows the current Settings\r\n"..
"\t"..jUserDefined.jHelp.."\t\t\t\tTHIS.\r\n\r\n"
end
u:SendData(x)
end,
-------------------------
[jUserDefined.jView] = function(u)
if not u.bOperator then return end
x = "*** Joke Bot "..jVer.." ***\r\n\r\n"..
"\t-=Current Jokes List=-\r\n"..
"[Index Number] - Joke\r\n"..
"------------------------------------------------------------\r\n"
for i = 1,table.getn(jJokes) do
x = x.."["..i.."] - "..jJokes[i].."\r\n"
end
u:SendData(x)
end,
-------------------------
[jUserDefined.jSett] = function(u)
if not u.bOperator then return end
y = {[1] = "ON", [0] = "OFF"}
x = "*** Joke Bot "..jVer.." ***\r\n\r\n"..
"\t\t-=Settings=-\r\n\r\n"..
"\tJoke Bot is currently: "..y[jTable.On].."\r\n"..
"\tMain Chat Interval: "..jTable.Interval.." minute(s)\r\n"..
"\tNumber of Jokes: "..table.getn(jJokes).."\r\n\r\n"
u:SendData(x)
end,
-------------------------
[jUserDefined.jOn] = function(u)
if not u.bOperator then return end
jTable.On = 1
u:SendData("*** Joke Bot "..jVer.." Turned On ***")
jFunctions.saveData(jTable, "jTable", jFileName)
jTime = jTable.Interval * min
SetTimer(tonumber(jTime))
StartTimer()
end,
[jUserDefined.jOff] = function(u)
if not u.bOperator then return end
jTable.On = 0
u:SendData("*** Joke Bot "..jVer.." Turned Off ***")
jFunctions.saveData(jTable, "jTable", jFileName)
StopTimer()
end,
-------------------------
[jUserDefined.jsInterval] = function(u,p1)
if not u.bOperator then return end
p1 = tonumber(p1)
if string.type(p1) =="number" then
jTable.Interval = p1
u:SendData("*** Joke Bot "..jVer..": Main Chat interval set to '"..p1.."' minutes. ***")
jFunctions.saveData(jTable, "jTable", jFileName)
jTime = jTable.Interval * min
SetTimer(tonumber(jTime))
else
u:SendData("*** Joke Bot "..jVer..": Syntax Error. "..jHelp.." for help. ***")
end
end,
-------------------------
}
--//Joke Bot v0.2, by BottledHate (19/09/04)
I bet Herodes will add the ability to set bot's desc, email, etc... :P - you have already experienced that I an not the man of decorations... functionality is enough for me. :))
this one i cant ecen start i keep getting the message scripts\jokes.lua:7: function arguments expected near `='....
QuoteOriginally posted by ~~~~?Master?~~~~
this one i cant ecen start i keep getting the message scripts\jokes.lua:7: function arguments expected near `='....
nope, no error like that here, just this one::
Syntax ...\My Documents\0.3.3.0.b17.03.nt.rls\scripts\joke.lua:137: bad argument #1 to `random' (interval is empty)
line 137:
jTime = jTable.Interval * min
is there a change that a jumble script can cause trubbles
with that script?
QuoteOriginally posted by ~~~~?Master?~~~~
is there a change that a jumble script can cause trubbles
with that script?
Nope, that's because you're not copying only what should be.
The problem must be in your script's first line. Can you copy it here?
Best regards,
jiten