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 reacts after double the set duration.

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
s
simo
Revered One
Posts: 1100
Joined: Sun Mar 22, 2015 2:41 pm

timer reacts after double the set duration.

Post by simo »

greetings ive been using this test tcl to clear bans with delay but for some reason it sets after 8 seconds while the value ive used is 4 seconds i cant figure why this happens.

Code: Select all



bind pub n|- !cbx CLEAR-OLD-Bans
 

proc CLEAR-OLD-Bans {nick host hand chan text} {
   set chan2 "#test"

   bind raw - 367 timed:clear:oldbans:raw2024 
   bind raw - 368 timed:clear:oldbans:raw2024

   putnow "mode $chan2 +b"
}

 
 proc timed:clear:oldbans:raw2024 {from key text} { 
   global clearbans 

   switch -- $key { 
      367 { 
         lassign [split $text] bot chan mask 
       set chan [string tolower $chan] 
         lappend clearbans($chan) $mask 
}

      368 { 
         lassign [split $text] bot chan 
         set chan [string tolower $chan] 
         unbind raw - 367 timed:clear:oldbans:raw2024 
         unbind raw - 368 timed:clear:oldbans:raw2024 
         if {![info exists clearbans($chan)]} return 
         set len [llength $clearbans($chan)] 
         set total 0 
         if {$len > 0} { 
            while {$len > 0} { 
               if {$len > 6} { 
                  set mode [string repeat "b" 6] 
                  set masks [join [lrange $clearbans($chan) 0 [expr {6 - 1}]]] 
                  set clearbans($chan) [lrange $clearbans($chan) 6 end] 
                  incr len -6 
                  incr total 6 
               } else { 
                  set mode [string repeat "b" $len] 
                  set masks [join $clearbans($chan)] 
                  incr total $len  
                  set len 0 
               } 
                incr counter 1
                after [expr {$counter*4000}] [list putnow "MODE $chan -$mode $masks"]                 
            } 
         } 
      } 
   } 
}




Last edited by simo on Thu Jul 18, 2024 9:40 am, edited 1 time in total.
s
simo
Revered One
Posts: 1100
Joined: Sun Mar 22, 2015 2:41 pm

Re: timer reacts after double the set duration.

Post by simo »

here is an example of a test:

14:12:31 (+Simo) : !cbx

14:12:39 @Hawk Sets Mode on #test to: -bbbb *!*@s44-wtu7-9op6-q76-wl2y.8856.7930.IP *!*@t1m-5w4-5541-9aa-i730.877.0687.IP *!*@8nz2-3klm-448-6k2-wi2.2932.754.IP *!*@f991-8f8-04z-83mz-0vh2.1549.3535.IP

14:12:43 @Hawk Sets Mode on #test to: -bbbb *!*@i4yp-fw5o-39q7-g94-67a5.632.6222.IP *!*@vj4-x36-fb92-g1eq-622.831.4177.IP *!*@42v-o2x-6x1-h3ct-089m.032.120.IP *!*@vsb-7w3-a5s-p1t4-8f8.243.6571.IP

14:12:47 @Hawk Sets Mode on #test to: -bbbb *!*@vkj-4wm-445n-c4w0-44vt.7892.696.IP *!*@805b-f6g-45i-0iy6-26v5.5367.2331.IP *!*@55o0-487o-726-c05q-48j.1556.8675.IP *!*@2fro-1zur-vr64-65w-5k2.5517.7794.IP

14:12:51 @Hawk Sets Mode on #test to: -bbbb *!*@62ms-6l2-p536-zry-9lj.260.8383.IP *!*@i9rw-5gfa-kqr-835-83dj.246.5893.IP *!*@171-s3x4-62o-6r4-880r.374.537.IP *!*@s0v-wybp-0j5-c54-2qp4.2118.816.IP
User avatar
CrazyCat
Revered One
Posts: 1277
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Re: timer reacts after double the set duration.

Post by CrazyCat »

Simplified version of your script:
while {$len > 0} {
   incr counter 1
   after [expr {$counter*4000}] [list putnow "MODE $chan -$mode $masks"]
}
So if $len = 1, time will be 4s. If len = 2, time will be 8s, ....
Post Reply