Mass message unregged users
 

News:

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

Mass message unregged users

Started by Optimus, 30 March, 2005, 19:12:56

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Optimus

-- Message Unregged Users
-- Made by Optimus
-- 03/30/05

sBot = "BotName"

Main = function()
	frmHub:RegBot(sBot)
end

ChatArrival = function(user, data)
	data=string.sub(data,1,string.len(data)-1)
	s,e,cmd=string.find(data, "%b<>%s+(%S+)")
	if (cmd == "!messunreg") then
		if user.bOperator then			
			local s,e,cmd,message = string.find(data,"%b<>%s+(%S+)%s+(.*)")
			if message then
				local border = ""
				if (string.len ( message)*2/3+2) < 76 then
					border = string.rep ("-", string.len (message)*2/3+2)
				else
					border = string.rep ("-", 75)
				end message = "\r\n\r\n"..border.."\r\n"..message.."\r\n"..border.."\r\n"
				for id,who in frmHub:GetOnlineUsers() do
					if who.iProfile == -1 then
						who:SendPM(sBot, message)
					end
				end
			else
				user:SendData(sBot, "*** Usage: !messunreg ")
			end
		end
		return 1
	end
end


Mass message unregged users updated version.

- Optimus

Herodes

nice trick for the border,.. its about 2/3rds ;)
I couldn't resist touching this one,... no offense..

-- Message Unregged Users
-- Made by Optimus
-- 03/30/05
---
-- I couldn't resist touching .. Herodes..

sBot = "BotName"

ChatArrival = function(user, data)
	if user.bOperator then
		data=string.sub(data,1,-2)
		s,e,cmd=string.find(data, "%b<>%s+(%S+)")
		if (cmd == "!messunreg") then
			local s,e,cmd,message = string.find(data,"%b<>%s+(%S+)%s+(.*)")
			if message then
				local border = string.rep ("-", 75)
				if (string.len (message)*2/3+2) < 76 then
					border = string.rep ("-", string.len (message)*2/3+2)
				end
				message = "\r\n\r\n"..border.."\r\n"..message.."\r\n"..border.."\r\n"
				for id,who in frmHub:GetOnlineUsers() do
					if who.iProfile == -1 then
						who:SendData( "$To: "..who.sName.." From: "..who.sName.." $<"..sBot.."> "..message )
					end
				end
			else
				user:SendData(sBot, "*** Usage: !messunreg ")
			end
		end
		return 1
	end
end

bastya_elvtars

If i use this:

SendPmToAll(user.sName,"message came")

will the away messages be rebounded to me?

Or better use this:

for h=1,table.getn(userstbl) do; userstbl[h]:SendData("$To: "..userstbl[h].sName.." From: "..Bot.." $<"..user.sName.."> "..message ); end

, where user is me.

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

Optimus

-- Message Unregged Users
-- Made by Optimus
-- 03/30/05
--
-- I couldn't resist touching .. Herodes..
-- Touched it some more by Optimus cause it feels so good hehe

sBot = "BotName"

ChatArrival = function(user, data)
	if user.bOperator then
		data=string.sub(data,1,-2)
		local s,e,cmd=string.find(data, "%b<>%s+(%S+)")
		if (cmd == "!massunreg") then
			local s,e,cmd,message = string.find(data,"%b<>%s+(%S+)%s+(.*)")
			if message then
				local border = string.rep ("-", 75)
				if (string.len (message)*2/3+2) < 76 then
					border = string.rep ("-", string.len (message)*2/3+2)
				end message = "*** Hub: "..(frmHub:GetHubName() or frmHub:GetHubAddress()).." - From: "..user.sName.."\r\n\r\n"..border.."\r\n"..message.."\r\n"..border.."\r\n"
				for id,who in frmHub:GetOnlineUsers() do
					if who.iProfile == -1 then
						who:SendData( "$To: "..who.sName.." From: "..who.sName.." $<"..sBot.."> "..message)
					end
				end SendToOps(sBot, user.sName.." sended a mass message to all none regged users!")
			else
				user:SendData(sBot, "*** Usage: !massunreg ")
			end
			return 1
		end
	end
end
Yummy yummy

Requiem

The script above eats too much resources (memory compared to the one I'll give below) I think.. Maybe you can try this one:
-- Made by Optimus
-- 08/12/03
-- converted to LUA 5 by jiten

sBot = "BotName"

unRegUsers = {}
unRegUserFile = "unRegUsers.txt"

function Main()
	frmHub:RegBot(sBot)
	doloadTable(unRegUserFile)
	if frmHub:GetUsersCount() == 0 then unRegUsers = {}
		dosaveTable(user,data)
	end
end

function NewUserConnected(user)
	if user.iProfile == -1 then
		doLog_unRegUsers(user, data)
	end
end
function UserDisconnected(user)
	if unRegUsers[user.sName] then
		unRegUsers[user.sName] = nil
		dosaveTable(user,data)
	end
end

function ChatArrival(user, data)
	data=string.sub(data,1,string.len(data)-1)
	_,_,cmd=string.find(data, "%b<>%s+(%S+)")
	if user.bOperator then
		if (cmd == "!unregpm") then				
			s,e,cmd,message = string.find(data,"%b<>%s+(%S+)%s+(.+)")
			if message then
				tosend = ""
				if (string.len ( message)*2/3+2) < 76 then
					border = string.rep ("-", string.len (message)*2/3+2)
				else
					border = string.rep ("-", 75)
				end
				tosend = "\r\n\r\n"..border.."\r\n"..message.."\r\n"..border.."\r\n"
				if unRegUsers then
					for name,_ in unRegUsers do
						SendPmToNick(name,sBot, tosend)
					end
				end
			else
				user:SendData(sBot, "*** Please Enter a Message!")
			end
		return 1
		end
	end
end

function doLog_unRegUsers(user, data)
	if unRegUsers[user.sName] == nil then
		unRegUsers[user.sName] = 1
		dosaveTable(user,data)
	end
end


function doloadTable(unRegUserFile)
	local handle = io.open(unRegUserFile,"r")
	if (handle ~= nil) then
                dofile(unRegUserFile)
		handle:flush()
		handle:close()
        end
end

function dosaveTable(user,data)
	local f = io.open(unRegUserFile, "w+")
	assert(unRegUserFile)
	f:write("unRegUsers = {")
	          for a,b in unRegUsers do
                  if b == 1 then
	          f:write(string.format("[%q]=",a)..b..",")
	          end 
        end 
        f:write("}") 
        f:flush()
        f:close()
end


Am I wrong ?

[UK]Madman

If using lua new releases of ptokax (e.g. lua 5) wouldnt something like this be easier ?

local tUsers = {}
		tUsers = frmHub:GetOnlineUsers()
		for key,value in tUsers do
			if not value.bRegistered then
				tUnreg[value.sName] = 1
 			end
		end

Would save the need to save to a text file, tho use more resources when called in a hub with a lot of users.....

Herodes

Requiem,.. I dont think that it eats up resources.. check it out ... the script done by Opti is taking advantage of what [UK]Madman pointed out .. ;)

philoum

Hello, i'm french
I put this last unreg mess but on connected unreg there no mess auto in pm for the unreg user ?
can you help me?

thank
respectfull

Rincewind

This script only sends a message when an operator types !massunreg in main followed by the message to send.

Madman

I noticed.. All codes posted in this is thread is lua 5... so maybe this topic fits better in the lua 5 section?
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

SMF spam blocked by CleanTalk