i was wondering how to edit the $time part as that has always to be in minutes using it with newchanban from what i understood to convert it
from year / month / week / day / hour to minutes
proc delay2min {delay} {
regexp {((\d{1,})y)?((\d{1,})w)?((\d{1,})d)?((\d{1,})h)?} $delay - iy by iw bw id bd ih bh
set min 0
incr min [expr 365*24*60*$by]
incr min [expr 7*24*60*$bw]
incr min [expr 24*60*$bd]
incr min [expr 60*$bh]
return $min
}
The param must follow the order 1y2w3d4h (every values are optional), so you can use delay2min 1y17h or delay2min 52w1d but you CAN NOT do delay2min 1d2w
bind pub o|o !addbl permanent_ban
proc permanent_ban {nick host hand chan text} {
set text [regsub -all -- {\s{2,}} [string trim [stripcodes * $text]] { }]
set items [split $text]
if {[llength $items] < 3} {
putnow "notice $nick :Syntax !addbl <target> <banduration> <reason>" ; return 0
}
set reason [join [lassign $items target time]]
#if {$reason eq ""} { set reason "default reason" } ;# reason cant be empty:) #
if {[matchaddr $target $::botname]} { return 0 }
if {[matchstr permanent $time] || [matchstr perm $time] || [matchstr p $time]} { set min 0
} elseif {[string is digit -strict $time]} { set min $time
### Thanks CrazyCat ###
} else { set min 0
regexp {((\d{1,})y)?((\d{1,})w)?((\d{1,})d)?((\d{1,})h)?} $time - iy by iw bw id bd ih bh
catch { incr min [expr {365*24*60*$by}] }
catch { incr min [expr {7*24*60*$bw}] }
catch { incr min [expr {24*60*$bd}] }
catch { incr min [expr {60*$bh}] }
}
newchanban $chan $target $nick $reason $min sticky
if {$min == 0} { set dur "forever"
} else { set dur [duration [expr {60*$min}]] }
putnow "notice $nick :Added new sticky ban to the Eggdrop user file (duration: $dur)."
return 0
}
<banduration> can be done in several ways:
a) 1y26w |or| 1d12h |or| other variations of 1y2w3d4h (in that order)(every values are optional)
b) any integer number (of minutes). example: 150 (= 150 minutes or 2 and a half hours)
c) perm |or| p |or| permanent |or| 0 (= a forever permanent ban)
proc delay2min {delay} {
regexp {((\d{1,})y)?((\d{1,})w)?((\d{1,})d)?((\d{1,})h)?(\d{1,})?} $time - iy by iw bw id bd ih bh bm
set min 0
incr min [expr 365*24*60*$by]
incr min [expr 7*24*60*$bw]
incr min [expr 24*60*$bd]
incr min [expr 60*$bh]
incr min [expr 1*$bm]
return $min
}
tried your version Spike^^ but setting bans on nicks like [nick] doesnt seem to work proper it sets it as {[nick]}
tested your version as well CC same issue and gettin error:
08:51:55 <Hawk> [08:51:55] Tcl error [sticky_bansx]: invalid bareword "set"
08:51:55 <Hawk> in expression "
08:51:55 <Hawk> set min [delay2min $time]...";
08:51:55 <Hawk> should be "$set" or "{set}" or "set(...)" or ...
proc delay2min {delay} {
regexp {((\d{1,})y)?((\d{1,})w)?((\d{1,})d)?((\d{1,})h)?(\d{1,})?} $delay - iy by iw bw id bd ih bh bm
set min 0
incr min [expr {365*24*60*$by}]
incr min [expr {7*24*60*$bw}]
incr min [expr {24*60*$bd}]
incr min [expr {60*$bh}]
incr min [expr {1*$bm}]
return $min
}
Tcl error [sticky_bansx]: can't use empty string as operand of "*"