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.

change time minutes

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
d
demetrius_reis
Halfop
Posts: 42
Joined: Tue Aug 10, 2010 9:54 am

change time minutes

Post by demetrius_reis »

The time of ban is in hours, would like to modify for minutes.
5 { set threshold [expr [clock seconds] - $banlist(hours) * 3600]
set chanbanlist
  • foreach ban [chanbans $chan] {
    if {$threshold > [lindex $ban 2]} {
    lappend chanbanlist $ban
    }
    }
    if {[string is integer $banlist(remove)]} {
    set chanbanlist [lrange $chanbanlist 0 [expr $banlist(remove) - 1]]
    }
    }
Soon I modified the 3600 for - > 60 - > but he did not function
#Set the type of channels you would like this script to work on.
#USAGE: [1/2] (1=USER DEFINED CHANNELS, 2=ALL CHANNELS)
#Setting '1' only checks banlists of channels which are defined for the script (in the next setting)
#Setting '2' checks banlists of all the channels the bot is on
set banlist(chantype) "1"

###SET THIS ONLY IF YOU HAVE SET THE PREVIOUS SETTING TO '1'###
#Set the channels here on which the script would work. Each channel should be separated by a space.
#USAGE: set banlist(chanlist) "#channel1 #channel2 #channel3"
set banlist(chanlist) "#Age_of_Empires_2"

#Set this to the 'number' of bans you will allow in the channel banlist. If the number
#of bans exceeds this number then bans will be removed based on your settings below.
######################################################################################
#REMEMBER: This number should NOT be more than your IRC network's banlist capacity.
#To find this number, see 'MAXBANS' setting on connection to your irc server.
#(If you are not aware contact your local friendly irc operator and find out)
#Example: DALnet currently has 200.
set banlist(max) ""


#Set the METHOD in which you would like to remove the channel bans. The number
#of bans to be removed will be based on the value set above.
#USAGE: [1/2/3/4/5/6] (1=RANDOM, 2=RECENT, 3=LAST, 4=BY BOT, 5=OLDER THAN, 6=ALL)
#################################################################################
#Use '1' If you want to remove bans randomly.
#Use '2' If you want to remove recently placed bans.
#Use '3' If you want to remove last placed bans.
#Use '4' If you want to remove bans only placed by the bot.
#Use '5' If you want to remove bans older than a specific number of hour(s).
#Use '6' If you want to remove all bans from the channel.
set banlist(type) "5"


#Set the 'number' of bans to remove when the bans in the channel banlist reaches more
#than 'banlist(max)', which you set above in the first setting of the script.
#USAGE: 'Any number' ==> removes a number of bans
#USAGE: 'all' ==> removes all channel bans (only valid for banlist method 4 and 5)
#####################################################################################
###If this setting is set to 'ALL'###
#For banlist method 4: All bans placed by the bot will be removed
#For banlist method 5: All bans older than specific hour(s) defined will be removed
set banlist(remove) "all"


###SET THIS ONLY IF YOU HAVE SET THE PREVIOUS SETTING TO '5'###
#Set the time here in 'hour(s)' after which you would like to remove the bans.
#Bans placed before this specified number of hour(s) will be removed.
set banlist(hours) "2"


#----------------------------------------#
# SET BANLIST NOTIFICATION OPTIONS #
#----------------------------------------#

#Set this if you want to send an OPNOTICE to the channel ops when removing the bans.
#USAGE [0/1] (0=OFF, 1=ON)
set banlist(onotice) "0"


#---------------------------------#
# SET BANLIST ON JOIN CHECK #
#---------------------------------#

#Set the time here in 'minutes' to check the banlist for removing bans. This
#will be initiated after the bot joins a channel, typically after a restart.
set banlist(delay) "1"

##############################################################################
### Don't edit anything else from this point onwards even if you know tcl! ###
##############################################################################

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

set banlist(auth) "\x61\x77\x79\x65\x61\x68"
set banlist(ver) "v8.96.b"

proc banlist:on:join {nick uhost hand chan} {
global banlist
if {![isbotnick $nick]} { return 0 }
if {($banlist(chantype) == "1") && ([lsearch -exact [split [string tolower $banlist(chanlist)]] [string tolower $chan]] == -1)} { return 0 }
timer $banlist(delay) [list banlist:on:mode $nick $uhost $hand $chan +b join]
}

proc banlist:on:mode {nick uhost hand chan mode target} {
global banlist
if {[string is integer $banlist(remove)] && ($banlist(remove) > $banlist(max))} { return 0 }
if {($banlist(chantype) == "1") && ([lsearch -exact [split [string tolower $banlist(chanlist)]] [string tolower $chan]] == -1)} { return 0 }
if {[string equal "+b" $mode] && [botisop $chan]} {
if {[llength [chanbans $chan]] >= $banlist(max)} {
set banlist(notc1) "Channel banlist currently contains $banlist(max) entries"
switch -exact $banlist(type) {
1 { set chanbanlist [chanbans $chan] }
2 { set chanbanlist [lsort -index 2 -integer -increasing [chanbans $chan]] }
3 { set chanbanlist [lsort -index 2 -integer -decreasing [chanbans $chan]] }
4 { set chanbanlist
  • foreach ban [chanbans $chan] {
    if {[string equal -nocase [lindex [split [lindex $ban 1] !] 0] $botnick]} {
    lappend chanbanlist $ban
    }
    }
    if {[string is integer $banlist(remove)]} {
    set chanbanlist [lrange $chanbanlist 0 [expr $banlist(remove) - 1]]
    }
    }
    5 { set threshold [expr [clock seconds] - $banlist(hours) * 3600]
    set chanbanlist
    • foreach ban [chanbans $chan] {
      if {$threshold > [lindex $ban 2]} {
      lappend chanbanlist $ban
      }
      }
      if {[string is integer $banlist(remove)]} {
      set chanbanlist [lrange $chanbanlist 0 [expr $banlist(remove) - 1]]
      }
      }
      6 { if {$banlist(onotice) == "1"} {
      putserv "NOTICE @$chan :$banlist(notc1). Clearing the entire channel banlist."
      }
      resetbans $chan
      return 0
      }
      default { return 0 }
      }
      if {$banlist(type) == "5"} {
      if {[llength $chanbanlist] > 0} {
      if {$banlist(onotice) == "1"} {
      if {[string is integer $banlist(remove)]} {
      putserv "NOTICE @$chan :$banlist(notc1). Removing $banlist(remove) bans older than $banlist(hours) hours."
      } elseif {[string equal -nocase "all" $banlist(remove)]} {
      putserv "NOTICE @$chan :$banlist(notc1). Removing all bans older than $banlist(hours) hours."
      }
      }
      if {[llength $chanbanlist] > 0} {
      foreach ban $chanbanlist { pushmode $chan -b [lindex $ban 0] }
      flushmode $chan; return 0
      }
      }
      } elseif {[string is integer $banlist(remove)] && [regexp {^[1-4]$} $banlist(type)]} {
      set chanbanlist [lrange $chanbanlist 0 [expr $banlist(remove) - 1]]
      if {$banlist(onotice) == "1"} {
      switch -exact $banlist(type) {
      1 { set banlist(notc2) "Removing $banlist(remove) bans randomly from the banlist." }
      2 { set banlist(notc2) "Removing the recent $banlist(remove) bans placed." }
      3 { set banlist(notc2) "Removing the last $banlist(remove) bans placed." }
      4 { set banlist(notc2) "Removing [string tolower $banlist(remove)] bans placed by the bot." }
      }
      putserv "NOTICE @$chan :$banlist(notc1). $banlist(notc2)"
      }
      if {[llength $chanbanlist] > 0} {
      foreach ban $chanbanlist { pushmode $chan -b [lindex $ban 0] }
      flushmode $chan; return 0
      }
      }
      }
      }
      }

      if {![string equal "\x61\x77\x79\x65\x61\x68" $banlist(auth)]} { set banlist(auth) \x61\x77\x79\x65\x61\x68 }
      putlog "Channel Banlist Cleaner $banlist(ver) by $banlist(auth) has been loaded successfully."
how I can modify the time of hours for minutes?
Thanks !!
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Re: change time minutes

Post by willyw »

demetrius_reis wrote:The time of ban is in hours, would like to modify for minutes.
....
how I can modify the time of hours for minutes?
Thanks !!
See this line:

Code: Select all

5 { set threshold [expr [clock seconds] - $banlist(hours) * 3600]
specifically:

Code: Select all

 $banlist(hours) * 3600
That is taking whatever you have assigned earlier, in the config section:

Code: Select all

set banlist(hours) "2" 
and coverting that value to seconds.
In this case, 2 hours multiplied by 3600 would equal 7200 seconds.
It needs the value, in seconds.

If, in the config section, you wish to give it minutes intead of hours,
then change to:

Code: Select all

5 { set threshold [expr [clock seconds] - ($banlist(hours) * 60)]
save and rehash. Then test.

In this example, it would then be working with 2 times 60 = 120 seconds.

Again... do test it carefully.

I hope this helps.



Note:
I question this line:

Code: Select all

if {$threshold > [lindex $ban 2]} { 
Maybe I'm just fuzzing out today, but to me it looks like that line will *always* evaluate to true.
If it does, then the script will not perform as you expect.

Perhaps someone else will come along and comment on this.
d
demetrius_reis
Halfop
Posts: 42
Joined: Tue Aug 10, 2010 9:54 am

Post by demetrius_reis »

Certain… I go to try… agradecio!

thanks !!
Post Reply