Need Help!!!
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Need Help!!!

Started by MDFP, 27 July, 2005, 04:02:27

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MDFP

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.

imby

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.

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

imby

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

SMF spam blocked by CleanTalk