well it depens how often does he want to 'use' the ban data.Papillon wrote:well... if he wants every ban to be recorded and logged he will have to work with files.. and that's really not hard
not even quiteDe Kus wrote:i dunno what he exactly wants, but sounds similar to that i would really like to make. but i am laking knowledge about using tables.
well, you can use (for the good start) something next code for searching banlist *$newban is new ban string from `bind mode'*:De Kus wrote:---snip---
and here is my problem. id need a way finding the ban in the bots banlist, if not found returning doing nothing, and if found returning creator handle. in case creator handle is invalid it suggest it is created by script, means
by the bot equilant to ban is made by a master.
---snip---
Code: Select all
foreach list_of_bans [banlist] {
foreach {ban comment expire created lastact owner} $list_of_bans {
if {[string match $ban $newban]} {
return ($owner)
}
}
}
Papillon wrote:the problem with caches is that it dissapears if the bot goes down ... of course you can store it all in cache but then I would make sure the complete cache is written to a file before rehash, restart, sighterm, kill ..... etc
Code: Select all
#Script for adding and removing bans to and from the bots intern banlist by privileged persons.
#v1.0.4: 26.02.03 fixed logical error in the if expression for -userbans - still unknown why no -b comes tried to fix with ""
#v1.0.3: 22.02.03 fixed problems somehow only occuring on unix eggdrops with variables and newchanban return
#v1.0.2: 19.02.03 changed texts to be configurable
#v1.0.1: 16.02.03 changed priority of other bots bans
#v1.0 : 15.02.03 first release
set banmanagerbanreason "bis zu ${ban-time}min - requested by"
#up to
set banmanagerillegal "Sorry, diesen Ban kann ich nicht annehmen!"
#Sorry, I can't accept this ban!
set banmanagernorights "Sorry, ich kenn dich nicht mit irgendwelchen Rechten, die dir das Hinzufügen von Bans gestatten würden."
#Sorry, I don't know you having any rights to add a ban.
set banmanagernoperm "Sorry, du hast nicht die Rechte den Ban zu entfernen"
#Sorry, your don't have the rights to remove this ban
#only configuration you'd like to make could be to change german feedback ^-^
#no more configuration needed, tried to hold script flexible using global variables
#
# begin of Code - change on your own risk :)
#
bind mode - "*+b" banmanager:add
bind mode - "*-b" banmanager:rem
proc banmanager:add {nick uhost hand chan mode newban} {
global botnick banmanagerbanreason banmanagerillegal banmanagernorights
if { [matchban $newban $chan] || $nick == "" || $nick == $botnick } { return 0 }
#ban is already registered? fine, what else would we want?
#till now server bans will be ignored until i figure out how to add them as flagged op, not master
if { [matchattr $hand m|m $chan] || [matchattr $hand o|o $chan] || [matchattr $hand l|l $chan] } {
newchanban $chan $newban $hand "$banmanagerbanreason $hand"
if { [isban $newban $chan] } {
putcmdlog "<$nick@$chan> !$hand! added Channelban $newban"
} else {
pushmode $chan -b $newban
puthelp "NOTICE $nick :$banmanagerillegal"
}
#creates the ban with the handle as creator and with standard banlifetime
return 1
} elseif { [lsearch -exact [channel info $chan] -userbans] > -1} {
#removing ban if no userbans are allowed on channel and telling the user this
pushmode $chan -b "$newban"
puthelp "NOTICE $nick :$banmanagernorights"
} else { return 2 }
}
proc banmanager:rem {nick uhost hand chan mode oldban} {
global botnick banmanagernoperm
if { $nick == $botnick && [lsearch -exact [channel info $chan] +dynamicbans] > -1} { return 0 }
#do nothing if ban gets removed by a bot on channels with dynamic bans
set banowner [getbanowner $oldban $chan]
if { $banowner == "*" } {
return 0
#ban not registered? who cares... now its away
} elseif { ![validuser $banowner] } { set banowner [finduser -telnet!*@*] }
#owner doenst exist? must be from a script. and i hope everyone has the autocreated account with host this host
if { [matchattr $banowner m|m $chan] && ![matchattr $banowner b] } {
#i mean... any owner is master, isnt it?
set ownerrank 3
} elseif { [matchattr $banowner o|o $chan] } {
set ownerrank 2
} elseif { [matchattr $banowner l|l $chan] } {
set ownerrank 1
} else { set ownerrank 0 }
if { [matchattr $hand m|m $chan] && ![matchattr $banowner b] } {
set handrank 3
} elseif { [matchattr $hand o|o $chan] || $nick == "" } {
#nick can only be empty on server mode changes, so lets say server is op
set handrank 2
} elseif { [matchattr $hand l|l $chan] } {
set handrank 1
} else { set handrank 0 }
if { $handrank >= $ownerrank } {
if { ![killchanban $chan $oldban] } {
if {(([matchattr $hand o] || [matchattr $hand n|n $chan]) && ![isbansticky $oldban]) || [matchattr $hand m]} {
#only global ops and channel owner may remove a global ban and non sticky bans
killban $oldban
putcmdlog "<$nick@$chan> !$hand! removed global ban $oldban"
return 1
}
} else {
putcmdlog "<$nick@$chan> !$hand! removed Channelban $oldban"
return 1
}
}
pushmode $chan +b $oldban
if { !($nick == "") } { puthelp "NOTICE $nick :$banmanagernoperm" }
return 1
}
#this code is sponsered by StormLord @ egghelp.org
proc getbanowner {oldban chan} {
foreach list_of_bans [banlist] {
foreach {ban comment expire created lastact owner} $list_of_bans {
if { $ban == $oldban } {
return $owner
}
}
}
foreach list_of_bans [banlist $chan] {
foreach {ban comment expire created lastact owner} $list_of_bans {
if { $ban == $oldban } {
return $owner
}
}
}
return *
}
na gutcaesar wrote:An english translation? ;]