Read from file to Main
 

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

Read from file to Main

Started by MDFP, 27 July, 2005, 23:38:35

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MDFP

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



aL1en

can you make it show only to the user that types the command?

thanks!!

aL1en

QuoteOriginally posted by Mutor
SendToAll(sConf.sBot,ReadFile(sConf.sFile1))

to

user:SendData(sConf.sBot,ReadFile(sConf.sFile1))


thanks ;)

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 ;)

James

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

aL1en

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

MDFP

Hi James


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


Thanks


SMF spam blocked by CleanTalk