egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Bind RAW Lusers

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
r00terr0r
Voice


Joined: 22 Aug 2012
Posts: 3

PostPosted: Thu Aug 23, 2012 6:01 am    Post subject: Bind RAW Lusers Reply with quote

Code:

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 Very Happy Can anyone help me? Very Happy
If anyone have some idea why dont work Smile
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Thu Aug 23, 2012 7:24 am    Post subject: Reply with quote

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:
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, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
r00terr0r
Voice


Joined: 22 Aug 2012
Posts: 3

PostPosted: Thu Aug 23, 2012 7:35 am    Post subject: Reply with quote

TNX BROOO!!! Smile
I need it for stats for my web page.
You are clever guy! Wink
Tnx again Wink

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

Here is final code:
Code:

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"
}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber