PM Blocker
 

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

PM Blocker

Started by Tw?sT?d-d?v, 14 July, 2007, 10:19:02

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Tw?sT?d-d?v

Hi   im after a PM blocker script for my priavte hub ..
ive looked over the forum and i cant see anythin or i messed 1

If poss i would like it so i can block with 2 options
1 , all users
2 , single users
Profiles i use are   op,mod,master & netfounder.
I would like it so that there is a rightclicker and only N/F gets sent cmds .
If at all poss     thx in advance  <(^^,)>

Reason for the script is too much spamming in hub and many users are finding ways round anti-ad script i got running
So fiqured next best thing is to block pm for 30mins or so on the spammers without having to ban users ( i hate banning )

Psycho_Chihuahua

try this

--[[
	User PM Filter 1.0c LUA 5.1 [Strict]

	by Mutor		03/24/06
	
	Requested by vadertje


	Prevents PM's by specified profiles to all but ops
	
	+Changes from 1.0       03/24/06
		+Added blocked profiles table
		
	+Changes from 1.0b       07/10/07
		+Converted to LUA 5.1x Strict
		+Added full profiles table. You can now filter to/from all profiles
		+Added OnError func.
		+Config table set as local
]]

--Script Settings
local PmCfg = {
--Name for bot pulled from hub, or use "custom" name
PmBot = frmHub:GetHubBotName(),
-- Admins nick for status/error messages
OpNick = "Mutor",
--Set Your profiles here, 0 = Disable/ 1= Enable
--[Sending Profile] = {[Receiving Profile]=1, ...},
Profiles = {
	--Unregistered User
	[-1] = {[-1]=1,[0]=1,[1]=1,[2]=0,[3]=0,[4]=1,[5]=1,[6]=1,},
	--Master
	[0] = {[-1]=1,[0]=1,[1]=1,[2]=1,[3]=1,[4]=1,[5]=1,[6]=1,},
	--Operator
	[1] = {[-1]=1,[0]=1,[1]=1,[2]=1,[3]=1,[4]=1,[5]=1,[6]=1,},
	--Vip
	[2] = {[-1]=1,[0]=1,[1]=1,[2]=1,[3]=1,[4]=1,[5]=1,[6]=1,},
	--Registered User
	[3] = {[-1]=1,[0]=1,[1]=1,[2]=1,[3]=1,[4]=1,[5]=1,[6]=1,},
	--Moderator
	[4] = {[-1]=1,[0]=1,[1]=1,[2]=1,[3]=1,[4]=1,[5]=1,[6]=1,},
	--NetFounder
	[5] = {[-1]=1,[0]=1,[1]=1,[2]=1,[3]=1,[4]=1,[5]=1,[6]=1,},
	--Owner
	[6] = {[-1]=1,[0]=1,[1]=1,[2]=1,[3]=1,[4]=1,[5]=1,[6]=1,},
	},
}

Main = function()
	PmCfg.Script = "User PM Filter 1.0c"
	if PmCfg.PmBot ~= frmHub:GetHubBotName() or 
		PmCfg.PmBot == frmHub:GetHubBotName() and not frmHub:GetHubBot() then
		frmHub:RegBot(PmCfg.PmBot, 1, PmCfg.Script, "")
	end
end

OnError = function(msg)
	SendToNick(PmCfg.OpNick,"<"..PmCfg.PmBot.."> [ Message From Script: "..PmCfg.Script.." ]  "..msg)
end

ToArrival = function(user, data)
	if PmCfg.Profiles[user.iProfile] then
		local s,e,to = data:find("$To: (%S+) From:")
		local nick,prof1 = GetItemByName(to),GetProfileName(user.iProfile) or "Unregistered User"
		if nick then
			if not PmCfg.Profiles[user.iProfile][nick.iProfile] or 
				PmCfg.Profiles[user.iProfile][nick.iProfile] ==0 then
				local prof2 = GetProfileName(nick.iProfile) or "Unregistered User"
				local FilterMsg = "<"..PmCfg.PmBot..">\r\n\r\n\tSorry "..user.sName..
				", Your Private Message To "..nick.sName.." Was Blocked.\r\n\r\n"..
				"\t"..prof1.."'s may not private message "..prof2.."'s\r\n\r\n"
				return user:SendPM(nick.sName,FilterMsg),1
			end
		else
			local OfflineMsg = "The user "..to.." is not online. Check your spelling."
			return user:SendPM(PmCfg.PmBot,OfflineMsg),1
		end
	else
		local badprof = GetProfileName(user.iProfile) or "Invalid Profile"
		return OnError("Error!, Private Message from "..badprof.." "..user.sName..
		". Profile not set in script: "..PmCfg.Script.."."),1
	end
end
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Tw?sT?d-d?v


   Prevents PM's by specified profiles to all but ops

I would like to block specified users not profiles .... But thx for reply  :)

Tw?sT?d-d?v

I use the following anti-advert script ...
-------------------------------------------------------------------------------- 
-- anti advertise by ruler 
-- OPs cannot post adverts in PM but Master can :P 
-------------------------------------------------------------------------------- 
antiadds = { 
["gotdns"]=1, 
["bounceme.net"]=2, 
["hopto.org"]=3, 
["myftp.biz"]=4, 
["myftp.org"]=5, 
["myvnc.com"]=6, 
["ip.biz"]=7, 
["ip.info"]=8, 
["ip.org"]=9, 
["redirectme.net"]=10, 
["servebeer.com"]=11, 
["servecounterstrike.com"]=12, 
["serveftp.com"]=13, 
["servegame.com"]=14, 
["servehalflife.com"]=15, 
["servehttp.com"]=16, 
["servemp3.com"]=17, 
["servepics.com"]=18, 
["servequake.com"]=19, 
["sytes.net"]=20, 
["zapto.org"]=21, 
["ciscofreak.com"]=22, 
["damnserver.com"]=23, 
["http://"]=24, 
["ditchyourip.com"]=25, 
["dnsiskinky.com"]=26, 
["geekgalaxy.com"]=27, 
["freaks.com"]=28, 
["ip.ca"]=29, 
["ip.co.uk"]=30, 
["ip.com"]=31, 
["ip.net"]=32, 
["point2this.com"]=33, 
["securityexploits.com"]=34, 
["securitytactics.com"]=35, 
["servehumour.com"]=36, 
["servep2p.com"]=37, 
["servesarcasm.com"]=38, 
["stufftoread.com"]=39, 
["workisborring.com"]=40, 
["musicdvdworld"]=41, 
["dchub://"]=42, 
["www."]=43, 
["hub"]=44,
["no-ip"]=45,
["dash"]=46,
["dot"]=47,
["private"]=48,
["privatehub"]=49,
["hub"]=50,
["gb"]=51,
["greatalliance"]=52,
["great"]=53,
["alliance"]=54,
["h%s+u%s+b"]=55,
["priva"]=56,
["kicks"]=57,
["ass"]=58,
["org"]=59,
["25000"]=60,
["h"]=61,
["u"]=62,
["b"]=63,


} 
-------------------------------------------------------------- 
Bot = frmHub:GetHubBotName() 
function ToArrival(user, data) 
if user.iProfile ~= 0  and user.iProfile ~= 4 and user.iProfile ~= 5 then
for key,a in pairs(antiadds) do 
if( string.find(string.lower(data), key) ) then 
         user:SendPM(Bot, "Sorry, your PM was blocked. Please use main chat to post adverts!") 
         return 1 
         end 
end 
end 
end 
-- EOF


it has been modified for my needs      Adverts can be posted in main but not pm
Tried to do somethin for all users ... but others take advantage.Hence asking for the pm blocker for users and not profiles.

Tw?sT?d-d?v

#4
Thank you very much Mutor     :)   

Setting it up now ...     any probs and ill be back  :P

Edit
Great work  (yet again)
Works like a charm  :)

Tw?sT?d-d?v

Thx for the update Mutor
Having got the newer version and setting it up for my hub ..
When testing i dont seem to be able to block any1 all i get is the following message

Tw?sT?d-d?v?l is protected and may not be blocked.   

At 1st i thought id done something wrong ,so i got script again ,
all i have done this time is change Operator profile to  0 and i still get same message

Mutor is protected and may not be blocked.

Tw?sT?d-d?v

Nice 1 Mutor      thx     :) :)

Djdirect

Bonjour Mutor help me please
i have this error PM Block.lua:275: attempt to concatenate local 'v' (a table value) when i want look user block list

Djdirect

Merci Mutor

you are incredible me post has 10 minutes and already a solution  ;)

question maybe stupid sorry

the help command is this
   Command      Description
   ????????????????????????????????????????
   +pmbhelp        PM Block Command Help
   +block          Block This User's PM's
   +blockall       Block All User's PM's
   +unblock        Unblock This User's PM
   +unblockall     Unblock All User's PM's
   +pmblist        List PM Blocked Users

   ????????????????????????????????????????
why this ordering how to change it ??   to
   Command      Description
   ????????????????????????????????????????
   +block          Block This User's PM's
   +unblock        Unblock This User's PM
   +blockall       Block All User's PM's
   +unblockall     Unblock All User's PM's
   +pmblist        List PM Blocked Users
   +pmbhelp        PM Block Command Help

   ????????????????????????????????????????
right clic also


Tw?sT?d-d?v

Mutor would it be poss for you to convert this script .. or tell me what i messed here.....

--[[

	PM Block 1.0 LUA 5.1 [Strict]

	By Mutor	07/14/07

	Requested by	Tw?sT?d-d?v?l


	Blocks / Unblocks user PM's by command.
	-Provides commands by profile
	-Can block/unblock all [non-enabled] online nicks
	-Can block / unblock offline nicks
	-Cannot block / unblock own nick
	-Provides context menu [right click]
	-Blocked user list saved to file

	
]]

PbCfg = {
-- Botname pulled from the hub or use "CustomName"
Bot = "'([SPAM-PROTECTER])'",
-- Should bot have a key?
BotIsOp = 1,
-- Bot description
BotDesc = "Private Message Blocker",
-- Bot Email address
BotMail = "user@domain.com",
-- Admins nick for status/error messages
OpNick = "Mutor",
-- Send verbose script messages to OpNick? ["yes","no"]
Verbose = "yes",
-- File to save config/user table
File = "Blocked.dat",
-- Context Menu Title
Menu = "-[-=={PM-BLOCKER}==-]-",
-- Context Submenu Title
SubMenu = "PM Block",
--Block time [in minutes] after which users will be automatically unblocked.
BlockTime = 3000000000000000000,
--Set your profiles permissions here.
--[profile #] = {PM Block enabled [0=no 1=yes], "Custom Profile Name"}
Profiles = {
	[-1] = {0,"Unregistered User"},	
	[0] = {1,"Master"},
	[1] = {0,"Operator"},
	[2] = {0,"Vip"},
	[3] = {0,"Registered User"},
	},
}

local Script = "PM Block 1.0"
OnStartup = function()
	PbCfg.Blocked = {}
	local Ver = string.sub(_VERSION,1,7)
	if Ver ~= "Lua 5.1" then
		OnError(Script.." is not compatible with your version of LUA: ".._VERSION)
	end

	if loadfile(PbCfg.File) then
		dofile(PbCfg.File)
	else
		Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked")
	end
	if PbCfg.Bot ~= SetMan.GetString(21) or
		PbCfg.Bot == SetMan.GetString(21) and not (SetMan.GetBool(17) and 1 or 0) then
		Core.RegBot(PbCfg.Bot,PbCfg.BotDesc,PbCfg.BotMail,false)
	end
	OnError(Script.." for ".._VERSION.." by Mutor has been started.")
end

OnTimer = function(tmr)
	local Now,Change = os.time()
	for i,v in ipairs(PbCfg.Blocked) do
		if ((Now - v[2]) / 60) > PbCfg.BlockTime then
			Change = true
			if PbCfg.Verbose:lower() == "yes" then
				OnError(v[1].." has been removed blocked pm users.")
			end
			table.remove(PbCfg.Blocked,i)
		end
	end
	if Change then
		Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked")
	end
end

OnExit = function()
	OnError(Script.." for ".._VERSION.." by Mutor has been stopped.")
end

OnError = function(msg)
	Core.SendToNick(PbCfg.OpNick,"<"..PbCfg.Bot.."> "..msg)
end

function NewUserConnected(user, data)
	if PbCfg.Profiles[user.iProfile] and PbCfg.Profiles[user.iProfile][1] == 1 then
		SendBlockCmds(user)
		Core.SendToNick(user.sNick,"<"..PbCfg.Bot.."> "..PbCfg.Profiles[user.iProfile][2].."'s "..Script..
		" commands enabled. Right click hub tab or user list for a command menu.")
	end
end
OpConnected = UserConnected

ChatArrival = function(user,data)
	Core.GetUserAllData(user)
	local _,_,to = data:find("^$To: (%S+) From:")
	if to and CheckBlock(user.sNick) then
		local msg = "Your PM's are blocked! It is senseless to try to speak."
		return Core.SendPmToNick(user.sNick,to,"<"..PbCfg.Bot.."> "..msg),1
	elseif to and CheckBlock(to) then
		local msg = "Sorry "..user.sNick..", "..to.."'s PM's are blocked! "..
		to.." may receive a message but cannot respond."
		Core.SendPmToNick(user.sNick,to,"<"..PbCfg.Bot.."> "..msg)
	else
		if PbCfg.Profiles[user.iProfile] and PbCfg.Profiles[user.iProfile][1] == 1 then
			local _,_,cmd = data:find("%b<> %p(%w+)")
			if cmd and BlockCmds[cmd] then
				if to and to == PbCfg.Bot then
					Core.SendPmToNick(user.sNick,PbCfg.Bot,BlockCmds[cmd](user,data))
				else
					Core.SendToNick(user.sNick,"<"..PbCfg.Bot.."> "..BlockCmds[cmd](user,data))
				end
				collectgarbage("collect")
				return true
			end
		end
	end
end
ToArrival = ChatArrival

CheckBlock = function(nick)
	local block
	for i,v in ipairs(PbCfg.Blocked) do
		if v[1]:lower() == nick:lower() then
			block = i
			break
		end
	end
	return block
end

BlockCmds = {
	block = function(user,data)
		if user then
			local _,_,nick = data:find("%b<> %p%w+ (%S+)|$")
			if not nick then
function getcmdprefixarray() local p = {} for i=1,#SetMan.GetString(29) do table.insert(p,SetMan.GetString(29):sub(i,i)) end end
				return "Error!, Usage: "..getcmdprefixarray()[1]..
				"block <nick>"
			else
				if nick == user.sNick then
					return "You cannot block yourself "..user.sNick..". Dont be a fool!"
				end
				if CheckBlock(nick) then
					return "The user: "..nick.." has already been blocked."
				else
					table.insert(PbCfg.Blocked,{nick,os.time()})
					Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked")
					local status,usr = "offline",GetItemByName(nick)
					if usr then
						status = "online"
						Core.SendToNick(usr.sNick,"<"..PbCfg.Bot.."> You have been blocked. "..
						"You may not speak in private message.")
 					end
					Core.SendToNick(user.sNick,"<"..PbCfg.Bot.."> The "..status.." user: "..nick..
					" is now blocked and cannot speak in private message.")
					return nil
				end
			end
		else
			return "Block A User's PM"," %[line:Nickname]"," %[nick]"
		end
	end,
	blockall = function(user,data)
		if user then
			local Now,Count,Change = os.time(),0
			for i,usr in ipairs(Core.GetOnlineUsers(true)) do
				if not PbCfg.Profiles[usr.iProfile] or PbCfg.Profiles[usr.iProfile][1] == 0 then
					if usr.sNick:lower() ~= PbCfg.OpNick:lower() then
						Count = Count + 1
						Change = true
						local x = CheckBlock(usr.sNick)
						if x then
							PbCfg.Blocked[x][2] = Now
						else
							table.insert(PbCfg.Blocked,{usr.sNick,Now})
						end
					end
				end
			end
			if Change then
				Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked")
			end
			local status = "No"
			if Count > 0 then
				status = Count
			end
			return status.." users were added to or updated in the pm block table."
		else
			return "Block All User PM's","",""
		end
	end,
	unblock = function(user,data)
		if user then
			local _,_,nick = data:find("%b<> %p%w+ (%S+)|$")
			if not nick then
function getcmdprefixarray() local p = {} for i=1,#SetMan.GetString(29) do table.insert(p,SetMan.GetString(29):sub(i,i)) end end
				return "Error!, Usage: "..getcmdprefixarray()[1]..
				"unblock <nick>"
			else
				if nick:lower() == user.sNick:lower() then
					return "You cannot unblock yourself "..user.sNick..
					". What fun would that be?"
				end
				local Block = CheckBlock(nick)
				if not Block then
					return "The user: "..nick.." has not been blocked."
				else
					table.remove(PbCfg.Blocked,Block)
					Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked")
					local status,usr = "offline",GetItemByName(nick)
					if usr then
						status = "online"
						Core.SendToNick(usr.sNick,"<"..PbCfg.Bot.."> You have been unblocked. "..
						"You may now speak in private message again.")
					end
					Core.SendToNick(user.sNick,"<"..PbCfg.Bot.."> The "..status.." user: "..nick..
					" is unblocked and can now speak in private message again.")
					return nil
				end
			end
		else
			return "Unblock A User's PM"," %[line:Nickname]"," %[nick]"
		end
	end,
	unblockall = function(user,data)
		if user then
			PbCfg.Blocked = {}
			Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked")
			return "All user PM's are now unblocked"
		else
			return "Unblock All User PM's","",""
		end
	end,
	pmblist = function(user,data)
		if user then
			if next(PbCfg.Blocked) then
				local Count = 0
				local reply = "Listing PM Blocked Users...\r\n\r\n\tNumber\t\tUser Nick\r\n"..
				"\t"..string.rep("?",40).."\r\n"
				for i,v in ipairs(PbCfg.Blocked) do
					reply = reply.."\t"..string.format("[ %-3s ]",i).."\t\t"..v[1].."\r\n"
				end
				return reply.."\n\t"..string.rep("?",40).."\r\n\r\n"
			else
				return "There are no users blocked at this time."
			end
		else
			return "List Blocked Users","",""
		end
	end,
	pmbhelp = function(user,data)
		if user then
			local reply = "PM Block Command Help\r\n\r\n\tCommand\t\tDescription\r\n"..
			"\t"..string.rep("?",40).."\r\n"
			for i,v in pairs(BlockCmds) do
				local desc,args = BlockCmds[i]()
				reply = reply.."\t+"..string.format("%-15s",i).."\t"..desc.."\r\n"
			end
			return reply.."\n\t"..string.rep("?",40).."\r\n\r\n"
		else
			return "PM Block Command Help","",""
		end
	end,
}

SendBlockCmds = function(user)
	for i,v in pairs(BlockCmds) do
		local desc,arg1,arg2 = BlockCmds[i]()
		Core.SendToNick(user.sNick,"$UserCommand 1 1 "..PbCfg.Menu.."\\"..PbCfg.SubMenu.."\\"..
		desc.."$<%[mynick]> +"..i..arg1.."&#124;")
		Core.SendToNick(user.sNick,"$UserCommand 1 2 "..PbCfg.Menu.."\\"..PbCfg.SubMenu.."\\"..
		desc.."$$To: "..PbCfg.Bot.." From: %[mynick] $<%[mynick]> +"..i..arg2.."&#124;")
		collectgarbage("collect")
	end
end

Save_Serialize = function(tTable, sTableName, hFile, sTab)
	sTab = sTab or "";
	hFile:write(sTab..sTableName.." = {\n" )
	for key, value in ipairs(tTable) do
		local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key)
		if(type(value) == "table") then
			Save_Serialize(value, sKey, hFile, sTab.."\t")
		else
			local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value)
			hFile:write( sTab.."\t"..sKey.." = "..sValue)
		end
		hFile:write(",\n")
	end
	hFile:write( sTab.."}")
end

Save_File = function(file,table, tablename )
	local hFile = io.open (file , "wb")
	Save_Serialize(table, tablename, hFile)
	hFile:flush() hFile:close()
	collectgarbage("collect")
end
RegConnected = UserConnected


it doesnt show any errors in px but i dont get any r/c cmds sent on connect... testing on RC8


Tw?sT?d-d?v

The script doesnt seem to be working
This is in main

[18:02:51] <{-Twisteds-Soul-}> Master's PM Block 1.0c commands enabled. Right click hub tab or user list for a command menu.
[18:03:21] <Tw?sT?d-d?v?l> +pmblist
[18:09:50] <Tw?sT?d-d?v?l> +pmbhelp

And when i try blocking its doesnt block ....  My test hub is now RC9

Tw?sT?d-d?v

Tried and tested , i did have to alter script though..

Profiles = {
	[-1] = {false,"Unregistered User"},
	[0] = {true,"Master"},
	[1] = {true,"Operator"},
	[2] = {false,"Vip"},
	[3] = {false,"Registered User"},
	[4] = {false,"Moderator"},
	[5] = {true,"NetFounder"},
	[6] = {true,"Owner"},
	},

I had to change the true & false to 1 & 0 ... 

Tw?sT?d-d?v

I dont use op-chat     :P   i dont see point in an all op hub  :)

Tw?sT?d-d?v


P_pan

i got a little qusetion on this fine script..

is it possibble to block a user that will be on ohter hubs too with same nick?

or is there a clientside script for this one?
thank you....

P_pan

thank you for clarifying Mutor :)

SMF spam blocked by CleanTalk