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
can you make it show only to the user that types the command?
thanks!!
QuoteOriginally posted by Mutor
SendToAll(sConf.sBot,ReadFile(sConf.sFile1))
to
user:SendData(sConf.sBot,ReadFile(sConf.sFile1))
thanks ;)
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 ;)
LOL MDFP...Your Script is old. Rules Script by Jiten :D
-- 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
QuoteOriginally 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
Hi James
If you dont mind i need theoriginal script from Jiten.
Can you post it?
Thanks
(http://img225.imageshack.us/my.php?image=musica5rs.jpg)