Hi all;)
I was wondering if it was posible, to get a script where I just have to insert a name of a text file and a cmd for it and then it will be shown to the user.... like "!OPstatus" and a pm will pop up...
here you go, but next time check the forum a little bit more...
-- texter bot by plop
-- thx 2 chilla for the faster routine for opening the files
-- shows text files from a folder named text.
-- doesn't mather what prefix it used.
-- if the file excist it shows.
Bot = "something"
FDFolder = "text"
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(FDFolder.."/"..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(FDFolder.."/"..cmd..".txt") then
showtext(user, cmd)
return 1
end
end
end
function showtext(user, file)
local handle = openfile(FDFolder.."/"..file..".txt", "r")
local contents = gsub(read(handle, "*a"),strchar(10), "\r\n")
closefile (handle)
user:SendPM(Bot, "\r\n"..contents.."\r\n|")
end
K, thanks... It works fine...