Kick & Warn
 

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

Kick & Warn

Started by jiten, 26 April, 2005, 20:13:50

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jiten

-- Kick/Warn v1.0 by jiten
-- with:
-- Immune Profiles/Allowed Profiles
-- Kick/Warn Limit and Timeban

tConf = { -- Script settings
	mSet = {
		sBot = frmHub:GetHubBotName(), -- bot name
		iTimeBan = 10, -- in minutes
		kLimit = 3, -- kick limit
		wLimit = 3, -- warn limit
	},
	tKick = {},
	tWarn = {},
}

AllowedProfiles = {
	[-1] = 0, -- unreg
	[0] = 1, -- master
	[1] = 1, -- operator
	[2] = 0, -- vip
	[3] = 0, -- reg
	[4] = 1, -- moderator
	[5] = 1, -- founder
}

ImmuneProfiles = {
	[-1] = 0, -- unreg
	[0] = 1, -- master
	[1] = 0, -- operator
	[2] = 0, -- vip
	[3] = 0, -- reg
	[4] = 0, -- moderator
	[5] = 1, -- founder
}

function ChatArrival (user,data) 
	data=string.sub(data,1,-2) 
	local s,e,cmd = string.find ( data, "%b<>%s+[%!%?%+%#](%S+)" )
	if cmd then
		local s,e,usr,reason = string.find( data, "%b<>%s+%S+%s+(%S+)%s*(.*)" )
		local tCmds = { 
		["warn"] =	function(user,data)
			if AllowedProfiles[user.iProfile] == 1 then
				if usr == nil or reason == nil then
					user:SendData(tConf.mSet.sBot, "*** Syntax Error: Type !warn  ")
				else
					local victim = GetItemByName(usr)
					if (victim == nil) then
						user:SendData(tConf.mSet.sBot, "The user "..usr.." is not online.")
					else
						if ImmuneProfiles[victim.iProfile] ~= 1 then
							if tConf.tWarn[victim.sName] == nil then
								tConf.tWarn[victim.sName] = {}
								tConf.tWarn[victim.sName]["Warned"] = {}
								tConf.tWarn[victim.sName]["Warned"] = 1
							else
								tConf.tWarn[victim.sName]["Warned"] = tConf.tWarn[victim.sName]["Warned"] + 1
							end
						else
							user:SendData(tConf.mSet.sBot,"*** Error: You can't warn Immune Profile Users.")
							return 0
						end
						if (tConf.tWarn[victim.sName]["Warned"] == tConf.mSet.wLimit) then
							victim:SendPM(tConf.mSet.sBot, "You are being warned and disconnected because: "..reason)
							SendToAll(tConf.mSet.sBot, "User "..victim.sName.." was kicked by "..user.sName.." because: "..reason)
							tConf.tWarn[victim.sName] = nil
							victim:TempBan()
							victim:Disconnect()
						else
							victim:SendPM(tConf.mSet.sBot, "You are being warned because: "..reason)
							SendToAll(tConf.mSet.sBot, "User "..victim.sName.." was warned by "..user.sName.." because: "..reason)
						end
					end
				end
			else
				user:SendData(tConf.mSet.sBot,"*** Error: You are not allowed to use this command.")
			end
		end,
		["kick"] =	function(user,data)
			if AllowedProfiles[user.iProfile] == 1 then
				if usr == nil or reason == nil then
					user:SendData(tConf.mSet.sBot, "*** Syntax Error: Type !kick  ")
				else
					local victim = GetItemByName(usr)
					if (victim == nil) then
						user:SendData(tConf.mSet.sBot, "The user "..usr.." is not online.")
					else
						if ImmuneProfiles[victim.iProfile] ~= 1 then
							if tConf.tWarn[victim.sName] == nil then
								tConf.tWarn[victim.sName] = {}
								tConf.tWarn[victim.sName]["Kicked"] = {}
								tConf.tWarn[victim.sName]["Kicked"] = 1
							else
								tConf.tWarn[victim.sName]["Kicked"] = tConf.tWarn[victim.sName]["Kicked"] + 1
							end
						else
							user:SendData(tConf.mSet.sBot,"*** Error: You can't kick Immune Profile users.")
							return 0
						end
						if (tConf.tWarn[victim.sName]["Kicked"] == tConf.mSet.kLimit) then
							SendToAll(tConf.mSet.sBot, victim.sName.." has been timebanned for "..tConf.mSet.iTimeBan.." minutes by "..user.sName.." because : "..reason)
							victim:SendPM(tConf.mSet.sBot, "You've been timebanned for "..tConf.mSet.iTimeBan.." minutes by "..user.sName.." because: "..reason)
							tConf.tWarn[victim.sName] = nil
							victim:TimeBan(tConf.mSet.iTimeBan)
						else
							SendToAll(tConf.mSet.sBot, victim.sName.." has been kicked by "..user.sName.." because : "..reason)
							victim:SendPM(tConf.mSet.sBot, "You've been kicked by "..user.sName.." because: "..reason)
							victim:TempBan()
							victim:Disconnect()
						end
					end
				end
			else
				user:SendData(tConf.mSet.sBot,"*** Error: You are not allowed to use this command.")
			end
		end,
		}
		if tCmds[cmd] then 
			return tCmds[cmd](user,data), 1
		end
	end
end

Best regards,

jiten

Dessamator

2 scripts done by jiten, hmm i see a pattern here, nicely done m8, :D
Ignorance is Bliss.

jiten

QuoteOriginally posted by Dessamator
2 scripts done by jiten, hmm i see a pattern here, nicely done m8, :D
Indeed :D

Jaakko

A question about this script.
If I set the timeban for 1440 minutes and when a user that has been kicked 3 times (timebanned) tries to enter my hub will PtokaX tell him that he has been banned for 24 hours or does it say 1440 minutes?

jiten

QuoteOriginally posted by Jaakko
A question about this script.
If I set the timeban for 1440 minutes and when a user that has been kicked 3 times (timebanned) tries to enter my hub will PtokaX tell him that he has been banned for 24 hours or does it say 1440 minutes?
He will say that he's timebanned for 1440 minutes.

Best regards.

SMF spam blocked by CleanTalk