mIRC Home    About    Download    Register    News    Help

Print Thread
#137614 15/12/05 05:39 PM
Joined: Jan 2005
Posts: 55
R
rtg Offline OP
Babel fish
OP Offline
Babel fish
R
Joined: Jan 2005
Posts: 55
hello

sometimes when I try to prv msg a nickname I receive this msg in my status

"nickname Message target change too fast. Please wait x seconds and then try again."

1.I want this crucial info to be displayed in the query window, or if it doesnt exist in the active window

2.I want mirc to try to msg this person again

thanks!

#137615 15/12/05 06:24 PM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
I don't know if it's possible to resend the message automatically. I think it would be more to the point to prevent such messages from occuring at all. That message usually occurs when you (your script) sends too many messages to too many users in a short length of time. If you have a script that is sending messages to many users at the same time, you need to throttle those messages using timers of some sort. You could try this code that I wrote:
Code:
alias buffer {

  var %bufferlimit = 100
  var %resumefactor = 1.5

  if ($regex(buffer,$1,/-(.)/i)) {
    ;** Remove and store switches
    var %sw = $regml(buffer,1)
    tokenize 032 $2-
  }

  if (!$hget(buffer)) hmake buffer 10
  if (!$hget(buffer,head)) hadd buffer head 1
  if (!$hget(buffer,tail)) hadd buffer tail 1

  if (!$hget(buffer,delay)) hadd buffer delay 1000
  if ($hget(buffer,delay) < 10) hadd buffer delay 1000

  echo -a Head: $hget(buffer,head) Tail: $hget(buffer,tail)

  if (%sw == $null) {
    ;** Add a new item to the buffer

    if ($1- == $null) {
      echo -s Buffer: Error: No data to add to queue
      return 0
    }

    hinc buffer head 1
    if ($hget(buffer,head) > %bufferlimit) hadd buffer head 1
    hadd buffer $hget(buffer,head) $1-

    if (!$timer(.buffer)) .timer.buffer -m 1 $hget(buffer,delay) buffer -r
    if (!$timer(.bresume)) .timer.bresume -m 1 $calc($hget(buffer,delay) * %resumefactor) buffer -r
  }

  elseif (%sw == r) {
    ;** Read the next queued item

    if ($hget(buffer,head) == $hget(buffer,tail)) {
      .timer.buffer off
      .timer.bresume off
      return
    }

    .timer.bresume -m 1 $calc($hget(buffer,delay) * %resumefactor) buffer -r

    hinc buffer tail 1
    if ($hget(buffer,tail) > %bufferlimit) hadd buffer tail 1

    $hget(buffer,$hget(buffer,tail))
    hdel buffer $hget(buffer,tail)

    if ($hget(buffer,head) > $hget(buffer,tail)) {
      .timer.buffer -m 1 $hget(buffer,delay) buffer -r
      .timer.bresume -m 1 $calc($hget(buffer,delay) * %resumefactor) buffer -r
    }
    else {
      .timer.buffer off
      .timer.bresume off
    }

  }

  elseif (%sw == d) {
    ;** Set delay time in milliseconds

    if (($1 < 10) || ($1 !isnum)) {
      echo -s Buffer: Error: Delay must be at least 10ms
      return 0
    }

    hadd buffer delay $1
    if ($show) echo -s Buffer: Delay has been set to $1 $+ ms

  }

  return 1
}


This is basically a FIFO buffer.

Syntax:
/buffer [color:green]/command argument argument[/color]
(Add an item to the buffer)

/buffer -r
(Execute the next command in the buffer - This is called by the timers)

/buffer -d
(Adjust the timer delay in ms - Default is 1000ms (1s) )

$buffer([color:green]/command argument argument)[/color]
$buffer(-r)
$buffer(-d)
The identifier forms return 1 if the command executed successfully, otherwise it returns 0.


-genius_at_work

Last edited by genius_at_work; 15/12/05 06:29 PM.
#137616 15/12/05 08:44 PM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
(1) You need to add a var %sw at the start, as if there is a global variable (set) of %sw which is not $null the if (%sw == $null) { line well fail when it was not intended too.
(2) You also need to add some type of code to deal with buffer overruns, since should the head reach the [tail] your code essentially well dump the 100 buffer entries.
(3) Also if ($hget(buffer,head) > $hget(buffer,tail)) { is incorrect as should the head pass the bufferlimit it well be reset to 1, and thus be below tail, that should be != rather than >

I took the liberty of adjusting your code to remove the above things (1) & (2) and due to the change (3) wasnt incorrect anymore.

Code:
alias buffer {

  [color:blue]; <unneeded> var %bufferlimit = 100[/color]
  var %resumefactor = 1.5
  [color:blue]var %sw[/color]

  if ($regex(buffer,$1,/-(.)/i)) {
    ;** Remove and store switches
    var %sw = $regml(buffer,1)
    tokenize 032 $2-
  }

  if (!$hget(buffer)) hmake buffer 10
  if (!$hget(buffer,head)) hadd buffer head [color:blue]0[/color]
  if (!$hget(buffer,tail)) hadd buffer tail [color:blue]0[/color]

  if (!$hget(buffer,delay)) hadd buffer delay 1000
  if ($hget(buffer,delay) < 10) hadd buffer delay 1000

  echo -a Head: $hget(buffer,head) Tail: $hget(buffer,tail)

  if (%sw == $null) {
    ;** Add a new item to the buffer

    if ($1- == $null) {
      echo -s Buffer: Error: No data to add to queue
      return 0
    }

    hinc buffer head 1
    [color:blue]; <unneeded> if ($hget(buffer,head) > %bufferlimit) hadd buffer head 1[/color]
    hadd buffer $hget(buffer,head) $1-

    if (!$timer(.buffer)) .timer.buffer -m 1 $hget(buffer,delay) buffer -r
    if (!$timer(.bresume)) .timer.bresume -m 1 $calc($hget(buffer,delay) * %resumefactor) buffer -r
  }

  elseif (%sw == r) {
    ;** Read the next queued item

    if ($hget(buffer,head) <= $hget(buffer,tail)) {
      .timer.buffer off
      .timer.bresume off
      [color:blue]hdel buffer head | hdel buffer tail[/color]
      return
    }

    .timer.bresume -m 1 $calc($hget(buffer,delay) * %resumefactor) buffer -r

    hinc buffer tail 1
    [color:blue]; <unneeded> if ($hget(buffer,tail) > %bufferlimit) hadd buffer tail 1[/color]

    $hget(buffer,$hget(buffer,tail))
    hdel buffer $hget(buffer,tail)

    if ($hget(buffer,head) > $hget(buffer,tail)) {
      .timer.buffer -m 1 $hget(buffer,delay) buffer -r
      .timer.bresume -m 1 $calc($hget(buffer,delay) * %resumefactor) buffer -r
    }
    else {

      .timer.buffer off 
      .timer.bresume off
      [color:blue]hdel buffer head | hdel buffer tail[/color]
    }

  }

  elseif (%sw == d) {
    ;** Set delay time in milliseconds

    if (($1 < 10) || ($1 !isnum)) {
      echo -s Buffer: Error: Delay must be at least 10ms
      return 0
    }

    hadd buffer delay $1
    if ($show) echo -s Buffer: Delay has been set to $1 $+ ms

  }

  return 1
}


This uses a non cyclic buffer of unlimited length, once the tail catches the head the buffer tail and head are erased producing a new head and tail to be generated on next command addition. I set the head and tail to 0 rather than 1 only becuase the code inc head before storing the first command, and i felt storing the first command into "2" was a bit odd. The reseting the buffer head and tail, was only done due to the thats how i do mine, it could have been left to climb in numbers indefinitly, however eventually the numbers could have exceeded mircs numeric ability ,although I think pc memory would fail first, or it would take some significant time to reach such numbers.

#137617 15/12/05 10:29 PM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Thanks for the fixes, DaveC. I never actually used that code in any real application, so I never encountered any errors with it. I was bored one day so I decided to make it.

-genius_at_work

#137618 16/12/05 04:55 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
its pretty well thought out, as you can see i only had to make very small adjustments.

I particually liked the failsafe second timer .timer.bresume -m 1 $calc($hget(buffer,delay) * %resumefactor) buffer -r idea.


Link Copied to Clipboard