[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Tcldrop/CVS] tcldrop/modules/server server.tcl
From: |
Philip Moore |
Subject: |
[Tcldrop/CVS] tcldrop/modules/server server.tcl |
Date: |
Fri, 21 Nov 2003 22:32:07 -0500 |
CVSROOT: /cvsroot/tcldrop
Module name: tcldrop
Branch:
Changes by: Philip Moore <address@hidden> 03/11/21 22:32:06
Modified files:
modules/server : server.tcl
Log message:
A few tweaks, and make it so it counts the bytes in/out traffic.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/tcldrop/tcldrop/modules/server/server.tcl.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
Patches:
Index: tcldrop/modules/server/server.tcl
diff -u tcldrop/modules/server/server.tcl:1.10
tcldrop/modules/server/server.tcl:1.11
--- tcldrop/modules/server/server.tcl:1.10 Thu Nov 20 20:37:27 2003
+++ tcldrop/modules/server/server.tcl Fri Nov 21 22:32:05 2003
@@ -1,6 +1,6 @@
# server.tcl --
#
-# $Id: server.tcl,v 1.10 2003/11/21 01:37:27 fireegl Exp $
+# $Id: server.tcl,v 1.11 2003/11/22 03:32:05 fireegl Exp $
#
# Copyright (C) 2003 FireEgl (Philip Moore) <address@hidden>
#
@@ -27,7 +27,7 @@
namespace eval ::tcldrop::server {
variable version {0.2}
- variable rcsid {$Id: server.tcl,v 1.10 2003/11/21 01:37:27 fireegl Exp
$}
+ variable rcsid {$Id: server.tcl,v 1.11 2003/11/22 03:32:05 fireegl Exp
$}
# Provide the server module:
package provide tcldrop::server $version
# Initialize variables:
@@ -79,6 +79,7 @@
# so that we can have basic support for multiple server
connections.
set ::server-idx $idx
callraw $from $key $arg
+ traffic irc in [string length $line]
} else {
Error {EOF} {Got EOF From Server}
}
@@ -94,8 +95,9 @@
set hostname ${my-hostname}
}
if {[valididx $idx]} {
- putidx $idx "NICK $nick"
- putidx $idx "USER $username $hostname $username :$realname"
+ set ::server-idx $idx
+ putquick "NICK $nick"
+ putquick "USER $username $hostname $username :$realname"
} else {
Error SOCKET {Unknown error}
}
@@ -105,10 +107,8 @@
proc ::tcldrop::server::quit {{reason {}}} {
callevent predisconnect-server
global server-online server real-server server-idx
- if {[valididx ${server-idx}]} {
- putidx ${server-idx} "QUIT :$reason"
- killidx ${server-idx}
- }
+ putnow "QUIT :$reason"
+ killidx ${server-idx}
set server-online 0
set server-idx 0
set server {}
@@ -268,7 +268,7 @@
# Takes lines into the outgoing server queue,
# sends them immediately if it's able to burst,
# and flushes lines out when it calls itself.
-# $queue should be a number, the lower the number the higher up the queue
$line will be.
+# $queue should be a number, the lower the number the higher priority the
$line will be.
# Please note that queue 0 is reserved. Use 1 or higher when specifying
queues.
# $line is the text you want to send to the server.
# $option can be either -normal or -next (Like in Eggdrop).
@@ -309,8 +309,7 @@
putloglev v * "\[$a->\] $line"
putnow $line
# The time (in milliseconds) before we try
again..
- set SentData(penalty) [GetPenalty $line]
- if {$SentData(penalty) > 0} {
+ if {[set SentData(penalty) [GetPenalty $line]]
> 0} {
# Try again after the penalty expires
(plus a tad longer):
after [expr {$SentData(penalty) + 99}]
[list ::tcldrop::server::Queue 0]
# Get out of here, there's nothing more
we should do since we have to wait...
@@ -333,6 +332,7 @@
proc ::tcldrop::server::putnow {text} {
if {[valididx ${::server-idx}]} {
putidx ${::server-idx} $text
+ traffic irc out [string length $text]
} else {
clearqueue {all}
}
@@ -343,9 +343,7 @@
# $option can be -normal or -next (Like in Eggdrop).
proc ::tcldrop::server::putqueue {queue text {option {-normal}}} {
variable QueueAliases
- if {[info exists QueueAliases($queue)]} {
- set priority $QueueAliases($queue)
- }
+ if {[info exists QueueAliases($queue)]} { set priority
$QueueAliases($queue) }
variable Queue
# Unlike Eggdrop, we deal with people sending multiple lines at once..
foreach line [split $text \n] {
@@ -360,31 +358,20 @@
}
}
-# putquick command:
-proc ::tcldrop::server::putquick {text {option {-normal}}} {
- putqueue mode $text $option
-}
+proc ::tcldrop::server::putquick {text {option {-normal}}} { putqueue mode
$text $option }
-proc ::tcldrop::server::putserv {text {option {-normal}}} {
- putqueue server $text $option
-}
+proc ::tcldrop::server::putserv {text {option {-normal}}} { putqueue server
$text $option }
-proc ::tcldrop::server::puthelp {text {option {-normal}}} {
- putqueue help $text $option
-}
+proc ::tcldrop::server::puthelp {text {option {-normal}}} { putqueue help
$text $option }
# Reply to server PINGs:
bind raw - PING ::tcldrop::server::PING 99
-proc ::tcldrop::server::PING {from key arg} {
- putquick "PONG $arg"
-}
+proc ::tcldrop::server::PING {from key arg} { putquick "PONG $arg" }
# Handle server ERRORs:
bind raw - ERROR ::tcldrop::server::ERROR 99
proc ::tcldrop::server::ERROR {from key arg} {
- if {${::servererror-quit}} {
- Error {ERROR} $arg
- }
+ if {${::servererror-quit}} { Error {ERROR} $arg }
}
# Set our basic info (botnick, etc) and call the init-server event:
@@ -394,7 +381,7 @@
set ::real-server $from
set ::botnick [lindex [split $arg] 0]
# Eval $init-server (obsolete in Eggdrop):
- catch { eval ${::init-server} }
+ if {[info exists ::init-server]} { catch { eval ${::init-server} } }
# Call the init-server binds:
callevent init-server
}
@@ -411,4 +398,4 @@
bind evnt - prerestart ::tcldrop::server::PreRestart
proc ::tcldrop::server::PreRestart {type} {
quit $type
-}
+}
\ No newline at end of file