kick log and banlog - Page 3
 

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 log and banlog

Started by gizmo, 16 January, 2004, 18:03:28

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

NightLitch

Gizmo, how does it work if you don't change anything ??
//NL

NightLitch

Above code updated by the way....
//NL

NightLitch

well have notice some more bugs that I Am fixing now.

One thing Gizmo you have correct path to filename so it
isn't folder Log & in script log ???

notice to that log is not written when right kicking...
//NL

gizmo

scripts/log/kicklog.tx

NightLitch

New Version:

-- T-Rage Kick/Ban Count/Log -Bot
-- Version: 3.4
-- By: NightLitch 2004
-- Made some fixes
-- Major update :-P
-- Counter added...
-- Made some fixes...
-- Added 3x kick = ban
-- Fixed a small error
-- Fixed some more errors...
-- NOTE: create a folder name (  log  )
-- the files will be created there when first user is kicked/banned.
--
-- Available commands:
--	!kick  [reason]
--	!ban  [reason]
--	!getban 
--	!getkick 
---------------------------------------------
BotName = "T-Rage"
---------------------------------------------
BanLog = "log/banlog.txt"
KickLog = "log/kicklog.txt"
BanTable = {}
KickTable = {}
Count = {}
maxKicks = 3 
usrKicks = { } 

---------------------------------------------
Time = ""..date("%d").."/"..date("%m").."-"..date("%Y")..""
---------------------------------------------
function DataArrival(curUser, data) 
	if (strsub(data, 1, 1) == "<" ) then 
		data=strsub(data,1,strlen(data)-1) 
		local _,_,cmd=strfind(data, "%b<>%s+(%S+)") 
		if not cmd then cmd = "0" end 
		cmd = strlower(cmd) 
		if (cmd == "!ban") and curUser.bOperator then
			ComFunc(curUser,data,"!ban",BanLog,BanTable)
			return 1
		elseif (cmd == "!kick") and curUser.bOperator then
			ComFunc(curUser,data,"!kick",KickLog,KickTable)
			return 1
		elseif (cmd == "!getban") and curUser.bOperator then
			ShowLogs(curUser,data,"!getban","ban(s)",BanLog,BanTable)
			return 1
		elseif (cmd == "!getkick") and curUser.bOperator then
			ShowLogs(curUser,data,"!getkick","kick(s)",KickLog,KickTable)
			return 1
		end
	elseif strsub(data, 1, 5) == "$To: " then
		RightKick2(curUser, data)
	elseif strsub(data,1,6) == "$Kick " then
		RightKick1(curUser, data)
		return 1
	end
end 
---------------------------------------------
function ComFunc(curUser,data,command,file,table)
	local s,e,nick,reason = strfind( data, "%b<>%s+%S+%s+(%S+)%s*(.*)" )
	if nick == nil or nick == "" then
		curUser:SendData(BotName,"*** Syntax error in command "..command.."  [reason]: No parameter given.")
		return 1
	end
	local vUser = GetItemByName(nick)
	if not vUser then
		curUser:SendData(BotName,nick.." is not online or wrong name...")
		return 1
	end
	if (rule == nil or rule == "") then rule = "Not given"
	else rule = ""..rule
	end
	if command == "!kick" then 
	sc = "kicked" 
	elseif command == "!ban" then 
	sc = "banned" 
	end
	Msg = ""..vUser.sName.."$"..sc..","..curUser.sName..","..Time..","..reason
	local handle = openfile(file, "a")
	write(handle,Msg.."\r\n")
	closefile(handle)
	vUser:SendPM(BotName,"You are being "..sc.." by "..curUser.sName..", because: "..reason)
	SendToAll(BotName,curUser.sName.." is "..sc.." "..nick..", reason: "..reason)
	if sc == "kicked" then
			usrKicks[nick] = usrKicks[nick] or 0
			usrKicks[nick] = usrKicks[nick] + 1

		if vUser and usrKicks[nick] >= maxKicks then 
			SendToOps("Hub-Security", "User "..nick.." has now been permbanned for repeated violations.") 
			vUser:SendData("*** Banned.") 
			Msg = ""..vUser.sName.."$banned,"..curUser.sName..","..Time..",Kicked "..maxKicks.." times"
			local handle = openfile(BanLog, "a")
			write(handle,Msg.."\r\n")
			closefile(handle)
			vUser:Ban()
		else
			vUser:TempBan()
		end
	elseif sc == "banned" then
		vUser:Ban()
	end
end

function ShowLogs(curUser,data,command,dora,file,table)
	local s,e,nick = strfind( data, "%b<>%s+%S+%s+(%S+)" )
	if nick == nil or nick == "" then
		curUser:SendData(BotName,"*** Syntax error in command "..command.." : No parameter given.")
		return 1
	end
	LoadTable(table,file)
	local one = ""
	for vNick,vInfo in table do
		if strlower(nick) == strlower(vNick) then
			local s,e,arg,operator,time,reason = strfind( vInfo, "(%S+),(%S+),(%S+),(.*)")
			GetInfo = "User: "..nick.." is "..arg..", by "..operator.." becouse: "..reason..", at time "..time..""
			GetCount(file,dora,nick)
			curUser:SendData(BotName,GetInfo)
			curUser:SendData(BotName,"Total "..CNT)
			one = "1"
		end
	end
	if one == "" then
		curUser:SendData(BotName,"User not found...")
	end
end
	
function LoadTable(table,file)
	local handle = openfile(file, "r")
	if (handle) then
    		local line = read(handle)
    		while line do
			s,e,ind,val = strfind( line, "(.*)$(.*)")
			table[ind]=val
			line = read(handle)
    		end
  		closefile(handle)
	end
end

function RightKick2(curUser, data)
	if strfind(data,"You are being kicked because:") then
		local _,_, Name,Op,reason = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$<%S+> You are being kicked because:%s+(.*)|")
		OpCheck = GetItemByName(Op)
		if OpCheck~=nil and OpCheck.bOperator then
			vUser = GetItemByName(Name)
			if vUser~=nil then
				Msg = ""..vUser.sName.."$kicked,"..curUser.sName..","..Time..","..reason
				local handle = openfile(KickLog, "a")
				write(handle,Msg.."\r\n")
				closefile(handle)
			end
		end
	end
end

function RightKick1(curUser, data)
	data=strsub(data,1,strlen(data)-1)
	local s,e,who = strfind(data,"$Kick%s+(.*)")
	if GetItemByName(who) then
		local vUser=GetItemByName(who)
		usrKicks[who] = usrKicks[who] or 0 
		usrKicks[who] = usrKicks[who] + 1 
		if vUser and usrKicks[who] >= maxKicks then 
			SendToOps("Hub-Security", "User "..who.." has now been permbanned for repeated violations.") 
			vUser:SendData("*** Banned.") 
			Msg = ""..vUser.sName.."$banned,"..curUser.sName..","..Time..",Kicked "..maxKicks.." times"
			local handle = openfile(BanLog, "a")
			write(handle,Msg.."\r\n")
			closefile(handle)
			vUser:Ban()
		else
			vUser:TempBan()
		end
	end
end

function ShowCount(filename)
	local file = openfile(filename, "r")
	assert(file, "cant open "..filename)

	local total, Count = 0, {}			
	local line = read(file, "*l")			
	while line do
		total = total+1 			
		local s, e, nick, arg, op, time, reason = strfind(line, "(%S-)$(%S-),(%S-),(%S-),(.*)")
		assert(s, "bad format on line "..total)	

		Count[strlower(nick)] = (Count[strlower(nick)] or 0)+1	
		line = read(file, "*l")			
	end closefile(file)
	return Count, total
end

function GetCount(file,dora,user)
	local Count, total = ShowCount(file)
	if Count[user] == nil then
		CNT = dora..": 0"
		return CNT
	else
		CNT = dora..": "..Count[user]
		return CNT
	end
end
-- By: NightLitch

works with no problems for me in kicking/banning & finding users in file.
//NL

NightLitch

Quotescripts/log/kicklog.tx

think you missed a ( t ) here in txt...
//NL

Pedro

Now this is the script I have been looking for :D

Gr8 work, it works a treat.

Many thanx


HAPPY DAYS
if it aint broke, open it up and find out why...

NightLitch

np, fun creating it...
//NL

plop

QuoteOriginally posted by gizmo
im using glory in our hubs
make sure that this script runs before glory, then it should work.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Pedro

I dont have glory,
using mean machine
and a share and minslot redirector

and it works just gr8 for me
if it aint broke, open it up and find out why...

NightLitch

When I have the time I will update this script more, Right now Am
working with NXS-3 very much.

/NL
//NL

gizmo


Shurlock

Although this thread has not been replied to for some time, I dare request one tiny addition.

Normal kicks will return the users IP while this script doesn't.

I believe the script would be perfect if it would include (or even be based upon!) the users IP. Just in case he/she decides to use a different name.

In any case: thanks NightLitch!!
If it's raining and your roof leaks, fix the roof. DON'T try to stop the rain!!

SMF spam blocked by CleanTalk