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.

script to clear channel banlist when full

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

script to clear channel banlist when full

Post by BrewMaster »

I am looking for a script that will clear the channel banlist before it is full.
I tried banlistcleaner.tcl that is onsite but it only seams to adjust the channel banlist when the bot first enters a room. When channel banlist fills up again it dont flush it.

Idealy, the script would remove X number of bans when the channel banlist reached X number of bans in it. Preventing a channel banlist from reaching the maximum channel banlist.
any help would be appreciated.

brew
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

eggdrop.conf:
#
# dynamicbans
# Only activate bans on the channel when necessary? This keeps
# the channel's ban list from getting excessively long. The bot
# still remembers every ban, but it only activates a ban on the
# channel when it sees someone join who matches that ban.
#

....

# Set here the maximum number of bans you want the bot to set on a channel.
# Eggdrop will not place any more bans if this limit is reached. Undernet
# currently allows 45 bans, IRCnet allows 30, EFnet allows 100, and DALnet
# allows 100.
set max-bans 30
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

This is actually the old banlist cleaner. I edited this script recently to be free from of all kinds of bugs and errors and added new functions, like "ALL" to remove all channel bans. Here you go, it should work fine!

Code: Select all

bind join - "*" banlist:clean:on:join
bind mode - "*" banlist:clean:on:mode

#Remove bans if they go over this number
set banlistmax "100"

#Set the type/order in which you would like to remove the channel bans.
#USAGE: [1/2/3] (1=RANDOM BANS, 2=RECENT PLACED BANS, 3=LAST PLACED BANS)
#Use '1' If you want to remove bans 'randomly' from the channel's banlist.
#Use '2' If you want to remove 'recent placed bans' (increasing banlist) from the channel's banlist.
#Use '3' If you want to remove 'last placed bans' (decreasing banlist) from the channel's banlist.
#Use '4' If you want to remove all bans placed by the bot from the channel's banlist.
set banlisttype "3"

#No of bans to remove 'ALL' or 'any number: 10, 50, 125'
set banlistremove "30"

#Minutes after bot join to check the channel for bans
set banlistdelaycheck "5"


proc banlist:clean:on:join {nick uhost hand chan} {
 global banlistdelaycheck
 if {[isbotnick $nick]} {
  timer $banlistdelaycheck [list banlist:clean:on:mode $nick $uhost $hand $chan "+b" "on:join"]
  }
}

proc banlist:clean:on:mode {nick uhost hand chan mode target} {
 global botnick banlistmax banlisttype banlistremove
 if {[string is integer $banlistremove] && ($banlistremove > $banlistmax)} { return 0 }
 if {[string equal "+b" $mode] && [botisop $chan]} {
  if {[llength [chanbans $chan]] >= $banlistmax} {
   if {$banlisttype == "1"} {
        set banlist [chanbans $chan]
    } elseif {$banlisttype == "2"} {
        set banlist [lsort -index 2 -integer -increasing [chanbans $chan]]
    } elseif {$banlisttype == "3"} {
        set banlist [lsort -index 2 -integer -decreasing [chanbans $chan]]
    } elseif {$banlisttype == "4"} {
        set banlist [list]
        foreach ban [chanbans $chan] {
         if {[string equal -nocase "[lindex [split [lindex $ban 1] !] 0]" $botnick]} {
          lappend banlist $ban
          }
       }
    }
    if {[string is integer $banlistremove]} {
     set removebans [lrange $banlist 0 [expr $banlistremove - 1]]
     putserv "ONOTICE $chan :Channel banlist currently has $banlistmax entries. Removing the last $banlistremove bans placed."
     foreach ban $removebans {
       pushmode $chan -b [lindex $ban 0]
      }
     flushmode $chan
     return 0
    } elseif {[string equal -nocase "all" $banlistremove]} {
      putserv "ONOTICE $chan :Channel banlist currently has $banlistmax entries. Clearing the channel banlist."
      resetbans $chan
      return 0
      }
    }
  }
}
·­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 »

Thanks awyeah. Thats exactly what I was looking for. I am testing it now.

I am going to delete out the lines:

Code: Select all

putserv "ONOTICE $chan :Channel banlist currently has $banlistmax entries. Removing the last $banlistremove bans placed."
and:

Code: Select all

putserv "ONOTICE $chan :Channel banlist currently has $banlistmax entries. Clearing the channel banlist."
If I remove those 2 lines of code, I should not have any issues correct?
(other than its not going to tell the ops what its doing).

Thanks for the response and recoding of the old script.

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

Post by awyeah »

No, the script should be just fine even after you delete those two lines. Those lines just send an OPNOTICE to the channel, before they start removing bans from the banlist.
·­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 »

Thanks awyeah. The script is working great!
Post Reply