Author Topic: Read from file to Main  (Read 2932 times)

0 Members and 1 Guest are viewing this topic.

Offline MDFP

  • Junior Member
  • **
  • Posts: 13
  • Karma: +0/-0
Read from file to Main
« on: 27 July, 2005, 23:38:35 »
Hi Guys

Here's is a script to read from .txt file to main chat.

Just complete the 2 "????" fields and enjoy





-- Comando read file to main feito por MDFP
-- Thanks to CONEJODELMAL
-- 27-07-2005

-- Place a .txt file on scripts folder


sConf = {
   sBot = frmHub:GetHubBotName(),
   sFile1 = "???.txt",                                            --## file name ##--
}
 
function ChatArrival(user,data)
   local data = string.sub(data,1,-2)
   local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
   if cmd then
      local tCmds =    {
         ["???"] =    function(user,data)            --## Command Name ##--
                  SendToAll(sConf.sBot,ReadFile(sConf.sFile1))
               end,
      }
      if tCmds[cmd] then  
         return tCmds[cmd](user,data), 1
      end
   end
end
 
function ReadFile(file)
   local fFile = io.open(file)
   if fFile then
      local message = ""
      for line in io.lines(file) do
         message = message..line.."\n"
      end
      fFile:close()
      return message
   else
      return file.." not found!"
   end
end



PtokaX forum

Read from file to Main
« on: 27 July, 2005, 23:38:35 »

Offline aL1en

  • Fulll Member
  • ****
  • Posts: 65
  • Karma: +0/-0
(No subject)
« Reply #1 on: 29 July, 2005, 20:56:06 »
can you make it show only to the user that types the command?

thanks!!

Offline aL1en

  • Fulll Member
  • ****
  • Posts: 65
  • Karma: +0/-0
(No subject)
« Reply #2 on: 30 July, 2005, 00:10:38 »
Quote
Originally posted by American Idiot
Code: [Select]
SendToAll(sConf.sBot,ReadFile(sConf.sFile1))
to

Code: [Select]
user:SendData(sConf.sBot,ReadFile(sConf.sFile1))


thanks ;)

Offline aL1en

  • Fulll Member
  • ****
  • Posts: 65
  • Karma: +0/-0
jooooo American Idiot
« Reply #3 on: 30 July, 2005, 07:20:51 »
do you think its possible to make this script read multiple txt's?

for exemple
sFile2 = "!sfv.txt"
sFile3 = "!activedc.txt"
sFile4 = "!rar.txt"


i dont like the idea of having one for each.. big waste..
this script very educative ;)

Offline James

  • Fulll Member
  • ****
  • Posts: 59
  • Karma: +0/-0
(No subject)
« Reply #4 on: 30 July, 2005, 07:40:19 »
LOL  MDFP...Your Script is old. Rules Script by Jiten  :D

Code: [Select]
-- rules by jiten

sConf = {
sBot = frmHub:GetHubBotName(),
sFile1 = "file1.txt",
ShowAll = true -- true/false to show all
}

function Main()
frmHub:RegBot(sConf.sBot)
end

function ChatArrival(user,data)
local data = string.sub(data,1,-2)
local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
if cmd then
local tCmds = {
["rules"] = function(user,data)
if sConf.ShowAll then
SendToAll(sConf.sBot,ReadFile(sConf.sFile1))
else
user:SendData(sConf.sBot,ReadFile(sConf.sFile1))
end
end,
}
if tCmds[cmd] then
tCmds[cmd](user,data)
end
end
end

function ReadFile(file)
local fFile = io.open(file)
if fFile then
local message = ""
for line in io.lines(file) do
message = message..line.."\n"
end
fFile:close()
return message
else
return file.." not found!"
end
end

Offline aL1en

  • Fulll Member
  • ****
  • Posts: 65
  • Karma: +0/-0
(No subject)
« Reply #5 on: 30 July, 2005, 17:25:57 »
Quote
Originally posted by aL1en
do you think its possible to make this script read multiple txt's?

for exemple
sFile2 = "!sfv.txt"
sFile3 = "!activedc.txt"
sFile4 = "!rar.txt"


i dont like the idea of having one for each.. big waste..
this script very educative ;)


got jitens fixed..
if anyone needs drop me a PM

Offline MDFP

  • Junior Member
  • **
  • Posts: 13
  • Karma: +0/-0
needed
« Reply #6 on: 14 September, 2005, 02:41:03 »
Hi James


If you dont mind i need theoriginal script from Jiten.
Can you post it?


Thanks


PtokaX forum

needed
« Reply #6 on: 14 September, 2005, 02:41:03 »