Timed mass message
 

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

Timed mass message

Started by -SkA-, 20 March, 2006, 10:08:49

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

-SkA-

I've tried to convert this script:
--Lua 5 By Dessamator(added message To Profile)
-- timed mass message from text by ??????Hawk??????
-- create a massmessage.txt file in the scripts directory
-- containing your message


CanDo = { 
[0] = 1, -- Master 
[1] = 1, -- Operator 
[2] = 1, -- VIP 
[3] = 1, -- Reg 
[4] = 1, -- Moderator 
[5] = 1, -- Netfounder 
[-1] =0, -- User 
} 

SendEvery = 1   ----  time in Mins
textfile = "massmessage.txt"
bot = frmHub:GetHubBotName()
hrs = 1000 * 60 * SendEvery


function Main()
	SetTimer(hrs)
	StartTimer()
end





function OnTimer()
	local handle = io.open(textfile, "r") 
	if (handle ~= nil) then 
                 Temptimerfile = "\r\n"
		for line in (io.lines(textfile)) do 
			Temptimerfile = Temptimerfile.."\r\n"..line
			io.read() 
		end 
		for prf,sw in ipairs(CanDo) do
			if sw == 1 then
				for pos,user in pairs (frmHub:GetOnlineUsers(prf)) do		
					user:SendPM(bot, Temptimerfile) 
				end
			end
		end
	end
	io.close() 
end


but I got this error:

timedoriginal.lua:48: attempt to use a closed file

Any idea?

???:::??x??em?-N????:::??? ?wN??

BrianzaLand Blog" style="border:0

bastya_elvtars

#1
--Lua 5 By Dessamator(added message To Profile)
-- cleanup/optimization by bastya_elvtars
-- timed mass message from text by ?~??o?Hawk?o??~?
-- create a massmessage.txt file in the scripts directory
-- containing your message

CanDo =
{
[0] = 1, -- Master
[1] = 1, -- Operator
[2] = 1, -- VIP
[3] = 1, -- Reg
[4] = 1, -- Moderator
[5] = 1, -- Netfounder
[-1] =0, -- User
}

SendEvery = 1   ----  time in Mins

textfile = "massmessage.txt"

bot = frmHub:GetHubBotName()

hrs = 1000 * 60 * SendEvery
-------------------------------------------------------------
-------------------------------------------------------------
function Main()
SetTimer(hrs)
StartTimer()
end

function OnTimer()
	local handle = io.open(textfile, "r")
	if handle then
		Temptimerfile = "\r\n"..string.gsub(handle:read("*a"),string.char(10), "\r\n")
		for _,user in ipairs (frmHub:GetOnlineUsers()) do
			if CanDo[user.iProfile]==1 then
				user:SendPM(bot, Temptimerfile)
			end
		end
		handle:close()
	end
end
Everything could have been anything else and it would have just as much meaning.

-SkA-

#2
Uhm... no errors from gui but I can't receive any mass message? ???

Edit: If I login with profile 0 it doesn't works, but with profile 1 it works well
???:::??x??em?-N????:::??? ?wN??

BrianzaLand Blog" style="border:0

bastya_elvtars

Try the above again, edited & optimized.
Everything could have been anything else and it would have just as much meaning.

-SkA-

timedmessage.lua:35: attempt to index global 'f' (a nil value)
???:::??x??em?-N????:::??? ?wN??

BrianzaLand Blog" style="border:0

bastya_elvtars

Everything could have been anything else and it would have just as much meaning.

-SkA-

???:::??x??em?-N????:::??? ?wN??

BrianzaLand Blog" style="border:0

((KMN))Gazza-95

is there any way you can have more than 1 timed mass message

Dessamator

Ignorance is Bliss.

Thor

Here is the extended version of TXT-show by bastya elvtars.
-- Txtshow by bastya_elvtars
-- At preconfigured times it shows a text file.
Botname = frmHub:GetHubBotName()
command = "!getmass"
HubAD={
	["18:00"]="blabla.txt",
	["22:33"]="thx.txt",
	["01:21"]="ReadMe.txt",}
_=[[
["HH:MM"]="filename.txt",
Can even be 18:33 if this is your perversion :)
Does not have to be a textfile reachable by command as well. :)
A textfile can be bound to any number of timestamps.
Just comment a line if you do not need it any longer, or rename the file to a non-existant.
Or, delete the file (if a file does not exist, there are gonna be no errors).
]] 

-- The folder where your text files reside
-- Warning: NOT \ but /
folder = frmHub:GetPtokaXLocation().."scripts/massmessages/"

-- // Don't edit below.

Timer=0

function OnTimer()
local now=os.date("%H:%M")
	if Timer~=60 then
	Timer=Timer+1
	else
		if HubAD[now] then
		local f=io.open(folder.."/"..HubAD[now],"r")
			if f then
			local contents = string.gsub(f:read("*a"),string.char(10), "\r\n")
			SendPmToAll(Botname,"\r\n"..contents.."\r\n")
			f:close()
			end
		end
	Timer=0
	end
end

function Main()
	SetTimer(1000)
	StartTimer()
end

function ChatArrival(curUser,data)
data = string.sub(data,1,string.len(data)-1)
local s,e,cmd = string.find(data,"%b<>%s(%S+)")
	if cmd == command and curUser.bOperator then
		local lista = "\r\n\tMass messages:\r\n"
		for key,value in HubAD do
		lista = lista.."\r\n\tTime: "..key.."\tFilename:\t"..value..""
		end
		curUser:SendPM(Botname, lista)
	return 1
	end
end

Just make a massmessages folder into the scripts folder, then put all txt files what you want to send. Then in the start of the script set up the messages in ["when"] = "what" format. I put the code the !getmass command to easily check when will send what.

((KMN))Gazza-95


SMF spam blocked by CleanTalk