Strong Gagger Conversion needed
 

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

Strong Gagger Conversion needed

Started by QuikThinker, 11 March, 2005, 12:29:58

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

QuikThinker

This is my gag script I currently use and need it converted if sum1 can pls?
Although for sum reason the OPs can still use !talk which also needs adjsuting.

--## 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("NetFounder") 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

Thanx in advance!

jiten

Try this:

--## Stand Alone Gagger 1.1
--## Converted to LUA 5 by jiten
--## 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 ChatArrival(user, data)
	if (string.sub(data,1,1) == "<") then 
		if (gagged[string.lower(user.sName)] ~= nil) then
			if (user.bOperator) then
				data = string.sub(data,1,string.len(data)-1)
				s,e,uCmd,prefix = string.find(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[string.lower(user.sName)] ~= nil) then
				user:SendPM(sBot, "You are gagged.")
				return 1
			end
		end
	end
	if (string.sub(data,1,1) == "<") then
		data = string.sub(data,1,string.len(data)-1)
		s,e,cmd = string.find(data, "%b<>%s+(%S+)")
		if (cmd == "!gag" and user.bOperator) then
			local s,e,gag = string.find(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[string.lower(gag)] == nil) then
					gagged[string.lower(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 = string.find(data, "%b<>%s+%S+%s+(%S+)")
			if (gag == nil) then
				user:SendPM(sBot, "Syntax Error, !ungag , you must write a nick.")
			else
				if (gagged[string.lower(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[string.lower(gag)] = nil
				end
			end
			return 1
		elseif (cmd == "!gaglist" and user.bOperator) then
			ShowGagList(user)
			return 1			
		end
	end
end

function ToArrival(user, data)
	if (string.sub(data,1,5) == "$To: " or string.sub(data,1,1) == "%*") then 
		if (gagged[string.lower(user.sName)] ~= nil) then
			if (user.bOperator) then
				data = string.sub(data,1,string.len(data)-1)
				s,e,uCmd,prefix = string.find(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[string.lower(user.sName)] ~= nil) then
				user:SendPM(sBot, "You are gagged.")
				return 1
			end
		end
	end
	if (string.sub(data,1,5+string.len(sBot)) == "$To: "..sBot) then
		data = string.sub(data,1,string.len(data)-1)
		s,e,cmd = string.find(data, "%b<>%s+(%S+)")
		if (cmd == "!gag" and user.bOperator) then
			local s,e,gag = string.find(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[string.lower(gag)] == nil) then
					gagged[string.lower(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 = string.find(data, "%b<>%s+%S+%s+(%S+)")
			if (gag == nil) then
				user:SendPM(sBot, "Syntax Error, !ungag , you must write a nick.")
			else
				if (gagged[string.lower(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[string.lower(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("NetFounder") do
			if (string.lower(usr) == string.lower(who)) then
				return 1
			end
		end
	end
	return 0
end

function CheckForGagCMD(cmd)
	for i=1, table.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 string.format("[%q]",key) or string.format("[%d]",key);

                if(type(value) == "table") then
                        sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
                else
                        local sValue = (type(value) == "string") and string.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)
	local handle = io.open(file,"w+")
        handle:write(Serialize(table, tablename))
	handle:flush()
        handle:close()
end

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

SMF spam blocked by CleanTalk