SpiKe^^ wrote:I believe this is much closer to what you were looking for.
Will monitor all channels the bot is on, for joins and nick changes.
Will then report all other nicks that uhost has also been know as,
to all channels and/or nicks listed in the 'report_to' setting.
Script is completely untested, so let me know how it works out.
Code: Select all
# Nickname/Uhost tracker script
# Egghelp version, donations to slennox are welcomed. :P
# Revised version by SpiKe^^ (5 Mar 2013) #
# set your filename
set filename "nicklist.txt"
# set the channel(s) and/or nick(s) to report the nick info to
# space separated list
# example: set report_to {#chanadmin}
# example: set report_to {#admin #chan2 bart ted}
set report_to {#somechannel}
# set the number of seconds not to report on the same nick
set nk_recent "15"
# set the maximum number of lines to keep in the file
# the oldest last seen uhosts/nicks will be deleted from the file
set file_max "100"
# set the maximum number of chars to use for a line of text
set char_max "350"
# set the text to use for the beginning of each line sent
set txt_pre "%nick% is also known as :"
# set the text to use for the separator between the nicks
set txt_sep ", "
################### END OF SETTINGS ###################
bind nick - * nick_nickchange
bind join - * join_onjoin
# make sure the file exists before we go to read it
# this initializes the file if it doesn't already exist
# and makes it blank to start with.
if {![file exists $filename]} {
set file [open $filename "w"]
close $file
}
set report_to [split $report_to]
# check for nick changes
proc nick_nickchange {nick uhost hand chan newnick} {
join_onjoin $newnick $uhost $hand $chan
return 0
}
# check for joins
proc join_onjoin {nick uhost hand chan} {
global filename report_to nk_recent file_max char_max txt_pre txt_sep nktrack
# see if this nick has been reported in last $nk_recent seconds
set nklow [string tolower $nick]
if {[llength [set recent [array names nktrack]]]>"0"} {
set old [expr {[unixtime]-$nk_recent}]
set fnd 0
foreach ename $recent {
if {$nktrack($ename)<$old} { unset nktrack($ename)
} elseif {$ename eq $nklow} { set fnd 1 }
}
if {$fnd=="1"} { return 0 }
}
set nktrack($nklow) [unixtime]
# keep uhost lowercase for simplicity.
set uhost [string tolower $uhost]
# read the file
set file [open $filename "r"]
set text [split [read $file] \n]
close $file
# locate a duplicate host
set found [lsearch -glob $text "*<$uhost"]
if {$found < 0} {
# host isn't found in the file
set nlist [list $nick]
} else {
# the host exists, so set our list of nicks for that host
set nicks [lindex [split [lindex $text $found] "<"] 0]
set nlslow [split [string tolower $nicks] ","]
set nlist [split $nicks ","]
# remove the found line from the text
set text [lreplace $text $found $found]
# is the nick already known for that host?
if {[set pos [lsearch $nlslow $nklow]]>"-1"} { set nlist [lreplace $nlist $pos $pos] }
# if nick is also known as someone else, say so
if {[llength $nlist]>"0"} {
set pre [string map [list %nick% $nick] $txt_pre]
set tmp $pre[join $nlist $txt_sep]
if {[string length $tmp]<=$char_max} {
foreach tgt $report_to { putserv "privmsg $tgt :$tmp" }
} else { set tmp $pre[lindex $nlist 0]
foreach nk [lrange $nlist 1 end] {
set nx $tmp$txt_sep$nk
if {[string length $nx]>$char_max} {
foreach tgt $report_to { putserv "privmsg $tgt :$tmp" }
set tmp $pre$nk
} else { set tmp $nx }
}
foreach tgt $report_to { putserv "privmsg $tgt :$tmp" }
}
}
lappend nlist $nick
}
# write the new file, this uhost and nicks first
set file [open $filename "w"]
puts $file [join $nlist ","]<$uhost ; set cnt 1
foreach line $text {
if {[string length $line]} { puts $file "$line" ; incr cnt }
if {$cnt==$file_max} { break }
}
close $file
return 0
}
putlog "Nickname/Uhost tracker enabled."
Hello. Thanks a lot SpiKe^^ for this patch. it works nice and solves the ex problems indeed. i was testing it enough of time and saw some needs or minor issues which i will state here now.
-script should have an exempt flags setting... so it doesnt try to track the bots or known users. it would be nice if i will not need to add this user on bot's .user file but script may creates it's own exempt file for this purpose maybe. or the better option is to point the user on nicklist.text file on source without create another file. for my opinion, if i ran "!exempt ip" command in the channel, the script will add # sign at the beginning of line in nicklist.text for this nick's ip. so, it will not match or announce it on nick changes or joins. if you have better idea, it's ok too. (i am using only ip numbers to catch users. no idents included on my edited script, so, just cloaked ip's as *!*@ip.here on each nick is assigned on nicklist.text at my own patched script) if i will use !exempt nick then it may cause problem coz some users not registered their nicks and it will exempt to other users who used same nick too. i meant, so many different users can use the same nick. it may cause problem. that's why ip exempt better way. it shouldn't track exempted ip.
-!forget ip same as mentioned !exempt ip on above.
-if nick begins with [ sign then output being wrong. maybe it's having problem with ^ or ' and other signs, i'm not sure but sometimes outputs seems as weird and not alphanumeric. showing just random unrecognized signs. sometimes my nicklist.txt file being delete and lost. it begins from zero. i don't know why happens so, but i'm suspecting from those kinds of signs maybe creates problem while reading or writing?
-it would be nice if we can add some nicks to be exempted as Guest_997 Guest_998 Guest_999 etc. coz some users using only as Guest nicknames and they're having 200 old nicknames to be seen.
-use lreverse to show it the other direction. it would be better as like "NewNick < BeforeTheNewNick | blah2 | blah1" because now it's showing latest nick as in the end of list. oldest is on the beginning. On view it would be better if nicks will be shown from left to right. on left side, the latest nick will seem better.
-the commands would be able to run by bot ops. not by everyone.
- if {[isbotnick $nick]} { return 0 } so that bot should ignore his own joins. yeah and other bots joins etc? now bot announce repeats his own nick X times in a row on restarts or his own joins. bot should not announce hiw own and maybe owner|botops nicknames.
- i don't know why but nicklist.txt file starts from zero by itself on sometimes and i can't know when it happens. deletes the whole file and begins from zero. i need a backup system and automatic deletion to this backup files. ( i already wrote a script to make backups but need an automation to delete them. also, i can't know when the file returns to zero, that's the problem )
- there is biggest problem is that;
IP: 0E57D4.321A87.81A6DF.C1410C Realname: (BB1831196912) and IP: 0E57D4.321A87.81A6DF.A9F7A2 Realname: (BB1831196912)
those are two different ips and different users. but script shows them as same user. it's incorrect. if it's because of Realname part? can fix this please?
thanks a lot for all and script.