PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: Smulf on 16 January, 2004, 17:14:03

Title: Commands or other
Post by: Smulf on 16 January, 2004, 17:14:03
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...
Title:
Post by: NightLitch on 16 January, 2004, 17:50:05
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
Title:
Post by: Smulf on 17 January, 2004, 12:34:10
K, thanks... It works fine...