Mod needed on Gagger script
 

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

Mod needed on Gagger script

Started by QuikThinker, 20 August, 2004, 02:16:19

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

QuikThinker

I need a couple of modifications 2 this script please if any1 is willin 2 oblige?

--Requested by D-J Valhala
--Made by nErBoS

sBot = "?PHH?"

gagged = {}
gaggedsv = "gagged.dat"

function Main()
	frmHub:RegBot(sBot)
	LoadFromFile(gaggedsv)
end

function OnExit()
	SaveToFile(gaggedsv , gagged , "gagged")
end

function DataArrival(user, data)
	if (strsub(data,1,1) == "<" or strsub(data,1,5) == "$To: " or strsub(data,1,1) == "%*") then 
		if (gagged[strlower(user.sName)] ~= nil) then
			user:SendPM(sBot, "You are gagged.")
			return 1
		end
	end
	if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) then
		data = strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data, "%b<>%s+(%S+)")
		if (cmd == "!gag" and user.bOperator) then
			local s,e,gag = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (gag == nil) then
				user:SendPM(sBot, "Syntax Error, !gag , you must write a nick.")
			else
				if (gagged[strlower(gag)] == nil) then
					gagged[strlower(gag)] = 1
					user:SendPM(sBot, "The user "..gag.." has been gagged.")
					SendToAll(sBot, "The user "..gag.." has been shut the fuck up by "..user.sName..".")
				else
					user:SendPM(sBot, "The user "..gag.." is already gagged.")
				end
			end
			return 1
		elseif (cmd == "!ungag" and user.bOperator) then
			local s,e,gag = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (gag == nil) then
				user:SendPM(sBot, "Syntax Error, !ungag , you must write a nick.")
			else
				if (gagged[strlower(gag)] == nil) then
					user:SendPM(sBot, "The user "..gag.." isn't gagged.")
				else
					user:SendPM(sBot, "The user "..gag.." has been ungagged.")
					SendToAll(sBot, "The user "..gag.." has been ungagged by "..user.sName..".")
					gagged[strlower(gag)] = nil
				end
			end
			return 1
		elseif (cmd == "!gaglist" and user.bOperator) then
			ShowGagList(user)
			return 1			
		end
	end
end

function ShowGagList(user)
	local sTmp = "Users that are gagged in this Hub:\r\n\r\n"
	local usr,aux
	for usr, aux in gagged do
		sTmp = sTmp..usr.."\r\n"
	end
	user:SendPM(sBot, sTmp)
end		

function Serialize(tTable, sTableName, sTab)
	assert(tTable, "tTable equals nil");
	assert(sTableName, "sTableName equals nil");

	assert(type(tTable) == "table", "tTable must be a table!");
	assert(type(sTableName) == "string", "sTableName must be a string!");

	sTab = sTab or "";
	sTmp = ""

	sTmp = sTmp..sTab..sTableName.." = {\n"

	for key, value in tTable do
		local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);

		if(type(value) == "table") then
			Serialize(value, sKey, sTab.."\t");
		else
			local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
			sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
		end

		sTmp = sTmp..",\n"
	end

	sTmp = sTmp..sTab.."}"
	return sTmp
end

function SaveToFile(file , table , tablename)
	writeto(file)
	write(Serialize(table, tablename))
	writeto()
end

function LoadFromFile(file)
	if (readfrom(file) ~= nil) then
		readfrom(file)
		dostring(read("*all"))
		readfrom()
	end
end

I need it so that OPs cannot use this command on Masters. And I also need so when an OP is gagged they cannot use the !mass or !talk commands.

Thanx in advance,
Quik.

nErBoS

#1
Hi,

Try out...

--## Stand Alone Gagger 1.1
--## This script should be before the scripts with commands, in the Script List
--## Requested by D-J Valhala
--## Master Protected (asked by QuikThinker)
--## Added a table with Commands that can't be used when gagged (asked by QuikThinker)
--## Made by nErBoS

sBot = "?PHH?"

gagged = {}
gaggedsv = "gagged.dat"

arrGagCmd = {
	"!mass",
	"!talk",
	"!ungag",
}

function Main()
	frmHub:RegBot(sBot)
	LoadFromFile(gaggedsv)
end

function OnExit()
	SaveToFile(gaggedsv , gagged , "gagged")
end

function DataArrival(user, data)
	if (strsub(data,1,1) == "<" or strsub(data,1,5) == "$To: " or strsub(data,1,1) == "%*") then 
		if (gagged[strlower(user.sName)] ~= nil) then
			if (user.bOperator) then
				data = strsub(data,1,strlen(data)-1)
				s,e,uCmd,prefix = strfind(data, "%b<>%s+((%S+)%S+)")
				if (CheckForGagCMD(uCmd) == 1) then
					user:SendPM(sBot, "You are gagged, you can?t use this command.")
					return 1
				elseif (prefix ~= "!") then
					user:SendPM(sBot, "You are gagged.")
					return 1
				end
			elseif (gagged[strlower(user.sName)] ~= nil) then
				user:SendPM(sBot, "You are gagged.")
				return 1
			end
		end
	end
	if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) then
		data = strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data, "%b<>%s+(%S+)")
		if (cmd == "!gag" and user.bOperator) then
			local s,e,gag = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (gag == nil) then
				user:SendPM(sBot, "Syntax Error, !gag , you must write a nick.")
			elseif (CheckProfile(user, gag) == 1) then
				user:SendPM(sBot, "You don't have permission to gag "..gag..".")
			else
				if (gagged[strlower(gag)] == nil) then
					gagged[strlower(gag)] = 1
					user:SendPM(sBot, "The user "..gag.." has been gagged.")
					SendToAll(sBot, "The user "..gag.." has been shut the fuck up by "..user.sName..".")
				else
					user:SendPM(sBot, "The user "..gag.." is already gagged.")
				end
			end
			return 1
		elseif (cmd == "!ungag" and user.bOperator) then
			local s,e,gag = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (gag == nil) then
				user:SendPM(sBot, "Syntax Error, !ungag , you must write a nick.")
			else
				if (gagged[strlower(gag)] == nil) then
					user:SendPM(sBot, "The user "..gag.." isn't gagged.")
				else
					user:SendPM(sBot, "The user "..gag.." has been ungagged.")
					SendToAll(sBot, "The user "..gag.." has been ungagged by "..user.sName..".")
					gagged[strlower(gag)] = nil
				end
			end
			return 1
		elseif (cmd == "!gaglist" and user.bOperator) then
			ShowGagList(user)
			return 1			
		end
	end
end

function ShowGagList(user)
	local sTmp = "Users that are gagged in this Hub:\r\n\r\n"
	local usr,aux
	for usr, aux in gagged do
		sTmp = sTmp..usr.."\r\n"
	end
	user:SendPM(sBot, sTmp)
end		

function CheckProfile(user, who)
	if (user.iProfile ~= 0) then
		local usr,aux
		for aux, usr in GetUsersByProfile("Master") do
			if (strlower(usr) == strlower(who)) then
				return 1
			end
		end
	end
	return 0
end

function CheckForGagCMD(cmd)
	for i=1, getn(arrGagCmd) do
		if (arrGagCmd[i] == cmd) then
			return 1
		end
	end
	return 0
end

function Serialize(tTable, sTableName, sTab)
	assert(tTable, "tTable equals nil");
	assert(sTableName, "sTableName equals nil");

	assert(type(tTable) == "table", "tTable must be a table!");
	assert(type(sTableName) == "string", "sTableName must be a string!");

	sTab = sTab or "";
	sTmp = ""

	sTmp = sTmp..sTab..sTableName.." = {\n"

	for key, value in tTable do
		local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);

		if(type(value) == "table") then
			Serialize(value, sKey, sTab.."\t");
		else
			local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
			sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
		end

		sTmp = sTmp..",\n"
	end

	sTmp = sTmp..sTab.."}"
	return sTmp
end

function SaveToFile(file , table , tablename)
	writeto(file)
	write(Serialize(table, tablename))
	writeto()
end

function LoadFromFile(file)
	if (readfrom(file) ~= nil) then
		readfrom(file)
		dostring(read("*all"))
		readfrom()
	end
end

This script should be before the scripts with commands, in the Script List.

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

SMF spam blocked by CleanTalk