View Single Post
  #37  
Old 04-02-2003, 10:46 PM
noppid noppid is offline
 
Join Date: Mar 2003
Location: Florida
Posts: 1,875
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 "\\&amp;" i2h_text
  regsub 
-all \$i2h_text "\\&quot;" i2h_text
  regsub -all < 
$i2h_text "\\&lt;" i2h_text
  regsub -all > 
$i2h_text "\\&gt;" i2h_text
  regsub -all "  " 
$i2h_text " \\&nbsp;" 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
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01408 seconds
  • Memory Usage 1,824KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete