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 

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

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Luminous
Op


Joined: 12 Feb 2010
Posts: 146

PostPosted: Wed Oct 20, 2010 5:14 pm    Post subject: [SOLVED]checking a list of users in an auth proc Reply with quote

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:
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
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Wed Oct 20, 2010 5:57 pm    Post subject: Reply with quote

Code:
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.
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
Luminous
Op


Joined: 12 Feb 2010
Posts: 146

PostPosted: Wed Oct 20, 2010 9:49 pm    Post subject: Reply with quote

Ah, thanks, I see now! Very Happy 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.
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 -> Scripting Help 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