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.

newban/newchanban expire

Old posts that have not been replied to for several years.
Locked
User avatar
sKy
Op
Posts: 194
Joined: Thu Apr 14, 2005 5:58 pm
Location: Germany

newban/newchanban expire

Post by sKy »

I need 2 little procs. If a newchanban is allready set and bantime is 0 (permanent) and another script try to set a newchanban with a shorter expiretime this should be blocked.

Code: Select all

proc newchan:ban { channel hostname creator comment lifetime } {
	if { ! [isban $hostname $channel] } {
		newchanban $channel $hostname $creator $comment $lifetime
	}
	if { [isban $hostname $channel] } {
		set h [string tolower $hostname]
		foreach ban [banlist $channel] {
			set host [lindex $ban 0]
			set hostt [string tolower $host]
			set expire [lindex $ban 2]
			if { $h == $hostt } {
				if { $expire == 0 } {
					return
				}
			}
		}
	}
	newchanban $channel $hostname $creator $comment $lifetime
}

proc new:ban { hostname creator comment lifetime } {
	if { ! [isban $hostname] } {
		newban $hostname $creator $comment $lifetime
	}
	set h [string tolower $hostname]
	if { [isban $hostname] } {
		foreach ban [banlist] {
			set host [lindex $ban 0]
			set hostt [string tolower $host]
			set expire [lindex $ban 2]
			if { $h == $hostt } {
				if { $expire == 0 } {
					return
				}
			}
		}
	}
	newban $hostname $creator $comment $lifetime
}
Can you find a error?
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Can't you simply add a check before adding the ban, like

Code: Select all

if {![isban $ban $channel]} {
 # newchanban
}
this way the bot will not change the ban if it's already set.
User avatar
sKy
Op
Posts: 194
Joined: Thu Apr 14, 2005 5:58 pm
Location: Germany

Post by sKy »

right,

but if the bantime will be longer (permanent) i wish to have the new ban and not the old (shorter).
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Something like this should do it:

Code: Select all

proc newchan:ban {chan ban who arg time} {
 if {![isban $ban $chan]} {
  newchanban $chan $ban $who $arg $time
 } else {
  foreach setban [banlist $chan] {
   if {[string equal -nocase [lindex $setban 0] $ban]} {
    if {$time > [lindex $setban 2]} {
     newchanban $chan $ban $who $arg $time
     break
    }
   }
  }
 }
}
same goes with new:ban.
User avatar
sKy
Op
Posts: 194
Joined: Thu Apr 14, 2005 5:58 pm
Location: Germany

Post by sKy »

Code: Select all

proc newchan:ban { channel hostname creator comment lifetime } {
	if { ! [isban $hostname $channel] } { 
		newchanban $channel $hostname $creator $comment $lifetime
		return
	} else { 
		foreach ban [banlist $channel] {
			if { [string match -nocase "*[lindex $ban 0]*" $hostname] } {
				set expire [lindex $ban 2]
				if { $expire == 0 } { break ; return }
				set remain [expr $expire - [unixtime]]
				set remain [expr $remain / 60]
				if { $remain > $lifetime } { break ; return }
				newchanban $channel $hostname $creator $comment $lifetime
			}
		}
	}
}

proc new:ban { hostname creator comment lifetime } {
	if { ! [isban $hostname] } { 
		newban $hostname $creator $comment $lifetime
		return
	} else { 
		foreach ban [banlist] {
			if { [string match -nocase "*[lindex $ban 0]*" $hostname] } {
				set expire [lindex $ban 2]
				if { $expire == 0 } { break ; return }
				set remain [expr $expire - [unixtime]]
				set remain [expr $remain / 60]
				if { $remain > $lifetime } { break ; return }
				newban $hostname $creator $comment $lifetime
			}
		}
	}
}
works now, thanks anyway.
Locked