Hi people.
I have this script to read a text file to a PM.
sConf = {
sBot = frmHub:GetHubBotName(),
sFile1 = "trafego.txt",
}
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 = {
["trafego"] = function(user,data)
user:SendPM(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
Could someone of "master-scripters" :) chande this to read the same file to Main chat?
Thanks.
I'm afraid this doesn't require a master scripter :P I'm pretty dire at scripting, but changing:
user:SendPM(sConf.sBot,ReadFile(sConf.sFile1))
to
user:SendData(sConf.sBot,ReadFile(sConf.sFile1))
should work.
Thanks guys (IMBY)
I've read the script and have changed this
function(user,data)
SendPM(sConf.sBot,ReadFile(sConf.sFile1))
to this
function(user,data)
SendToAll(sConf.sBot,ReadFile(sConf.sFile1))
Thanks anyway.
Entire Script
-- Comando comandos amigos feito por Hahn?
-- Pedido por MDFP
-- Modificado por MDFP (Show on main)
-- Thanks to CONEJODELMAL
-- 22-07-2005
sConf = {
sBot = frmHub:GetHubBotName(),
sFile1 = "comandos.txt",
}
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 = {
["cmds"] = function(user,data)
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
QuoteOriginally posted by MDFP
Thanks guys (IMBY)
I've read the script and have changed this
function(user,data)
SendPM(sConf.sBot,ReadFile(sConf.sFile1))
to this
function(user,data)
SendToAll(sConf.sBot,ReadFile(sConf.sFile1))
Thanks anyway.
Entire Script
-- Comando comandos amigos feito por Hahn?
-- Pedido por MDFP
-- Modificado por MDFP (Show on main)
-- Thanks to CONEJODELMAL
-- 22-07-2005
sConf = {
sBot = frmHub:GetHubBotName(),
sFile1 = "comandos.txt",
}
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 = {
["cmds"] = function(user,data)
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
Ah ok, mis-understood your request