This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Bot banlist cleaner/administrator

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
B
BrewMaster
Voice
Posts: 34
Joined: Sat Jul 07, 2007 8:26 am

Bot banlist cleaner/administrator

Post by BrewMaster »

I am looking for a bot ban list manager. I have not found anything to meet all the criteria I am looking for. There is one main thing I would like it to do that none I have found seem to do.

1. remove bans on the bot ban list that are older then ## days and never used. (I would not want to remove a ban created such as: Created 57 days ago, last used 11:15 OR Created 57 days ago, last used 2 days ago)

The scripts I have found do other useful stuff such as:
- scrub ban list for invalid/bad bans.
-scrub list for dupe bans ( *@192.168.11.* vs *@ 192.168.* ...remove the lower level ban)

It would be nice to have an all in one ban list manager tcl that includes all the "usefull" bot ban list management functions and what I am looking for. I am sure there are many other options that could be useful and I would love to see that included into one script.

If someone knows of a script that already does that please provide a link. I have yet to find it!

Brew
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
B
BrewMaster
Voice
Posts: 34
Joined: Sat Jul 07, 2007 8:26 am

Post by BrewMaster »

sorry I should be more specific. I meant the bots saved bans. Not the channel ban list of active bans.

I was referring to managing the bans that are saved in the bots .user file.

does this make more sense now?
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Although not a complete script, I do have bits'n'pieces that will clean your banlist of old, unused bans..

Code: Select all

set default-purgeage 180

#purgebanlist ?-age days? ?&/#channel?
#Checks through the specified banlist and removes any and all older
#bans that have not been in use in the specified number of days.
#Returns: A list of ban-structures, format similar to "banlist".

proc purgebanlist args {
 #Initialize local variables
 if {[info exists ::default-purgeage]} {
  set purgeage ${::default-purgeage}
 }
 set removed [list]

 #Read and interpret parameters
 #Only takes -age and optional channelname sofar... guess more might be added further on
 for {set i 0} {$i < [llength $args]} {incr i} {
  switch -glob -- [lindex $args $i] {
   "-age" {
    if {[string is integer [lindex $args [incr i]]]} {
     set purgeage [lindex $args $i]
    } {
     error "Age is not an integer: [lindex $args $i]"
    }
   }
   "#*" -
   "&*" {
    set channel [lindex $args $i]
    if {![validchan $channel]} {
     error "Invalid channel: $channel"
    }
   }
   default {error "Unknown option: [lindex $args $i]"}
  }
 }

 #Lets make sure we have a sane value to check age against
 #If not, just error out since we really don't know how to fix
 #it anyway
 if {[info exists purgeage] && [string is integer $purgeage]} {
  set threshold [expr [clock seconds] - $purgeage * 86400]
 } {
  error "No valid age-setting was found."
 }



 #Get the list of bans...
 if {[info exists channel]} {
  set bans [banlist $channel]
 } {
  set bans [banlist]
 }

 #...and start processing them. Save the removed bans for now.
 foreach ban $bans {
  if {[lindex $ban 3] < $threshold && [lindex $ban 4] < $threshold} {
   if {[info exists channel]} {
    killchanban $channel [lindex $ban 0]
   } {
    killban [lindex $ban 0]
   }
   lappend removed $ban
  }
 }
 #Return the list of removed bans, so the scripter can present this
 #in some fancy way with pretty colors *yuck*
 return $removed
}
Edit: fix for troublesome variablenames containing -
Edit: fixed missing close-bracket
Edit: missing space in "is integer"


This could be used with something like this, in order to provide some dcc-chat interface:

Code: Select all

bind dcc - purgebans dcc:purgebans
proc dcc:purgebans {hand idx text} {
 foreach chan [channels] {
  foreach ban [purgebanlist $chan] {
   putidx $idx "Removed \"[lindex $ban 0]\" from $chan"
  }
 }
 foreach ban [purgebanlist] {
  putidx $idx "Removed \"[lindex $ban 0]\" from global banlist"
 }
}
Of course, this could be extended to allow you to specify how old a ban must be in order to be removed, which banlist to cleanse, some fancy bells'n'whistles, etc.
Last edited by nml375 on Tue Jul 31, 2007 9:34 am, edited 4 times in total.
NML_375
B
BrewMaster
Voice
Posts: 34
Joined: Sat Jul 07, 2007 8:26 am

Post by BrewMaster »

two quick questions...
1. I place the binds at the beginning of the script? or is it irrelevant where they are placed.

2. The first line .... set default-purgeage ### is where I set the age of the unused bans I want to remove? I assume a value of 90 would remove all bans set over 90 days ago from the bots ban listing.

Finally, because I don't understand/read code well, If I have a ban in the bots ban list for example:
[05:55] <MyBot> [2331] *!*@192.168.1.1 (perm)
[05:55] <MyBot> Larry: Flooders
[05:55] <MyBot> Created 37 days ago, last used 2 days ago
And I have the line set default-purgeage 35 set in the script. what will be the outcome?

A. The ban will be flushed because it was created 37 days ago (purge age set to 35)
OR
B. The ban will not be flushed because even though it was created 37 days ago it has been used within the last 35 days. (last used 2 days ago)

I hope I am not confusing you. Thank you in advance for all the help!!

brew
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

1: Where you place the bindings really does'nt matter, as long as the proc exists once the binding is triggered. Last piece of code was just a quick user interface for the first script (which could be used by other scripts aswell).

2: Short answer: yes.
Long answer: Kinda, it is the default age to be used, should the scripter not provide one when calling the purgebanlist function. As I was a lazy coder when writing the user interface, I just went for the default.

3: B. The script will check both "added at" and "last used", and make sure both are older than the specified age before removing the ban. It will, however, currently not check wether the ban has an expire-time set, so it will remove bans that might've been scheduled for later removal.
NML_375
B
BrewMaster
Voice
Posts: 34
Joined: Sat Jul 07, 2007 8:26 am

Post by BrewMaster »

Thank you very much for the help.

I am off to go test this script!
B
BrewMaster
Voice
Posts: 34
Joined: Sat Jul 07, 2007 8:26 am

Post by BrewMaster »

Tcl error [dcc:purgebans]: can't read "::default": no such variable

(using dcc chat interface code)

I used .purgebans in dcc chat
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Minor bummer by me :oops:
Updated the post above to properly read the variable containing -
NML_375
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Well I think he wanted the script to be automated, so instead of bind dcc here, you have to use bind time BrewMaster or just use a proc with a continuous timer calling the ban remove proc.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
B
BrewMaster
Voice
Posts: 34
Joined: Sat Jul 07, 2007 8:26 am

Post by BrewMaster »

that was all Greek to me awyeah.
I was thinking that this script would run when triggered by a dcc command, then post what it removed. I guess I am off on my assumptions.

brew
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Perhaps this might lure your interest:
http://forum.egghelp.org/viewtopic.php?t=13839
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
B
BrewMaster
Voice
Posts: 34
Joined: Sat Jul 07, 2007 8:26 am

Post by BrewMaster »

nml375

the new error:

Tcl error [dcc:purgebans]: missing close-bracket
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Fixed.
Must've been abit too tired when writing that code. I hav'nt seen any further obvious flaws as of now. As soon as I get access to my devel-eggies, I'll have a more throughout bughunt, but it should work fine now.
Post above updated again.
Edit: Finally got in touch with those eggies, revealed one additional typo, apart from that, runs like a charm for me.

@Awyeah: Your script still does not alter the internal banlist, which is the topic of this thread.
NML_375
B
BrewMaster
Voice
Posts: 34
Joined: Sat Jul 07, 2007 8:26 am

Post by BrewMaster »

nml375

Worked Great!! Just what I was looking for. Thank you.

Brew
Post Reply