This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

/luser writing in HTML file

Old posts that have not been replied to for several years.
Locked
m
muhkuh2005

/luser writing in HTML file

Post by muhkuh2005 »

Hi,

can someone pls write me an TCL Script which any 5 minutes write the /lusers's into a html file? (lusers is a Unreal IRCD command which give information about the current users online
example:
There are 80224 users and 78318 invisible on 47 servers
97 operator(s) online
37 unknown connection(s)
148766 channels formed
I have 5742 clients and 1 servers
)
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Please search the forums, this has allready been answered in the past.

LUSERS is a IRC command, that has been around since the start of the IRC project. This doesn't just apply to UnrealIRCD.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Original code by egghead can be found here.

Code: Select all

#---------------------------------------------------------------------
# lusers.tcl
# Tcl script for IRC bot eggdrop
#
# Usage: !lusers
# The bot will send a LUSERS request to the server and report the
# result in the channel.
#
# v0: 24-Oct-2002
# v1: 26-Oct-2002
# v2: 28-Oct-2002
#---------------------------------------------------------------------

package require eggdrop 1.6
package require Tcl 8.0

set htmlfile "lusers.html"

bind pub o !lusers lusers:pub
bind time - * lusers:time
bind RAW - 251 lusers:raw
bind RAW - 252 lusers:raw
bind RAW - 253 lusers:raw
bind RAW - 254 lusers:raw
bind RAW - 255 lusers:raw

#---------------------------------------------------------------------
# Publicly triggered "LUSERS" request.
#---------------------------------------------------------------------

proc lusers:pub { nick uhost hand chan text } {
   global lusersinfo
   global lusersrawinfo
   # use lowercase channel name only in the remainder.
   set chantlw [string tolower $chan]
   # if lusersinfo exists a lusers request is already pending.
   if {[info exists lusersinfo]} {
      # check if a request is already pending for that channel.
      if {[lsearch -exact $lusersinfo $chantlw] == -1 } {
         # add the channel to channels where bot will report.
         lappend lusersinfo $chantlw
      }
      return 1
   }
   # Send with some delay a new lusers request.
   utimer 5 {puthelp LUSERS}
   lappend lusersinfo [unixtime] $chantlw
   # putlog the request.
   return 1
}

#---------------------------------------------------------------------
# On a regular basis check the pending request.
#---------------------------------------------------------------------

proc lusers:time { min hour day month year } {
   global lusersinfo
   global lusersrawinfo
   if {![info exists lusersinfo]} { return }
   set timestamp [lindex $lusersinfo 0]
   if {[expr [unixtime] - $timestamp] < 120 } { return }
   # request expired.
   lusers:report
}

#---------------------------------------------------------------------
# RAW results.
#---------------------------------------------------------------------

proc lusers:raw { server keyword text } {
   global lusersinfo
   global lusersrawinfo
   # currently a lusers request pending?
   if {![info exists lusersinfo]} { return 0 }
   # numerics must be in 251-255 range
   if {![string match {25[1-5]} $keyword]} { return 0 }
   # remove the botnick from the result.
   if {[scan $text "%s %\[^\n\]" botnick text ] != 2 } { return 0 }
   # awkward...
   regsub -all : $text "" text
   # lappend the remaining text to the list.
   lappend lusersrawinfo $text
   # retrieve total amount of users from raw 251
   if { $keyword == 251 } {
      set scanrule {There are %d users and %d invisible}
      if {[scan $text $scanrule vusers iusers] == 2 } {
        set totalusers [expr $vusers + $iusers]
        lappend lusersrawinfo "(total $totalusers users)"
      }
   }
   # numeric 255 (last) reached?
   if { $keyword != 255 } { return 0 }
   lusers:report
}

#---------------------------------------------------------------------
# On an expired request or a 255 RAW numeric, report results
# and unset the lists lusersinfo and lusersrawinfo.
#---------------------------------------------------------------------

proc lusers:report { } {
   global lusersinfo
   global lusersrawinfo
   global server
   global htmlfile
   # review the raw info.
   if {![info exists lusersrawinfo]} {
      set lusersrawinfo [list]
   }
   set line [join $lusersrawinfo ". "]
   # if line is empty: something is wrong.
   if { $line == "" } { 
      set line "Sorry, could not obtain lusers info."
   }
   # retrieve the name of the server
   set scanrule {%[^:]:%s}
   if {[scan $server $scanrule servername serverport] < 1 } {
      set servername "current server"
   }
   set date [ctime [unixtime]]
   # set line "\002Lusers info on $servername ($date)\002: $line."
   # spit out the line on all requestchannels.
   # set channels [lrange $lusersinfo 1 end]
   # foreach chan $channels {
   #   if { ![botonchan $chan] } { continue }
   #   puthelp "PRIVMSG $chan :$line"
   # }

   # write in the html file
   set file [open $htmlfile w] 
   puts $file "$line" 
   catch {close $file} 

   unset lusersinfo
   unset lusersrawinfo
}

putlog "Lusers version 2 + html loaded." 
Once the game is over, the king and the pawn go back in the same box.
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

http://www.dawgtcl.com:81/

they got this TCL with HTML support
Locked