HI can someone tell if its impossible to make a script who logs who banned and reason and the same when the op kicks ?
it's not impossible, Real simple acually.
do you know if there is such script ready ??
can make one easily for ya
question is how do you want it to look
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...
like this if its possible
!banlog shows [nick] bannade by op whos banned and reason and date
!kicklog and the same here but kicked
sure can add it later have to go out be back later... but fix it.. np
test the bot aleast so I now you're happy with it so far... :-)
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
:)
k I missed a part... sry guys...
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 ;-)
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 ??
:)
hehe... what a miss of me...
above code is updated...
DAMN.. still not working...
I can not find the txt files where is it in /scripts ?
does it works with kickban to ??
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
will update in later now, gonna catch some TV. l8r
Whoohoo Works :)
I've formatted to include time too :)
Thanks matey :)
now its works but when they right click kick $Kick its not logs the kick.
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...
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...
hehe take the time you want =)) its no hurry
?r du svensk ?
jo ?r det Gizmo
try this nightlitch.
local s,e,reason = strfind( vInfo, "([^|]+)$")
little explenation with it, search from the back and match everything BUT the |.
plop
thx m8
hehe nice f?r jag suger p? engelska :P
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
ok, men jag pratar bara svenska i PM annars engelska h?r...
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
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
the right click was gonna be my next question too :)
ok then we talk english =)
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
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.
its not logging the kicks and bans
or dosent it working when they use !kickban and
$Kick <--- right click kick
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
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...
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
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 ?
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
many thanks
:)
im using glory in our hubs
damn its not working =(
i have put kicklog.txt and banlog.txt in a map in scripts called log log/kicklog.txt
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...
i have changed but its not wprks =(
[14:26:03] User not found...
that message comes up
real strange...
Gizmo, how does it work if you don't change anything ??
Above code updated by the way....
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...
scripts/log/kicklog.tx
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.
Quotescripts/log/kicklog.tx
think you missed a ( t ) here in txt...
Now this is the script I have been looking for :D
Gr8 work, it works a treat.
Many thanx
HAPPY DAYS
np, fun creating it...
QuoteOriginally posted by gizmo
im using glory in our hubs
make sure that this script runs before glory, then it should work.
plop
I dont have glory,
using mean machine
and a share and minslot redirector
and it works just gr8 for me
When I have the time I will update this script more, Right now Am
working with NXS-3 very much.
/NL
ok =)
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!!