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.

timer

Help for those learning Tcl or writing their own scripts.
Post Reply
d
dfxrick
Voice
Posts: 4
Joined: Tue Jan 26, 2010 10:40 pm
Location: Alexandria, KY
Contact:

timer

Post by dfxrick »

Can someone please help me out with this code? I'm having problems finding out why its not working. I dont see it. after 60 minutes of idle its supposed to remove the authflag, and it isn't, can anyone please help with this problem. u can find me on #fam or #tzirc on efnet. Please help me out. Thanks!!!


proc auth_idle {} {
global _auth authflag

set idletime 1
set chans [channels]
set chan_tot [llength $chans]
set chan_num 0
for {set loop 0} {$loop < $chan_tot} {incr loop} {
set nicks [chanlist [lindex $chans $loop] $authflag]
set nickidle 1
set nick_tot [llength $nicks]
for {set loop2 0} {$loop2 < $nick_tot} {incr loop2} {
set idletime [getchanidle [lindex $nicks $loop2] [lindex $chans $loop]]
if {$idletime >= $nickidle} {set nickidle $idletime}
if {($idletime > 60)} {
set nick [lindex $nicks $loop2]
set hand [nick2hand [lindex $nicks $loop2]]
if {[hand2idx $hand] == -1} {
putlog "$nick Idle over 60 minutes. Deauthenticated."
chattr $hand "-${authflag}"
putserv "NOTICE $nick :Idle over 60 minutes. Deauthenticated."
}
}
}
}
www.tzirc.com check us out
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

At a first glance, there seems to be one } missing at the end. I'd recommend using the "code" BB-code tags for code, as this preserve indenting, and generally makes the code easier to read.

Also, you could easily replace all those for-loops and multiple lindex operations with a simple foreach-loop.

As for the logics, should a user be deauth'd if (s)he's idle on a single channel (even if (s)he's been active on any other), or does (s)he have to be idle on all channels?

Finally, how do you trigger the code? Timers/utimers, time binding, other event?

That said, here's a cleanup of your code sofar:

Code: Select all

proc auth_idle {} {
 global authflag

 foreach chan [channels] {
  foreach nick [chanlist $chan $authflag] {
   if {[getchanidle $nick $chan] > 60 && [hand2idx [nick2hand $nick]] == -1} {
    putlog "$nick Idle over 60 minutes. Deauthenticated."
    chattr $hand "-${authflag}"
    putserv "NOTICE $nick :Idle over 60 minutes. Deauthenticated."
   }
  }
 }
}
NML_375
Post Reply