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.

Traffic Script...

Old posts that have not been replied to for several years.
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Traffic Script...

Post by GodOfSuicide »

Hi..

The .traffic command in DCC gives me the following output :
Traffic since last restart
==========================
IRC:
out: 118.46 KBytes (24.71 KBytes today)
in: 3.13 MBytes (878.98 KBytes today)
Partyline:
out: 129.76 KBytes (1.32 KBytes today)
in: 1.54 KBytes (31 Bytes today)
Misc:
out: 814.39 KBytes (224.16 KBytes today)
in: 18.58 MBytes (5.22 MBytes today)
---
Total:
out: 1.04 MBytes (250.38 KBytes today)
in: 21.71 MBytes (6.08 MBytes today)
I wanted to publish the total traffic Stats on my website, but .tcl traffic returned
Tcl: {irc 900072 3283327 25303 121302} {botnet 0 0 0 0} {partyline 22 1571 1009 132530} {transfer 0 0 0 0} {misc 5474545 19479271 229543 833934} {total 6374639 22764169 255855 1087766}
It would be fine if somebody could write a little proc to split this output and maybe writeing the stats into a global variable, so it can be accesed from other tcl's too.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Tcl commands and partyline commands are totaly different things.

In the partyline, data is formatted for human reading.

In Tcl, only the needed data is issued. It is up to the scripter to use this data, and format it in his own way.

Placing the data in global variables is both wastgul, and leaves your with un-needed loads, or extra commands to run.

Rather than place "IRC in total" into a global variable, you access the data yourself, direct from the Tcl command that you have found.

Somthing like this will allow you to grab the information a little simpler

Code: Select all

proc gettraffic {type direction time} {
  set d 0
  set t 0
  switch -- [string tolower $direction] {
    "in" { set d 1 }
    "out" { set d 3 }
    default { error "Invalid direction used" }
  }
  switch -- [string tolower $time] {
    "today" { set t 0 }
    "total" { set t 1 }
    default { error "Invalid value type given" }
  }
  set traf [traffic]
  if {[set idx [lsearch $traf $type]] < 0} {
    error "Invalid traffic type given"
  }
  return [lindex [lindex $traf $idx] [expr $d + $t]]
}
Use it like

Code: Select all

set IRCfromSERVERtoday [gettraffic irc in today]
set BOTNETsentTOTAL [gettraffic botnet out total]
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

when i use this i allways get

Code: Select all

Tcl error [traffic_pub]: Invalid traffic type given
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Sorry - my fault. I do remember thinking about it, but got sidetracked when I spotted a correction.

CHange

Code: Select all

if {[set idx [lsearch $traf $type]] < 0} {
to

Code: Select all

if {[set idx [lsearch $traf "$type *"]] < 0} {
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

still doesnt work for me....
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Please show the exact command you are using, as it works for me.
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

Code: Select all

.tcl putlog "[gettraffic botnet out total]"
gave me an error
also did

Code: Select all

proc traffic_pub { nick uhost hand chan text } {
	set IRCfromSERVERtoday [gettraffic irc in today] 
	putserv "notice $nick :$IRCfromSERVERtoday"

}
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

GodOfSuicide wrote:

Code: Select all

.tcl putlog "[gettraffic botnet out total]"
gave me an error
What error did you get?
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

I'm running a eggdrop 1.6.13 and works smoothly. Also your pub proc works to.
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 »

egghead wrote:
GodOfSuicide wrote:

Code: Select all

.tcl putlog "[gettraffic botnet out total]"
gave me an error
What error did you get?
invalid traffic type
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

Like caesar I've used the following code:

Code: Select all

proc gettraffic {type direction time} { 
   set d 0 
   set t 0 
   switch -- [string tolower $direction] { 
      "in" { set d 1 } 
      "out" { set d 3 } 
      default { error "Invalid direction used" } 
   } 
   switch -- [string tolower $time] { 
      "today" { set t 0 } 
      "total" { set t 1 } 
      default { error "Invalid value type given" } 
   } 
   set traf [traffic] 
   putlog "TRAFFIC: $traf"
   if {[set idx [lsearch $traf "$type *"]] < 0} { 
      error "Invalid traffic type given" 
   } 
   return [lindex [lindex $traf $idx] [expr $d + $t]] 
} 
restart/rehash your bot and then
*** egghead joined the party line.
.tcl putlog "[gettraffic botnet out total]"
[05:27] 0
This is a bot not linked to a botnet.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

I just loaded the tcl and .rehash'ed and got the same results as egghead did on the botnet thing, cos I don't have it linked to any bots.
Once the game is over, the king and the pawn go back in the same box.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

botnet is a vlid type, regardless of the fact you are using a botnet or not.

No matter if you are, or not using a botnet, the code is still there. All traffic counter, will ramin at 0 as posted.

If you have any specific code, that generates the error, you should post it.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

I get the normal result for irc in or out. I get 0 for botnet cos in fact it's 0, due the fact that is not linked to any bots.
Once the game is over, the king and the pawn go back in the same box.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

My question is aimed at GodOfSuicide, as it's only him getting the errors now.
Locked