hi
i just would like to get/have/ simple script code that would let someone who was in my hub or me even to type say "#help" and then then it to load text stored in a text file say "help.txt" can anyone help me out here?
thankyou
please can i get a little help? it would be really really appreciated. from the likes of phatty etc
thankyou!
here is a script
sBotName = "HELP-O-BOT"
sRulesFileName = "help.txt"
function Main()
frmHub:RegBot(sBotName)
end
function DataArrival(user,data)
if (strsub(data, 1, 1) == "<" ) then
-- remove end pipe
data=strsub(data,1,strlen(data)-1)
--extract command
_,_,cmd=strfind(data, "%b<>%s+(%S+)")
--check if cmd exist
if not cmd then cmd = "0" end
-- make the cmd caseinsensitive
cmd = strlower(cmd)
-- get the command prefix
cmdprefix = strsub(cmd, 1,1)
-- check if the cmd prefix is !,+,# or ?
if cmdprefix == "!" or cmdprefix == "+" or cmdprefix == "#" or cmdprefix == "?" then
-- Remove the prefix and check the command
cmd = strsub(cmd, 2,strlen(cmd))
if cmd = "help" then
fFileHandle, sError = readfrom(sRulesFileName)
local sLine = read()
local sFileContent = ""
if sLine then
sFileContent = sLine
while 1 do
sLine = read()
if not sLine then
break
else
sFileContent = sFileContent..sLine.."\r\n"
end
end
readfrom() -- close filehandle
user:SendPM(sBotName,sFileContent)
return 1
elseif fFileHandle
user:SendPM(sBotName,"Nothing found in "..sRulesFileName)
return 1
else
user:SendPM(sBotName,"Error "..sError)
end
readfrom()
end
end
end
end
Syntax Error: `then' expected;
last token read: `=' at line 24 in string "sBotName = "HELP-O-BOT"
..."
change this
if cmd = "help" then
for this
if cmd == "help" then
plop
Syntax Error: `then' expected;
last token read: `user' at line 42 in string "sBotName = "hbot"
..."
sBotName = "hbot"
sRulesFileName = "help.txt"
function Main()
frmHub:RegBot(sBotName)
end
function DataArrival(user,data)
if (strsub(data, 1, 1) == "<" ) then
-- remove end pipe
data=strsub(data,1,strlen(data)-1)
--extract command
_,_,cmd=strfind(data, "%b<>%s+(%S+)")
--check if cmd exist
if not cmd then cmd = "0" end
-- make the cmd caseinsensitive
cmd = strlower(cmd)
-- get the command prefix
cmdprefix = strsub(cmd, 1,1)
-- check if the cmd prefix is !,+,# or ?
if cmdprefix == "!" or cmdprefix == "+" or cmdprefix == "#" or cmdprefix == "?" then
-- Remove the prefix and check the command
cmd = strsub(cmd, 2,strlen(cmd))
if cmd == "help" then
fFileHandle, sError = readfrom(sRulesFileName)
local sLine = read()
local sFileContent = ""
if sLine then
sFileContent = sLine
while 1 do
sLine = read()
if not sLine then
break
else
sFileContent = sFileContent..sLine.."\r\n"
end
end
readfrom() -- close filehandle
user:SendPM(sBotName,sFileContent)
return 1
elseif fFileHandle
user:SendPM(sBotName,"Nothing found in "..sRulesFileName)
return 1
else
user:SendPM(sBotName,"Error "..sError)
end
readfrom()
end
end
end
end
------------------------------------------------------
Syntax Error: `then' expected;
last token read: `user' at line 42 in string "sBotName = "hbot"
..."
didn't u test this?
all i want is to type #help
and get help.txt to open
in a PM window to who ever types it.
-------------------------------------------------------
i didn't think it would be OTT considering some of the scripts u see on the forum.
as always thankyou v.much appreciated
Damn :/
lol i got it to be fixed. sigh your soo useless. joke :rolleyes:
sBotName = "hbot"
sRulesFileName = "help.txt"
function Main()
frmHub:RegBot(sBotName)
end
function DataArrival(user,data)
if (strsub(data, 1, 1) == "<" ) then
-- remove end pipe
data=strsub(data,1,strlen(data)-1)
--extract command
_,_,cmd=strfind(data, "%b<>%s+(%S+)")
--check if cmd exist
if not cmd then cmd = "0" end
-- make the cmd caseinsensitive
cmd = strlower(cmd)
-- get the command prefix
cmdprefix = strsub(cmd, 1,1)
-- check if the cmd prefix is !,+,# or ?
if cmdprefix == "!" or cmdprefix == "+" or cmdprefix == "#" or cmdprefix == "?" then
-- Remove the prefix and check the command
cmd = strsub(cmd, 2,strlen(cmd))
if cmd == "help" then
fFileHandle, sError = readfrom(sRulesFileName)
local sLine = read()
local sFileContent = ""
if sLine then
sFileContent = sLine
while 1 do
sLine = read()
if not sLine then
break
else
sFileContent = sFileContent..sLine.."\r\n"
end
end
readfrom() -- close filehandle
user:SendPM(sBotName,sFileContent)
return 1
elseif fFileHandle then
user:SendPM(sBotName,"Nothing found in "..sRulesFileName)
return 1
else
user:SendPM(sBotName,"Error "..sError)
end
readfrom()
end
end
end
end
----------------------------
and it works!!! - all i want now is to get it to open up in a Pm window :P
haha it is in a window "SendPM"
it does i'm so stupid
and ideas on how to get it to do another command like #network without having to write the same code time and time again?
cheers.
Bot = "Helper"
textArray = {}
QWarray = {}
antall = 0
function Main()
frmHub:RegBot(Bot)
loadText()
getLine()
end
function OnTimer()
getLine()
end
-- Triggers
TriggerPrivate = {
- ["+newbie"]="newbie.txt",
- ["+rules"]="rules.txt",
}
function DataArrival(curUser, sData)
if( strsub(sData, 1, 1) == "<" ) then
-- get the msg only using regular expression
s,e,msg = strfind(sData, "%b<> ([ -z]*)")
if (msg == "+rules") then
local text1 = ""
readfrom("rules.txt.txt")
while 1 do
local line = read()
if (line == nil) then
break
else
text1 = text1..line.."\r\n"
end
end
readfrom()
local text2 = ""
readfrom("newbie.txt")
while 1 do
local line = read()
if (line == nil) then
break
else
text2 = text2..line.."\r\n"
end
end
readfrom()
end
end
if( strsub(sData, 1, 1) == "<" ) or ( strsub(sData, 1, 4) == "$To:") then
s,e,msg = strfind(sData, "%b<> ([ -z]*)")
for key, value in TriggerPrivate do
if( strfind( strlower(msg), key) ) then
answer, x = gsub(value, "%b[]", curUser.sName)
local text = ""
readfrom(answer)
while 1 do
local line = read()
if (line == nil) then
break
else
text = text..line.."\r\n"
end
end
SendPmToNick(curUser.sName, Bot, text)
end
readfrom()
end
Syntax Error: `end' expected (to close `if' at line 68);
last token read: `' at line 89 in string "-- Defines the name of the bot
..."
Bot = "Helper"
textArray = {}
QWarray = {}
antall = 0
function Main()
frmHub:RegBot(Bot)
loadText()
getLine()
end
function OnTimer()
getLine()
end
-- Triggers
TriggerPrivate = {
- ["+newbie"]="newbie.txt",
- ["+rules"]="rules.txt",
}
function DataArrival(curUser, sData)
if( strsub(sData, 1, 1) == "<" ) then
-- get the msg only using regular expression
s,e,msg = strfind(sData, "%b<> ([ -z]*)")
if (msg == "+rules") then
local text1 = ""
readfrom("rules.txt.txt")
while 1 do
local line = read()
if (line == nil) then
break
else
text1 = text1..line.."\r\n"
end
end
readfrom()
local text2 = ""
readfrom("newbie.txt")
while 1 do
local line = read()
if (line == nil) then
break
else
text2 = text2..line.."\r\n"
end
end
readfrom()
end
end
if( strsub(sData, 1, 1) == "<" ) or ( strsub(sData, 1, 4) == "$To:") then
s,e,msg = strfind(sData, "%b<> ([ -z]*)")
for key, value in TriggerPrivate do
if( strfind( strlower(msg), key) ) then
answer, x = gsub(value, "%b[]", curUser.sName)
local text = ""
readfrom(answer)
while 1 do
local line = read()
if (line == nil) then
break
else
text = text..line.."\r\n"
end
end
SendPmToNick(curUser.sName, Bot, text)
end
readfrom()
end
Syntax Error: `end' expected (to close `if' at line 68);
last token read: `' at line 89 in string "-- Defines the name of the bot
..."
can u help me fix that?
thanx to sha_dow
rewriten the whole thing.
make a folder named text, place in that all text files you want this bot 2 be able 2 show.
if the file is called rules.txt you can trigger it with !rules/+rules/#rules/Arules.
doesn't mather what prefix a user uses as long as it's 1 character and the file excists it works.
-- texter bot by plop
-- shows text files from a folder named text.
-- doesn't mather what prefix it used.
-- if the file excist it shows.
Bot = "something"
function Main()
frmHub:RegBot(Bot)
end
function DataArrival(user, data)
data=strsub(data,1,strlen(data)-1)
if( strsub(data, 1, 1) == "<" ) then
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
cmd = strsub(cmd, 2,strlen(cmd))
if readfrom("text/"..cmd..".txt") then
showtext(user, cmd)
return 1
end
elseif(strsub(data, 1, 4) == "$To:") then
s,e,cmd = strfind(data,"$To:%s+%S+%s+From:%s+%S+%s+$%b<>%s+(%S+)")
cmd = strsub(cmd, 2,strlen(cmd))
if readfrom("text/"..cmd..".txt") then
showtext(user, cmd)
return 1
end
end
end
function showtext(user, cmd)
lines = "\r\n\r\n"
readfrom("text/"..cmd..".txt")
while 1 do
local line = read()
if line == nil then
readfrom()
break
end
lines = lines..line.."\r\n"
end
user:SendPM(Bot, lines.." |")
end
plop
on the other hand you cud have went to this thread
i wrote a long time ago............
http://board.univ-angers.fr/thread.php?threadid=46&boardid=12&styleid=1&sid=6fac38ac3b3103906d8ee71e4ec1b27c (http://board.univ-angers.fr/thread.php?threadid=46&boardid=12&styleid=1&sid=6fac38ac3b3103906d8ee71e4ec1b27c)
l8rr,,
-phatty
QuoteOriginally posted by (uk-kingdom)pH?tt?
on the other hand you cud have went to this thread
i wrote a long time ago............
http://board.univ-angers.fr/thread.php?threadid=46&boardid=12&styleid=1&sid=6fac38ac3b3103906d8ee71e4ec1b27c (http://board.univ-angers.fr/thread.php?threadid=46&boardid=12&styleid=1&sid=6fac38ac3b3103906d8ee71e4ec1b27c)
l8rr,,
-phatty
lol would have been a way easyer thing indeed.
next time pls tell me before i write something. lol
plop
lol oooops 8o
cheers PLOP (what a name).
thanx to phatty. only thing about ur bots though there OTT they always have to go the extra mile and i preferr the simpl'er version by plop . . . like the black listing thing.
i can post a script later
QuoteOriginally posted by mmx
cheers PLOP (what a name).
yw.
my name isn't so weird if you are from the netherlands (http://www.kabouterplop.nl) / belgium (http://www.studio100.be/plop/default.asp)
plop