| View previous topic :: View next topic |
| Author |
Message |
awyeah Revered One

Joined: 26 Apr 2004 Posts: 1580 Location: Switzerland
|
Posted: Mon Jul 23, 2007 10:28 pm Post subject: Delayed /whois queing of channel users |
|
|
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: |
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: |
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.
================================== |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Tue Jul 24, 2007 6:38 am Post subject: |
|
|
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: | 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...
|
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
awyeah Revered One

Joined: 26 Apr 2004 Posts: 1580 Location: Switzerland
|
Posted: Tue Jul 24, 2007 11:01 am Post subject: |
|
|
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.
================================== |
|
| Back to top |
|
 |
awyeah Revered One

Joined: 26 Apr 2004 Posts: 1580 Location: Switzerland
|
Posted: Sun Aug 05, 2007 10:56 pm Post subject: |
|
|
| 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: | 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: |
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.
================================== |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Mon Aug 06, 2007 5:19 pm Post subject: |
|
|
You didn't really apply my idea, you created your own Also
| Code: | | 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. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
|