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.

Delayed /whois queing of channel users

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Delayed /whois queing of channel users

Post by awyeah »

Suppose I want to perform a task of whois all channel users on all channels the bot is on. Some channels may have user counts 100+ as well.

This task might slow the bot, I can manually at utimers and check for each channel with a delay, but how to make this system automated? Any idea? to help for the delay queing. Suppose I want to delay 2mins between the /whois check for every channel. Can't seem to get anything in my head currently, maybe because its just 8:30am here, heh.

Code: Select all

bind time - "*" check:ascii:time

proc check:ascii:time {m h d mo y} {
 #check the time interval to perform the scan
 if {([scan $m %d]+([scan $h %d]*60)) % 10 == 0} {

 #whois channel users
 foreach chan [split [string tolower [channels]]] {
  foreach user [chanlist $chan] {
    if {![isbotnick $user] && ![isop $user $chan] && ![isvoice $user chan]} {
        puthelp "WHOIS $user"
        }
      }
    }
  }
}
What I can do is add an array for each channel containing their user list:

Code: Select all

set userlist [list]
 foreach chan [split [string tolower [channels]]] {
  foreach user [chanlist $chan] {
    if {![isbotnick $user] && ![isop $user $chan] && ![isvoice $user chan]} {
     lappend userlist($chan) $user
    }
  }
}      
Now I got the channel user lists in an array, then how to whois every channels array with a specific delay of time in between? The reason is I don't want to whois every channels users at the one time, will heap the queue.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Add the channels into a list as well and create a timer which will perform a whois on each channel every 2 minutes (you'll remove the channel from the list each time). Example

Code: Select all

if {![info exists chanlist] || $chanlist == {}} {
 set chanlist [channels]
}
# whois array of channel at index 0 in $chanlist
# remove the first element from $chanlist
set chanlist [lreplace $chanlist 0 0]
# timer to call proc again...
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Ah thanks Sir_Fz, I will try to implement that.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Sir_Fz wrote:Add the channels into a list as well and create a timer which will perform a whois on each channel every 2 minutes (you'll remove the channel from the list each time). Example

Code: Select all

if {![info exists chanlist] || $chanlist == {}} {
 set chanlist [channels]
}
# whois array of channel at index 0 in $chanlist
# remove the first element from $chanlist
set chanlist [lreplace $chanlist 0 0]
# timer to call proc again...
Okay I devised something like this, just to let you know:

Code: Select all

proc check:ascii:time {m h d mo y} {
 #check the time interval to perform the scan
 if {([scan $m %d]+([scan $h %d]*60)) % 30 == 0} {

 #set list of channels to whois
 set chanlist [list "#awyeah #miri #urdu"]
 set chanlist [split [string tolower $chanlist]]

 #set whois timer
 set chanwhois 5

 #whois each channel
 foreach chan $chanlist {
  utimer $chanwhois [list whois:ascii:users $chan]
  incr chanwhois 5
  }
 }
}

proc whois:ascii:users {chan} {
 if {[botonchan $chan] && [botisop $chan]} {
  foreach user [chanlist $chan] {
    if {![isbotnick $user] && ![isop $user $chan] && ![isvoice $user $chan] && ![matchattr [nick2hand $user $chan] mn|mn $chan]} {
      puthelp "WHOIS $user"
      }
    }
  }
}
Didn't find a need remove the channel names from the list though.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

You didn't really apply my idea, you created your own ;) Also

Code: Select all

set chanlist [split [string tolower $chanlist]]
$chanlist is a list, so don't apply a [string] command over it (use [join] to convert it to a string). Besides, it's already lowercase so there's no need to apply [string tolower] over it anyway.
Post Reply