PtokaX forum

Archive => Archived 4.0 boards => Finished Lua 4 scripts => Topic started by: ((UKSN))shad_dow on 03 July, 2004, 13:21:27

Title: --// Therapy-X? simple HelpBot- v0.01
Post by: ((UKSN))shad_dow on 03 July, 2004, 13:21:27
--// Therapy-X?  simple HelpBot- v0.01
--//
--// Simple help bot which reads any text file from the  txt folder
--// example, txt I Love Ptokax.txt > type in main !read I Love Ptokax
--// example2, Rules.txt > type in main !read  rules
--//
--// Written by shad_dow?    may 2004


--// Bits u can change

Bot = "-=Help-Bot=-" --// change -=Help-Bot=- to what ever u like

--// Main script below ,if u modify do so @ own risk ;)

function Main()
frmHub:RegBot(Bot)
end

function DataArrival(user,data)
if(strsub(data,1,1) == "<" ) then
data = strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data, "%b<>%s+(%S+)") --// it works :) @ last
if  (cmd == "!read")then
local _,_,cmd,txtname = strfind( data, "%b<>%s+(%S+)%s+(.+)" )
if ( txtname  == nil) then
user:SendData(Bot, "Syntax error, try !read  .")
        return 1
else
readfrom("text/"..txtname..".txt")
local message = ""
while 1 do
local line = read()
if line == nil then
break
else
message = message..line.."\r\n"
end
end
user:SendPM(Bot,message)
return 1
end
end
end
end


:)