PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: gizmo on 16 January, 2004, 18:03:28

Title: kick log and banlog
Post by: gizmo on 16 January, 2004, 18:03:28
HI can someone tell if its impossible to make a script who logs who banned and reason and the same when the op kicks ?
Title:
Post by: NightLitch on 16 January, 2004, 18:07:28
it's not impossible, Real simple acually.
Title:
Post by: gizmo on 16 January, 2004, 18:08:19
do you know if there is such script ready ??
Title:
Post by: NightLitch on 16 January, 2004, 18:10:28
can make one easily for ya
Title:
Post by: NightLitch on 16 January, 2004, 18:12:59
question is how do you want it to look
Title:
Post by: NightLitch on 16 January, 2004, 19:11:55
try this one real simple:

-- Simple Kick/Ban Log -Bot
-- By: NightLitch 2004
---------------------------------------------
BotName = "T-Rage"
---------------------------------------------
BanLog = "banlog.txt"
KickLog = "kicklog.txt"
---------------------------------------------
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") then
ComFunc(curUser,data,"!ban",BanLog)
return 1
elseif (cmd == "!kick") then
ComFunc(curUser,data,"!kick",KickLog)
return 1
end
end
end
---------------------------------------------
function ComFunc(curUser,data,command,file)
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 = Time.."  |  "..vUser.sName.." is "..sc.." by: "..curUser.sName..", becouse: "..reason.." \n"
writeto(file)
write(Msg)
writeto()
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
vUser:TempBan()
elseif sc == "banned" then
vUser:Ban()
end
end
-- By: NightLitch

If you want anything changed just tell me...
Title:
Post by: gizmo on 16 January, 2004, 19:14:31
like this if its possible  

!banlog  shows  [nick] bannade  by op whos banned and reason  and date

!kicklog   and the same here but kicked
Title:
Post by: NightLitch on 16 January, 2004, 19:17:15
sure can add it later have to go out be back later... but fix it.. np
Title:
Post by: NightLitch on 16 January, 2004, 19:17:46
test the bot aleast so I now you're happy with it so far... :-)
Title:
Post by: Stravides on 16 January, 2004, 19:34:04
only problem is that this script seems to replace the value in it, i would expect to see 2 lines for 2 kicks for the same user...  can this be ammended
 :)
Title:
Post by: NightLitch on 16 January, 2004, 19:40:20
k I missed a part... sry guys...
Title:
Post by: NightLitch on 16 January, 2004, 19:42:35
here is a little fix til I add the Viewing part

* UPDATED * Again

-- Simple Kick/Ban Log -Bot
-- By: NightLitch 2004
-- Made some fixes
---------------------------------------------
BotName = "T-Rage"
---------------------------------------------
BanLog = "banlog.txt"
KickLog = "kicklog.txt"
---------------------------------------------
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)
return 1
elseif (cmd == "!kick") and curUser.bOperator then
ComFunc(curUser,data,"!kick",KickLog)
return 1
end
end
end
---------------------------------------------
function ComFunc(curUser,data,command,file)
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.." |"..reason.." | "..Time..""
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
vUser:TempBan()
elseif sc == "banned" then
vUser:Ban()
end
end
-- By: NightLitch

*UPDATED* Again

hope this one works ;-)
Title:
Post by: Stravides on 16 January, 2004, 19:53:47
Sorry, Still overwriting

heres the output, tested on a second dc++K client Mal
and used the script from DC++ op acct,.

i get this
16/01-2004 | Mal | kicked | Stravides |kasjdhflkasdf


would it be different if the time was added to the date, or file append used ?
 however you do that ??

:)
Title:
Post by: NightLitch on 16 January, 2004, 19:57:49
hehe... what a miss of me...

above code is updated...
Title:
Post by: NightLitch on 16 January, 2004, 20:00:28
DAMN.. still not working...
Title:
Post by: gizmo on 16 January, 2004, 20:01:03
I can not find the txt files where is it in /scripts ?
Title:
Post by: gizmo on 16 January, 2004, 20:03:28
does it works with kickban to ??
Title:
Post by: NightLitch on 16 January, 2004, 20:05:30
yepp directly in script folder... just create a folder log

and replace with

BanLog = "log/banlog.txt"
KickLog = "log/kicklog.txt"

above code updated again now it changes line
Title:
Post by: NightLitch on 16 January, 2004, 20:06:25
will update in later now, gonna catch some TV. l8r
Title:
Post by: Stravides on 16 January, 2004, 20:14:50
Whoohoo Works :)  
I've formatted to include time too :)

Thanks matey :)
Title:
Post by: gizmo on 16 January, 2004, 21:39:43
now its works but when they right click kick  $Kick its not logs the kick.
Title:
Post by: NightLitch on 16 January, 2004, 22:38:07
I think I'Am getting tired... nothing seams to get right now... F***... sry...

Plop help ME!

-- Simple Kick/Ban Log -Bot
-- By: NightLitch 2004
-- Made some fixes
---------------------------------------------
BotName = "T-Rage"
---------------------------------------------
BanLog = "banlog.txt"
KickLog = "kicklog.txt"
BanTable = {}
KickTable = {}
---------------------------------------------
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)
return 1
elseif (cmd == "!kick") and curUser.bOperator then
ComFunc(curUser,data,"!kick",KickLog)
return 1
elseif (cmd == "!getban") and curUser.bOperator then
ShowLogs(curUser,data,"!getban","banned")
return 1
end
end
end
---------------------------------------------
function ComFunc(curUser,data,command,file)
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
vUser:TempBan()
elseif sc == "banned" then
vUser:Ban()
end
end

function ShowLogs(curUser,data,command,dora)
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
------------------------------- THIS PART FUCKS UP-------------------------
LoadTable(BanTable,BanLog)
for vNick,vInfo in BanTable do
local s,e,reason = strfind( vInfo, "%S+|%S+|%S+|(.*)")
SendToAll("Reason: "..reason)
end
------------------------------- THIS PART FUCKS UP-------------------------
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
-- By: NightLitch

think you see my problem m8... I have never had this problem... think I Am gonna need to take more lessons from you
about strfind and so on... this sucks... BIG!

pls help me out...
Title:
Post by: NightLitch on 16 January, 2004, 22:41:18
AM CRYING HERE!!!

Damn I feel I SUCK... have done it over and over time after time...

But now IT FU**s up...

I quit... :-/

don't mean that but... gggaahhh...
Title:
Post by: gizmo on 16 January, 2004, 23:03:22
hehe take the time you want =)) its no hurry
Title:
Post by: gizmo on 16 January, 2004, 23:13:41
?r du svensk ?
Title:
Post by: NightLitch on 16 January, 2004, 23:40:42
jo ?r det Gizmo
Title:
Post by: plop on 17 January, 2004, 01:07:20
try this nightlitch.
local s,e,reason = strfind( vInfo, "([^|]+)$")
little explenation with it, search from the back and match everything BUT the |.

plop
Title:
Post by: NightLitch on 17 January, 2004, 01:09:45
thx m8
Title:
Post by: gizmo on 17 January, 2004, 01:10:03
hehe nice f?r jag suger p? engelska :P
Title:
Post by: NightLitch on 17 January, 2004, 01:25:20
explain more, here is the code I want it from.

"..sc.."|"..curUser.sName.."|"..Time.."|"..reason
   for vNick,vInfo in table do
      local s,e,reason = strfind( vInfo, "([^|]+)$")
      GetInfo = "Reason: "..reason..""
   end
Title:
Post by: NightLitch on 17 January, 2004, 01:25:51
ok, men jag pratar bara svenska i PM annars engelska h?r...
Title:
Post by: plop on 17 January, 2004, 02:01:16
QuoteOriginally posted by NightLitch
ok, men jag pratar bara svenska i PM annars engelska h?r...
yep use english here on the board unless of course it's a pm msg, then you may use swedish.

plop
Title:
Post by: plop on 17 January, 2004, 02:12:03
QuoteOriginally posted by NightLitch
explain more, here is the code I want it from.

"..sc.."|"..curUser.sName.."|"..Time.."|"..reason
   for vNick,vInfo in table do
      local s,e,reason = strfind( vInfo, "([^|]+)$")
      GetInfo = "Reason: "..reason..""
   end


"..sc.."|"..curUser.sName.."|"..Time.."|"..reason    <-- it starts there with the search.
-------------------------------------------^ and stops there.

with [] you can make you own character ranges 2 search for.
only matches the S.
[SHDE] matches the S or H or D or E.
[^S] matches all but the S.
adding a $ sign @ the end means start searching from the end of the string.
^ in the start means 2 start from the beginning.
"^a" matches only if the 1st character is the character a.

time for a howto: pattern matching part 2.

plop
Title:
Post by: Stravides on 17 January, 2004, 09:52:11
the right click was gonna be my next question too :)
Title:
Post by: gizmo on 17 January, 2004, 10:25:55
ok then we talk english =)
Title:
Post by: NightLitch on 17 January, 2004, 14:06:11
QuoteOriginally posted by plop
   


QuoteOriginally posted by NightLitch
explain more, here is the code I want it from.

"..sc.."|"..curUser.sName.."|"..Time.."|"..reason
for vNick,vInfo in table do
local s,e,reason = strfind( vInfo, "([^|]+)$")
GetInfo = "Reason: "..reason..""
end


"..sc.."|"..curUser.sName.."|"..Time.."|"..reason <-- it starts there with the search.
-------------------------------------------^ and stops there.

with [] you can make you own character ranges 2 search for.
only matches the S.
[SHDE] matches the S or H or D or E.
[^S] matches all but the S.
adding a $ sign @ the end means start searching from the end of the string.
^ in the start means 2 start from the beginning.
"^a" matches only if the 1st character is the character a.

time for a howto: pattern matching part 2.

ok think I understand, gonna try it some more... this is the things
I need to learn more about no doubt.

ThX m8
Title:
Post by: NightLitch on 17 January, 2004, 15:30:08
Ok here is the bot you all wanted :-p

-- T-Rage Kick/Ban Count/Log  -Bot
-- Version: 2.8
-- By: NightLitch 2004
-- Made some fixes
-- Major update :-p
-- Counter added...
-- Made some fixes...
--
-- Available commands:
-- !kick [reason]
-- !ban [reason]
-- !getban
-- !getkick
---------------------------------------------
BotName = "T-Rage"
---------------------------------------------
BanLog = "banlog.txt"
KickLog = "kicklog.txt"
BanTable = {}
KickTable = {}
Count = {}
---------------------------------------------
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
vUser:TempBan()
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,whom = strfind(data,"$Kick%s+(.*)")
if GetItemByName(whom) then
vUser=GetItemByName(whom)
vUser:TempBan()
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

enjoy, hope you all like it... (I now Plop little messy some parts... :-D )

but works... tell me if you want something else in it.
Title:
Post by: gizmo on 17 January, 2004, 16:09:58
its not logging the kicks and bans
Title:
Post by: gizmo on 17 January, 2004, 16:13:20
or dosent it working when they use !kickban and  
$Kick <--- right click kick
Title:
Post by: gizmo on 17 January, 2004, 17:05:54
and is it possible to add that after 3 kick they been autobannad

becouse when i have your scritp and the script above the scipt above not working


maxKicks = 3
usrKicks = { }

ignoreKicks = nil
silentKicks = nil
silentKickPMs = nil

function DataArrival(user, data)
   if strsub(data, 1, 1) == "<" then
      local s, e, who, why = strfind(data, "^%b<> %S+ is kicking (%S+) because: (.*)|$")
      if s and silentKicks then return 1 end
   elseif strsub(data, 1, 3) == "$To" then
      local s, e, who, why = strfind(data, "^%$To: (%S+) From: %S+ %$%b<> You are being kicked because: (.*)|$")
      if s and silentKickPMs then return 1 end
   elseif strsub(data, 1, 5) == "$Kick" then
      local s, e, who = strfind(data, "^%$Kick (%S+)|$")
      if s then
         local tmp = GetItemByName(who)
         usrKicks[who] = usrKicks[who] or 0
         usrKicks[who] = usrKicks[who] + 1
         if tmp and usrKicks[who] >= maxKicks then
            SendToOps("Hub-Security", "User "..who.." has now been permbanned for repeated violations.")
            tmp:SendData("*** Banned.")
            tmp:Ban() -- tmp:NickBan()
         end if ignoreKicks then return 1 end
      end
   end
end -- tezlo
Title:
Post by: NightLitch on 17 January, 2004, 17:12:49
can add that script.

QuoteOriginally posted by gizmo    
or dosent it working when they use !kickban and
$Kick <--- right click kick

!kickban is an own command but can add it to but don't know how it's working with other scripts... what other
scripts are you using ??

And $Kick should work... does for me...
Title:
Post by: NightLitch on 17 January, 2004, 18:02:41
Here is the new one updated with x kicks = ban
tell me if it's not working. :-)

*UPDATED* *AGAIN*

-- T-Rage Kick/Ban Count/Log -Bot
-- Version: 3.1
-- By: NightLitch 2004
-- Made some fixes
-- Major update :-p
-- Counter added...
-- Made some fixes...
-- Added 3x kick = ban
-- Fixed a small error
-- Fixed $To & $Kick
--
-- Available commands:
-- !kick [reason]
-- !ban [reason]
-- !getban
-- !getkick
---------------------------------------------
BotName = "T-Rage"
---------------------------------------------
BanLog = "banlog.txt"
KickLog = "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[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
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
Title:
Post by: Stravides on 17 January, 2004, 18:38:06
ok I'm using the majority of Nightlich's code ie here,
-- Simple Kick/Ban Log -Bot
-- By: NightLitch 2004
-- Made some fixes
---------------------------------------------
BotName = "Granny"
---------------------------------------------
BanLog = "banlog.txt"
KickLog = "kicklog.txt"
---------------------------------------------
Time = ""..date("%d").."/"..date("%m").."-"..date("%Y").." - "..date("%H")..":"..date("%M")..""
---------------------------------------------
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)
return 1
elseif (cmd == "!kick") and curUser.bOperator then
ComFunc(curUser,data,"!kick",KickLog)
return 1
elseif (cmd == "!kickfile") and curUser.bOperator then
SendKickFile(curUser)
return 1
elseif (cmd == "!banfile") and curUser.bOperator then
SendBanFile(curUser)
return 1
elseif strsub(data, 1, 5) == "$To: " then
RightKick2(curUser, data)
elseif strsub(data,1,6) == "$Kick " then
RightKick1(curUser, data)
return 1
end
end
end
---------------------------------------------
function DoRead(curUser)
while 1 do
line = read()
if line == nil then break end
curUser:SendPM(BotName, line)
end
readfrom()
end
---------------------------------------------
function SendKickFile(user)
readfrom(KickLog)
DoRead(user)
end
---------------------------------------------
function SendBanFile(user)
readfrom(BanLog)
DoRead(user)
end
---------------------------------------------
function ComFunc(curUser,data,command,file)
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.." was "..sc.." By OP: "..curUser.sName.." Because: "..reason.." @ "..Time
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
vUser:TempBan()
elseif sc == "banned" then
vUser:Ban()
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,whom = strfind(data,"$Kick%s+(.*)")
if GetItemByName(whom) then
vUser=GetItemByName(whom)
vUser:TempBan()
end
end

-- By: NightLitch


But I have changed the read files a little to make them the same as all my other scripts and no parameters needed.

The right click does not save to this file ?  Any ideas on what I may be doing wrong ?
Title:
Post by: NightLitch on 17 January, 2004, 19:10:19
here is your problem:
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)
return 1
elseif (cmd == "!kick") and curUser.bOperator then
ComFunc(curUser,data,"!kick",KickLog)
return 1
elseif (cmd == "!kickfile") and curUser.bOperator then
SendKickFile(curUser)
return 1
elseif (cmd == "!banfile") and curUser.bOperator then
SendBanFile(curUser)
return 1
-- COMMANDS ENDS HERE --
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

this is how it should be
Title:
Post by: Stravides on 17 January, 2004, 19:39:20
many thanks

:)
Title:
Post by: gizmo on 17 January, 2004, 20:32:33
im using glory in our hubs
Title:
Post by: gizmo on 17 January, 2004, 21:04:14
damn its not working =(

i have put kicklog.txt and banlog.txt in a map in scripts called log   log/kicklog.txt
Title:
Post by: NightLitch on 18 January, 2004, 00:29:03
change:

BanLog = "banlog.txt"
KickLog = "kicklog.txt"
to:
BanLog = "log/banlog.txt"
KickLog = "log/kicklog.txt"

this should work...

create a folder named -( log )- thats it...

duno if it not work... stange...
Title:
Post by: gizmo on 20 January, 2004, 14:37:36
i have changed but its not wprks =(

[14:26:03] User not found...

that message comes up
Title:
Post by: NightLitch on 20 January, 2004, 15:07:56
real strange...
Title:
Post by: NightLitch on 20 January, 2004, 15:10:09
Gizmo, how does it work if you don't change anything ??
Title:
Post by: NightLitch on 20 January, 2004, 15:10:57
Above code updated by the way....
Title:
Post by: NightLitch on 20 January, 2004, 15:24:11
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...
Title:
Post by: gizmo on 20 January, 2004, 15:27:38
scripts/log/kicklog.tx
Title:
Post by: NightLitch on 20 January, 2004, 15:28:33
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.
Title:
Post by: NightLitch on 20 January, 2004, 15:29:24
Quotescripts/log/kicklog.tx

think you missed a ( t ) here in txt...
Title:
Post by: Pedro on 20 January, 2004, 22:12:37
Now this is the script I have been looking for :D

Gr8 work, it works a treat.

Many thanx


HAPPY DAYS
Title:
Post by: NightLitch on 20 January, 2004, 22:14:58
np, fun creating it...
Title:
Post by: plop on 20 January, 2004, 22:29:02
QuoteOriginally posted by gizmo
im using glory in our hubs
make sure that this script runs before glory, then it should work.

plop
Title:
Post by: Pedro on 21 January, 2004, 02:59:19
I dont have glory,
using mean machine
and a share and minslot redirector

and it works just gr8 for me
Title:
Post by: NightLitch on 07 February, 2004, 12:17:37
When I have the time I will update this script more, Right now Am
working with NXS-3 very much.

/NL
Title:
Post by: gizmo on 07 February, 2004, 13:30:49
ok =)
Title:
Post by: Shurlock on 01 June, 2004, 06:45:00
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!!