Subscribe / Unsubscribe Bot?
 

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

Subscribe / Unsubscribe Bot?

Started by BlazeXxX, 23 March, 2004, 01:21:53

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

BlazeXxX

Hey folks,
I am planning to have a Messaging list a.k.a mailing list on web. I need a script that allows anyone from Unreged users to SU to subscribe them self to this system. Only People who are ops and Higher should be able to message to those subscribers. Its more like mass messaging to specific profile, but this one is going to read from a text file or some sort.

So for e.g.

!subscribe me      - this shud subscribe whoever is typing the command

!unsubscribe me  - This shud remove them from the messaging list

!subscribe   - This is for ops and higher to add ppl in the list manually

!unsubscribe - This shud remove them from messaing list, again only for ops and above.

The nick name should be there even if its 200 days, only it shud be removed upon unsubscribing.

The reason i am needing this script is, I have users who wants upto date news on things like whats happenig around, what site updates i made etc.. So this shud allow me to  mass msg those who are in the list.

I am pretty sure this can be done on hub side, so please cud someone give it a try? I don't want it taking too much memory, so must be pretty good for general usuage :)

Thanks in advance!

-BlazeXxX

nErBoS

#1
Hi,

Hope it helps...

--Requested by BlazeXxX
--Made by nErBoS

Bot = "Submiter-Bot"

masstxt = "mass.txt" --Put where the text to be read
submiters = "submiters.txt" --Will be created in the script folder
mass = nil

function Main()
	frmHub:RegBot(Bot)
end

function DataArrival(user, data)
	if (strsub(data,1,1)=="<") or (strsub(data,1,5+strlen(Bot))=="$To: "..Bot) then
	data=strsub(data,1,strlen(data)-1)
	s,e,cmd = strfind(data,"%b<>%s+(%S+)")
		if (cmd=="!subscribe") then
			local s,e,who = strfind(data,"%b<>%s+(%S+)%s+(%S+)")
			if (who == nil or who == "") then
				WriteUser(user, user.sName)
			else
				if (user.bOpertor) then
					WriteUser(user, who)
				else
					user:SendPM(Bot, "You don't have permission to put users in the submiters list.")
				end
			end
			return 1
		elseif (cmd=="!unsubscribe") then
			local s,e,who = strfind(data,"%b<>%s+(%S+)%s+(%S+)")
			if (who == nil or who == "") then
				RemoveUser(user, user.sName)
			else
				if (user.bOpertor) then
					RemoveUser(user, who)
				else
					user:SendPM(Bot, "You don't have permission to remove users from the submiters list.")
				end
			end
			return 1
		elseif (cmd=="!massnews") then
			if (user.bOperator) then
				MassMess(user)
			else
				user:SendPM(Bot, "You don't have permission to use this command.")
			end
		end
	end
end

function WriteUser(user, whoto)
local tmp = ""
local time = 0
	if (readfrom(submiters) == nil) then
		writeto(submiters)
		write(usr.."\r\n")
		writeto()
	else
		readfrom(submiters)
		while 1 do
		local line = read()
			if (line == nil) then
				if (time == 0) then
					user:SendPM(Bot, "The user "..whoto.." has been added to the list.")
					tmp = tmp..usr.."\r\n"
				else
					user:SendPM(Bot, "The user "..whoto.." is already in the list.")
				end
				break
			else
				local s,e,who = strfind(line, "(%S+)")
				if (who ~= nil and who == whoto) then
					time = 1
				else
					tmp = tmp..line.."\r\n"
				end
			end
		end
		readfrom()
	end
end

function RemoveUser(user, whoto)
local tmp = ""
local time = 0
	if (readfrom(submiters) == nil) then
		user:SendPM(Bot, "The file with the submitted users was not found.")
	else
		readfrom(submiters)
		while 1 do
		local line = read()
			if (line == nil) then
				if (time == 0) then
					user:SendPM(Bot, "The user "..whoto.." wasn?t found in the list.")
				else
					user:SendPM(Bot, "The user "..whoto.." was removed from the list.")
				end
				break
			else
				local s,e,who = strfind(line, "(%S+)")
				if (who ~= nil and who == whoto) then
					time = 1
				else
					tmp = tmp..line.."\r\n"
				end
			end
		end
		readfrom()
		writeto(submiters)
		write(tmp)
		writeto()
	end
end

function MassMess(user)
local tmp = ""
	if (readfrom(masstxt) == nil) then
		user:SendPM(Bot, "The file with the news wasn't found.")
	else
		readfrom(submiters)
		while 1 do
		local line = read()
			if (line == nil) then
				break
			else
				local s,e,who = strfind(line, "(%S+)")
				if (GetItemByName(who) ~= nil) then
					if (mass == nil) then
						mass = ReadText()
					end
					GetItemByName(who):SendPM(Bot, mass)
				end
			end
		end
		readfrom()
		user:SendPM(Bot, "Message sent.")
	end
end

function ReadText()
local tmp = ""
	readfrom(masstxt)
	while 1 do
	local line = read()
		if (line == nil) then
			break
		else
			tmp = tmp..line.."\r\n"
		end
	end
return tmp
end

I haven?t tested it. But think that will work :)

Best regards, nErBoS
--## nErBoS Spot ##--

BlazeXxX

wow that was fast. I will test it tommorow and let u know. thx in advance, looks like it will work :D.

SMF spam blocked by CleanTalk