Rotating Message - Page 2
 

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

Rotating Message

Started by jiten, 03 May, 2005, 20:45:25

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jiten

-- Rotating Message 1.1 by jiten - for PtokaX 0.3.3.0 build 16.09 or Higher
-- based on Rotating Message 1.0 by Mutor The Ugly
-- Rotates n text files posted to main chat at interval
-- Added: Rotates every .txt file stored in sFolder (by kepp)
-- Added: Text file sending by own trigger (Prefix - Filename)

mSet = {
	sBot = frmHub:GetHubBotName(),	-- Bot Name
	RunStatus = 0,			-- Auto Start -> 1=ON 0=OFF
	iDelay = 30,			-- Delay between each text file in minutes
	sFolder = "txt",		-- Folder where all the .txt files are stored
	-- Don't change this
	iCnt = 1,
}

sFile = {}

Main = function()
	ReloadText()
	SetTimer(mSet.iDelay*60*1000) 
	if (mSet.RunStatus == 1) then
		StartTimer()
	end
end 


ChatArrival = function(sUser, sData)
	sData=string.sub(sData,1,-2)
	local s,e,cmd = string.find(sData, "%b<>%s+[%!%?%+%#](%S+)" )
	if sUser.bOperator then
		local tCmds = {
		["adon"] =	function(user,data)
					mSet.RunStatus = 1
					user:SendData(mSet.sBot,"Messages started...")
					StartTimer()
				end,
		["adoff"] =	function(user,data)
					mSet.RunStatus = 0
					user:SendData(mSet.sBot,"Messages stopped...")
					StopTimer()
				end,
		["reload"] =	function(user,data)
					ReloadText()
					user:SendData(mSet.sBot,"Textfiles loaded...")
				end,
		}
		if tCmds[cmd] then
			return tCmds[cmd](sUser,sData),1
		else
			local sContent = FileExists(mSet.sFolder.."/"..cmd..".txt")
			if (sContent) then
				return sUser:SendData(mSet.sBot,"\r\n"..sContent),1 
			end
		end
	end
end

OnTimer = function()
	local TableSize = table.getn(sFile)
	for i=1,TableSize do
		if (i == mSet.iCnt) then
			local sContent = FileExists(mSet.sFolder.."/"..sFile[i])
			if (sContent) then
				SendToAll(mSet.sBot,"\r\n"..sContent)
			end
			if (TableSize == i) then mSet.iCnt = 1 else mSet.iCnt = mSet.iCnt + 1 end
			break
		end
	end
end

function FileExists(sFile)
	local oFile = io.open(sFile,"r");
	if (oFile) then
		local line = oFile:read("*all");
		oFile:close();
		return string.gsub(line,"\r","\r\n");
	else
		return nil;
	end
end

function ReloadText()
	sFile = nil;
	sFile = {};
	collectgarbage();

	--// Load up files to table from folder \\--
	os.execute("dir /b "..mSet.sFolder.."\\*.txt > files.txt");
	local hFile = io.open("files.txt","r");
	local line = hFile:read();
	while line do
		table.insert(sFile,1,line)
		line = hFile:read();
	end
	hFile:close();
	os.remove("files.txt");
end
Cheers

BeeR

after 2-3 days of rotating it stops sending mess to main,,
must restartscripts to start rotating again
A cold BeeR is stunning !!

Dessamator

QuoteOriginally posted by BeeR
after 2-3 days of rotating it stops sending mess to main,,
must restartscripts to start rotating again

lol, it runs out of fuel?, make sure some other script doesnt interfere with that, in theory it should run indefinitely, :)
Ignorance is Bliss.

BeeR

QuoteOriginally posted by Dessamator
QuoteOriginally posted by BeeR
after 2-3 days of rotating it stops sending mess to main,,
must restartscripts to start rotating again

lol, it runs out of fuel?, make sure some other script doesnt interfere with that, in theory it should run indefinitely, :)
Theory and reality can be 2 differnt thing :]
A cold BeeR is stunning !!

Dessamator

#29
indeed, but give us more info, did u change anything in the script,like  the timer interval, and doesnt it show any syntax error in ptokax ???, because if there are bugs with it, it should stop sooner than that !

btw, i just tested the script  for 10 mins with a 1 sec interval to send each txt, if it was a script problem it would have stopped in less than 5 mins, so theres obviously something wrong there in ur hub, :)
Ignorance is Bliss.

jiten

QuoteOriginally posted by BeeR
after 2-3 days of rotating it stops sending mess to main,,
must restartscripts to start rotating again
Can you run it for more 2/3 days and see if that error happens again and check if AutoStart is on by default?

As Dessamator said, it should be running fine...

Cheers

BeeR

QuoteOriginally posted by jiten
QuoteOriginally posted by BeeR
after 2-3 days of rotating it stops sending mess to main,,
must restartscripts to start rotating again
Can you run it for more 2/3 days and see if that error happens again and check if AutoStart is on by default?

As Dessamator said, it should be running fine...

Cheers

yes autostart is on and i dont get a syntax error on it - it just stops ,,
maybe it interfere with clever janina or my jokebot ,,

i do some more tests
A cold BeeR is stunning !!

xvk

hi
i already have a folder in my script folder called txt changed this sFolder = "Messages",      -- Folder where all the .txt files are stored
and made a folder called Messages but getting error texter.lua:99: attempt to concatenate local `cmd' (a nil value)

any ideas please

jiten

QuoteOriginally posted by xvk
hi
i already have a folder in my script folder called txt changed this sFolder = "Messages",      -- Folder where all the .txt files are stored
and made a folder called Messages but getting error texter.lua:99: attempt to concatenate local `cmd' (a nil value)

any ideas please
Hi xvk.
That's strange. I did the same you wrote and didn't get any error. Working fine here.
Did you change anything else in the script?
Maybe if you change the script loading error in PtokaX...

Best regards

Honey

Hi folks,

I have two things.

1) Thank you very much to all for this great script.

2. And thats my problem:
I write into ABC.txt this: Hello all users on my hub!

But script write into mainchat this:

Hello all users on my hub!

It is possible to do that the script write the message on the first line, like this: Hello all users on my hub!

I think, that script write message into main chat exactly how I write this message into .txt file: eg.
Into .txt file:
(1st line)
(2nd line)
(3rd line) Hello all users on my hub!

and into chat script write:
(1st line)
(2nd line)
3rd line)Hello all users on my hub!

It is this possbile to do, please?

Thank you in advance for help!

 Honey

java

Is it possible modify the rotating message (for build 17.02 or higher) so that it start automatically by default, and cant be stopped any other way then by stopping the script in hubsoft?

Dessamator

QuoteOriginally posted by java
Is it possible modify the rotating message (for build 17.02 or higher) so that it start automatically by default, and cant be stopped any other way then by stopping the script in hubsoft?

Yes
Ignorance is Bliss.

java

What a helpfull reply. :P

Is there anybody who can tell me how to modify it to work like that  then?

java


SMF spam blocked by CleanTalk