While reading the thread a few things came up that we would like to share. Here are our TCL modifications to Joey's great irc hack.
1) Putting the "No matter what" back in to the title, a Timer.
This method allows the script to wait for the user to exit before compiling the stats. No more two users have to exit to decrement the count. Plus since the userslist.txt is updated within 5 seconds of any bound event, there is no need for a constantly running timer. The file updates only when necessary.
2) Remove the bot from the list and the count.
Done! If that's what ya want, it's in here.
Thanks again to Joey for Excellent code to work with!
Although this is TCL, I'm gonna tag it php.
PHP Code:
# joey's irc hack userschatting.tcl
#
# modified to remove the bot's name and count.
# modified to Run "No matter what" and be up to
# date in 5 seconds of an event that is bound.
# Set the bots name here. (noppid)
set i2h_botname "PitBoss"
set i2h_htmlfile "/home/username/eggdrop/scripts/userlist.txt"
set i2h_chan "#vbcustom"
set i2h_text "#000000"
# all modified to i2h:make2, our new proc (noppid)
bind join - "$i2h_chan %" i2h:make2
bind part - "$i2h_chan %" i2h:make2
bind sign - "$i2h_chan %" i2h:make2
bind topc - "$i2h_chan %" i2h:make2
bind kick - "$i2h_chan %" i2h:make2
bind nick - "$i2h_chan %" i2h:make2
bind rejn - "$i2h_chan %" i2h:make2
# set timer to wait 5 seconds before update on above events
# This allows the exiting updates to be correct and not
# have to have a timer constantly running (noppid)
proc i2h:make2 {args} {
# set timer to wait 5 seconds before running the stats proc (noppid)
utimer 5 i2h:make
return 1
}
proc i2h:make {args} {
global i2h_htmlfile i2h_chan i2h_text server i2h_botname
set i2h_file [open $i2h_htmlfile w]
puts $i2h_file "<b>Topic</b>: $i2h_chan \[[lindex [getchanmode $i2h_chan] 0]\]: '[i2h:convert [topic $i2h_chan]]'<br>"
puts $i2h_file "<b>Server</b>: [string range $server 0 [expr [string last ":" $server] - 1]]<br>\n"
set users ""
set online [chanlist $i2h_chan]
set count [llength $online]
set users [lindex $online 0]
for {set i 0} {$i < $count} {incr i 1} {
set user [lindex $online $i]
set users "$users%20$user"
}
# decrement user count, don't count the bot (noppid)
set count [expr $count - 1]
# Sometimes the names appear with %20, remove the bot name (noppid)
regsub -all "$i2h_botname%20" $users "" users
# Sometimes the botname is in the array without a %20, remove those if present (noppid)
regsub -all $i2h_botname $users "" users
# Simplified the user count to a singel var (noppid)
puts $i2h_file "<b>Users</b> \[$count\]: $users<br>\n"
close $i2h_file
return 1
}
proc i2h:convert {i2h_text} {
#Strip control codes.. sorta
regsub -all $i2h_text "" i2h_text
regsub -all $i2h_text "" i2h_text
regsub -all $i2h_text "" i2h_text
regsub -all $i2h_text "" i2h_text
regsub -all $i2h_text "" i2h_text
#Convert special chars
regsub -all & $i2h_text "\\&" i2h_text
regsub -all \" $i2h_text "\\"" i2h_text
regsub -all < $i2h_text "\\<" i2h_text
regsub -all > $i2h_text "\\>" i2h_text
regsub -all " " $i2h_text " \\ " i2h_text
return $i2h_text
}
set i2h_file [open $i2h_htmlfile w]
puts $i2h_file "<b>Topic</b>: $i2h_chan \[\]: ''<br>"
puts $i2h_file "<b>Server</b>: unknown<br>"
puts $i2h_file "<b>Users</b>: unknown<br>\n"
close $i2h_file
utimer 3 i2h:make
putlog "SaS IRC nick list loaded."
Follow the homepage link in my profile to see it in action.
Regards