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.

[SOLVED]checking a list of users in an auth proc

Help for those learning Tcl or writing their own scripts.
Post Reply
L
Luminous
Op
Posts: 146
Joined: Fri Feb 12, 2010 1:00 pm

[SOLVED]checking a list of users in an auth proc

Post by Luminous »

There is more to this proc, the rest of it works. This part is supposed to check each user on each channel 3 times per hour, sending a status request to nickserv every 5 seconds between each user, as to not flood the bot or the server. This does not work because of the loop. How can I adjust this so that it will step through each nick every 5 seconds like I want?

Code: Select all

bind time - "05 * * * *" check_reg
bind time - "20 * * * *" check_reg
bind time - "45 * * * *" check_reg

proc check_reg {min hr day mm yy} {
    foreach c [channels] {
        foreach n [chanlist $c] {
           utimer 5 [list auth_check $n]
        }
   return 0
    }
}

proc auth_check {n} {
bind notc - * isreg
 puthelp "PRIVMSG nickserv :status $n"
}
Last edited by Luminous on Wed Oct 20, 2010 9:53 pm, edited 1 time in total.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

bind time - "05 * * * *" check_reg
bind time - "20 * * * *" check_reg
bind time - "45 * * * *" check_reg

# check/attain
proc check_reg {min hr day mm yy} {
   # reset purged list, empty
   set ::reg_checklist [list]
   # iterate channels
   foreach c [channels] {
      # create list of nicks from chan, including all from prior iterations
      set ::reg_checklist [concat "$::reg_checklist" "[chanlist $c]"]
   } 
   # sort list, remove dupes
   set ::reg_checklist [lsort -unique $::reg_checklist]
   # call purge
   start_purging
}

# purge/invoke
proc start_purging {
   # avoid endless timers, no timer created if no list present
   if {![llength $::reg_checklist]} { return }
   # attain 1st nick in the list
   set nick [lindex $::reg_checklist 0]
   # remove it from the list
   set ::reg_checklist [lreplace $::reg_checklist 0 0]
   # call auth with attained nick
   auth_check $nick
   # invoke start_purging again to purge list
   utimer 5 [list start_purging]
}

# auth/push   
proc auth_check {n} {
   bind notc - * isreg
   puthelp "PRIVMSG nickserv :status $n"
}
You almost had it all. You were missing the part which queues your list of nicks every 5 seconds. This script will take all the nicks in all your channels, mash them together into a list. Then it sorts them uniquely (to remove dupes) and makes them in alphabetical order. It then passes this to start_purging procedure which picks the first nick, deletes it from the list, calls your auth_check proc, then calls itself after 5 seconds. It will repeat this, every 5 seconds until the list is empty.
L
Luminous
Op
Posts: 146
Joined: Fri Feb 12, 2010 1:00 pm

Post by Luminous »

Ah, thanks, I see now! :D I had actually written a newer version of my OP after talking to someone on irc about it, but It was that purge section that I needed to make that work. I had the list part fine, but missed the magic involving that step.
Post Reply