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.

Bind RAW Lusers

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
r
r00terr0r
Voice
Posts: 3
Joined: Wed Aug 22, 2012 5:04 pm

Bind RAW Lusers

Post by r00terr0r »

Code: Select all

bind time - "*" save:lusers
bind raw - "250" lusers0
bind raw - "251" lusers1
bind raw - "255" lusers5
bind raw - "265" lusers65
bind raw - "266" lusers66

set lusersfile "/var/www/portal/lusers.html"
set lusers0 ""; set lusers1 ""; set lusers5 ""; set lusers65 ""; set lusers66 ""; 

proc lusers0 {from cmd text} {
global lusers0
set lusers0 "$text"
}
proc lusers1 {from cmd text} {
global lusers1
set lusers1 "$text"
}
proc lusers5 {from cmd text} {
global lusers5
set lusers65 "$text"
}
proc lusers65 {from cmd text} {
global lusers65
set lusers65 "$text"
}
proc lusers66 {from cmd text} {
global lusers66
set lusers65 "$text"
}
proc save:lusers {min hour day mon year} {
putserv "LUSERS"
global lusersfile lusers0 lusers1 lusers5 lusers65 lusers66
  set lusers [open $lusersfile w]
  puts $lusers "$lusers0 <br> $lusers1 <br> $lusers5 <br> $lusers65 <br> $lusers66"
  close $lusers
}
I made some script to save IRC Lusers, but doesnot work :D Can anyone help me? :D
If anyone have some idea why dont work :)
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

The problem here, is that save:lusers complete before the raw255 (or other) bindings have a chance to trigger (due to the single-threaded nature of eggdrop/tcl).

What you need to do, is first send the "LUSERS" command, and then wait for the server responses (bind raw). Once the binding triggers, extract the data, and then open and save the file.

Code: Select all

bind time - "*" requestLusers
bind raw - "250" rawLusers250
bind raw - "251" rawLusers251
bind raw - "255" rawLusers255
bind raw - "265" rawLusers265
bind raw - "266" rawLusers266

set lusersfile "/var/www/portal/lusers.html"

proc requestLusers {min hour day month year} {
  puthelp "LUSERS"
}

proc rawLusers250 {from cmd text} {
  set ::lusers250 $text
}

proc rawLusers251 {from cmd text} {
  set ::lusers251 $text
}

proc rawLusers255 {from cmd text} {
  set ::lusers255 $text
}

proc rawLusers265 {from cmd text} {
  set ::lusers265 $text
}

proc rawLusers266 {from cmd text} {
  set fileId [open $::lusersfile w]
  if {[info exists ::lusers250]} {
    puts $fileId "$::lusers250 <br>"
    unset ::lusers250
  }
  if {[info exists ::lusers251]} {
    puts $fileId "$::lusers251 <br>"
    unset ::lusers251
  }
  if {[info exists ::lusers255]} {
    puts $fileId "$::lusers255 <br>"
    unset ::lusers255
  }
  if {[info exists ::lusers265]} {
    puts $fileId "$::lusers265 <br>"
    unset ::lusers265
  }
  puts $fileId $text
  close $fileId
}
This code will intercept all the listed raw messages, and store their values, up until when 266 is sent. As 266 is received, the previous messages are recalled, and everything is written to file.
Thus, this script expects that the server sends the 266 numeric after any of the other ones.
NML_375
r
r00terr0r
Voice
Posts: 3
Joined: Wed Aug 22, 2012 5:04 pm

Post by r00terr0r »

TNX BROOO!!! :)
I need it for stats for my web page.
You are clever guy! ;)
Tnx again ;)

And if i dont wrong, i think i need to global string at rawLusers266 proc? :)

Here is final code:

Code: Select all

bind time - "*" save:lusers
bind raw - "250" rawLusers250
bind raw - "251" rawLusers251
bind raw - "255" rawLusers255
bind raw - "265" rawLusers265
bind raw - "266" rawLusers266

set lusersfile "/var/www/portal/lusers.html"

proc rawLusers250 {from cmd text} {
regexp {H.*} $text ::lusers250
}

proc rawLusers251 {from cmd text} {
regexp {T.*} $text ::lusers251
}

proc rawLusers255 {from cmd text} {
regexp {I.*} $text ::lusers255
}

proc rawLusers265 {from cmd text} {
regexp {C.*} $text ::lusers265
}

proc rawLusers266 {from cmd text} {
global ::lusers250 ::lusers251 ::lusers255 ::lusers265 lusersfile
  set fileId [open $::lusersfile w]
  if {[info exists ::lusers250]} {
    puts $fileId "$::lusers250 <br>"
    unset ::lusers250
  }
  if {[info exists ::lusers251]} {
    puts $fileId "$::lusers251 <br>"
    unset ::lusers251
  }
  if {[info exists ::lusers255]} {
    puts $fileId "$::lusers255 <br>"
    unset ::lusers255
  }
  if {[info exists ::lusers265]} {
    puts $fileId "$::lusers265 <br>"
    unset ::lusers265
  }
  regexp {C.*} $text ::lusers266
  puts $fileId $::lusers266
  close $fileId
}
proc save:lusers {min hour day mon year} {
putserv "LUSERS"
}
Post Reply