how to change this script so the txt shows in mainchat?
-- texter bot by plop
-- shows text files from a folder named text.
-- doesn't mather what prefix is used.
-- if the file excist it shows.
Bot = "textbot"
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
Hi,
Done...
-- texter bot by plop
-- shows text files from a folder named text.
-- doesn't mather what prefix is used.
-- if the file excist it shows.
Bot = "textbot"
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
[b]user:SendData(Bot, lines.." |")[/b]
end
Best regards, nErBoS
thx a lot m8
:)