simpel tagchecker
 

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

simpel tagchecker

Started by -RICK-, 09 May, 2006, 16:16:33

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

-RICK-

--Tag check (with add and remove)
-- RICK 2006
-- create in scriptsfolder? ? "Tagtable.tbl"



settings = {
	["Bot"] = "Tagtablecheck",	-- botname								
	["cmd"] = {["addtag"] = 1, ["remtag"] = 2, ["showtag"] = 3,},
	["prefix"] = {["!"] = 1, ["+"] = 1, ["-"] = 1, ["/"] = 1, ["*"] = 1,},				
	["AllowedProfiles"] = {[-1] = 0, [0] = 1, [1] = 0, [2] = 0, [3] = 1, [4] = 1, [5] = 1,}, -- who can use the commands
}


Tagtable = {}
tcmd={}
TagtableFile = ("Tagtable.tbl")

function Main()
	frmHub:RegBot(settings["Bot"])
	loadTableFromFile(TagtableFile)
end

function ChatArrival(curUser,data)
	local data = string.sub(data,1,string.len(data)-1)
	local s,e,prefix,cmd = string.find(data, "%b<>%s*(%S)(%S+)")
	if cmd and settings["prefix"][prefix] and settings["cmd"][cmd] then
		if settings["cmd"][cmd] ~= nil then
			if settings["AllowedProfiles"][curUser.iProfile] == 1 then
				if tcmd[settings["cmd"][cmd]] ~= nil then
					return tcmd[settings["cmd"][cmd]](curUser, data)
				else
					curUser:SendData(" *** ??? command incorrect ")
					return 1
				end
			else
				curUser:SendData(" *** U dont have acces to this command !")
				return 1
			end
		end
	end
end



tcmd[1] = function(user,data)
	s,e,arg = string.find(data, "%b<>%s+%S+%s+(.*)")
	AddTagtable(user)
	return 1
end
	
function AddTagtable(user)	
	table.insert(tTagtable, arg) 
	saveTableToFile(TagtableFile, tTagtable, "tTagtable")
	SendToOps(" *** "..arg.." In Tag tabel")
	return 1
end

tcmd[2] = function(user,data)
	local _,_,arg = string.find(data, "%b<>%s+%S+%s+(.*)") 
	for i,v in tTagtable do 
		if v == arg then 
			table.remove(tTagtable, i) 
			saveTableToFile(TagtableFile, tTagtable, "tTagtable")
			addmsg = (" *** "..arg.." Removed from Tag tabel")
			SendToOps(addmsg)
		end 
	end
? ? return 1
end

tcmd[3] = function(user,data)
? ? ? ? tablename = tTagtable
? ? ? ? message1 = ("\t\t\tTag check list ["..table.getn(tTagtable).."] Tag(s)\r\n")
? ? ? ? message2 = ("\tno Tag found in list")
? ? ? ? senddisplay(user)
? ? ? ? return 1
? ? end
? ?
 -------------------------------------------------------------
--senddisplay
-------------------------------------------------------------
function senddisplay(user)
? ? ? ? local dsp1
? ? ? ? dsp1 = "\r\n=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
? ? ? ? dsp1 = dsp1..""..message1.."\r\n"
? ? ? ? dsp1 = dsp1.."=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n\r\n"
? ? ? ? if table.getn(tablename) ~= 0 then
? ? ? ? ? ? for i = 1,table.getn(tablename) do
? ? ? ? ? ? ? ? dsp1 = dsp1.." "..tablename[i].."\r\n"
? ? ? ? ? ? end
? ? ? ? ? ? else
? ? ? ? ? ? dsp1 = dsp1..""..message2.."\r\n"
? ? ? ? end
? ? ? ? user:SendData(settings["Bot"], dsp1)
? ? ? ? dsp1 = nil
? ? ? ? return 1
? ? end


function checkForTag(user)
	for i = 1,table.getn(tTagtable) do
		if string.find( user.sTag , tTagtable[i] , 1 , true ) then
? ? ? ? ? ? return 1
		end
	end
	return
end

NewUserConnected = function(user)
? ?if settings["AllowedProfiles"][user.iProfile] == 1 then
? ? ? ? user:SendData("$UserCommand 1 3 Tagtablecheck\\Show Tag$<%[mynick]> !showtag&#124;|")
? ? ? ? user:SendData("$UserCommand 1 3 Tagtablecheck\\Add Tagtable$<%[mynick]> !addtag %[line:Add Tag]&#124;|")
? ? ? ? user:SendData("$UserCommand 1 3 Tagtablecheck\\Rem Tagtable hubs$<%[mynick]> !remtag %[line:Add Tag]&#124;|")
? ? end
end

function MyINFOArrival(user, data)
? ? ? ? if user.sTag == nill then
? ? ? ? ? ? user.sTag = ""
? ? ? ? end
	if checkForTag(user)and settings["AllowedProfiles"][user.iProfile] ~= 1 then
? ? ? ? user:SendData(settings["Bot"],"wrong tag")
? ? ? ? user:Disconnect()
? ? end
end

OpConnected=NewUserConnected
------------------------------------------------------------------------------------------------------------------------------------------

Serialize = function(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
	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
------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------

saveTableToFile = function(file , table , tablename, tab)
	local tempfile = io.open(file, "w")
	tempfile:write(Serialize(table, tablename, tab))
	tempfile:close()
end
	? ? ?
-----------------------------------------------------------
loadTableFromFile = function(file)
dofile(file)
end

SMF spam blocked by CleanTalk