Update NickTracker/nicktracker.tcl

This commit is contained in:
2026-06-18 18:41:56 +02:00
parent 825c53b14a
commit 4a99ea3dcf
+66 -25
View File
@@ -1,5 +1,5 @@
#####
# Nickname/Uhost tracker script
# Nickname/Uhost v2 tracker script
# Egghelp version, donations to slennox are welcomed. :P
# Original version from speechles (?)
# Enhanced by PeGaSuS
@@ -22,23 +22,39 @@ if {[catch {package require Tcl 8.5} err]} {
set dupes 0
##########
# How many nicks to show per line?
# To avoid messages being cut off, this is hard limited to 10
# Maximum number of nicks shown per output line
# Recommended value is 10
##########
set list_length "10"
set nicks_per_line 10
##########
# Send nicktracking information to the specified channel(s)/nickname(s). You can set several destinations
# Maximum number of lines the bot will output per join/nick-change event
##########
# 0 = unlimited
##########
set max_output_lines 5
##########
# Set here the words in your language
##########
### Also used
set nUsed "ha usato"
### Other
set nOther "altri"
##########
# Send nicktracking information to the specified channel(s). You can set several destinations
# Example
# set channelmap {
# "#channel1" "#channel2"
# "#otherchannel" "#channel3 #channel4 somenick"
# "#otherchannel" "#channel3 #channel4"
# }
#
##########
set channelmap {
"#thelounge" "#thelounge-staff"
"#thelounge" "#thelounge-ops"
"#amicizia" "#camelot"
}
##########
@@ -87,7 +103,7 @@ proc nick_nickchange {nick uhost hand chan newnick} {
# check for joins
##########
proc join_onjoin {nick uhost hand chan} {
global botnick dupes channelmap list_length alertnicks
global botnick dupes channelmap list_length alertnicks nicks_per_line max_output_lines nUsed nOther
if {![channel get $chan "nicktrack"]} {
return 0
}
@@ -123,37 +139,62 @@ proc join_onjoin {nick uhost hand chan} {
# is the nick already known for that host?
set nlist [split $nicks ","]
if {[set pos [lsearch -nocase $nlist $nick]] != -1} { set nlist [lreplace $nlist $pos $pos] }
# calculate the list length, as we're going to use it later
if {$list_length > 10} { set list_length 10 }
set offset [expr {$list_length - 1}]
# Build the (possibly truncated) display list, then chunk it into
# groups of $nicks_per_line, capped at $max_output_lines lines total.
set displaylist $nlist
set remaining 0
if {$max_output_lines > 0} {
set max_shown [expr {$nicks_per_line * $max_output_lines}]
if {[llength $displaylist] > $max_shown} {
set remaining [expr {[llength $displaylist] - $max_shown}]
set displaylist [lrange $displaylist 0 [expr {$max_shown - 1}]]
}
}
set chunks [list]
for {set i 0} {$i < [llength $displaylist]} {incr i $nicks_per_line} {
lappend chunks [join [lrange $displaylist $i [expr {$i + $nicks_per_line - 1}]] { }]
}
if {$remaining > 0 && [llength $chunks]} {
set last [expr {[llength $chunks] - 1}]
lset chunks $last "[lindex $chunks $last] (+$remaining ${nOther})"
}
# Send messages to the defined channels
if {$ch in [dict keys $channelmap]} {
set bkc [dict get $channelmap $ch]
foreach bkct [split $bkc] {
for {set i 0} {$i < [llength $nlist]} {incr i $list_length} {
if {[regexp {\+[^ ]*c} [getchanmode $bkct]]} {
putquick "PRIVMSG $bkct :\[$chan\] ${nick} also used: [join [lrange $nlist $i $i+$offset] { }]"
set nocolor 0
catch {set nocolor [regexp {\+[^ ]*c} [getchanmode $bkct]]}
foreach c $chunks {
if {$nocolor} {
putquick "PRIVMSG $bkct :\[$chan\] ${nick} ${nUsed}: $c"
} else {
putquick "PRIVMSG $bkct :\[\00302$chan\003\] \00304${nick}\003 also used: \00304[join [lrange $nlist $i $i+$offset] { }]\003"
putquick "PRIVMSG $bkct :\[\00302$chan\003\] \00304${nick}\003 ${nUsed}: \00304$c\003"
}
}
}
} else {
# Send a notice to channel operators if bot is chanop
if {[isop $botnick $ch]} {
for {set i 0} {$i < [llength $nlist]} {incr i $list_length} {
if {[regexp {\+[^ ]*c} [getchanmode $ch]]} {
putquick "NOTICE @$ch :${nick} also used: [join [lrange $nlist $i $i+$offset] { }]"
} else {
putquick "NOTICE @$ch :\00304${nick}\003 ha usato: \00304[join [lrange $nlist $i $i+$offset] { }]\003"
foreach c $chunks {
set nocolor [regexp {\+[^ ]*c} [getchanmode $bkct]]
foreach c $chunks {
if {$nocolor} {
putquick "PRIVMSG $bkct :\[$chan\] ${nick} ${nUsed}: $c"
} else {
putquick "PRIVMSG $bkct :\[\00302$chan\003\] \00304${nick}\003 ${nUsed}: \00304$c\003"
}
}
}
} else {
# Send a message to the nicks on the list if none of the conditions above is met
foreach n [split $alertnicks] {
for {set i 0} {$i < [llength $nlist]} {incr i $list_length} {
putquick "PRIVMSG $n :\[\00302$chan\003\] \00304${nick}\003 ha usato: \00304[join [lrange $nlist $i $i+$offset] { }]\003"
if {[llength $alertnicks]} {
foreach n [split $alertnicks] {
foreach c $chunks {
putquick "PRIVMSG $n :\[\00302$chan\003\] \00304${nick}\003 ${nused} \00304$c\003"
}
}
}
}
@@ -182,4 +223,4 @@ proc join_onjoin {nick uhost hand chan} {
return 0
}
putlog "Nickname/Uhost tracker enabled."
putlog "Nickname/Uhost v2 tracker enabled."