0

I've been trying for days to add a 2 second delay to the "postmessage" alias in this code. Nothing I've tried seems to work. How do you add a 2 second delay to this script ? Like make the first message be sent immediately when triggered but the second one 2 seconds after the first.

The full code is here.

this is the portion of the code I need help with:

alias postmessage {

IF (%notes_for. [ $+ [ $server ] ] [ $+ [ . ] ] [ $+ [ $chan ] ] [ $+ [ . ] ] [ $+ [ $nick ] ]) {
VAR %x_notes 1
WHILE ($gettok(%notes_for. [ $+ [ $server ] ] [ $+ [ . ] ] [ $+ [ $chan ] ] [ $+ [ . ] ] [ $+ [ $nick ] ],%x_notes,32)) {
  MSG $chan %note_from_to. [ $+ [ $server ] ] [ $+ [ . ] ] [ $+ [ $chan ] ] [ $+ [ . ] ] [ $+ [ $v1 ] ] [ $+ [ . ] ] [ $+ [ $nick ] ]      
  UNSET %note_from_to. [ $+ [ $server ] ] [ $+ [ . ] ] [ $+ [ $chan ] ] [ $+ [ . ] ] [ $+ [ $v1 ] ] [ $+ [ . ] ] [ $+ [ $nick ] ]
  INC %x_notes
}
UNSET %notes_for. [ $+ [ $server ] ] [ $+ [ . ] ] [ $+ [ $chan ] ] [ $+ [ . ] ] [ $+ [ $nick ] ]
  }
}

1 Answers1

2

You have to make another alias with a timer to call the postmessage alias

For example

alias postmessageDelayed {
; the next line of code will have a delay of 2 seconds
  .timer 1 2 postmessage
}
alias postmessage {

IF (%notes_for. [ $+ [ $server ] ] [ $+ [ . ] ] [ $+ [ $chan ] ] [ $+ [ . ] ] [ $+ [ $nick ] ]) {
VAR %x_notes 1
WHILE ($gettok(%notes_for. [ $+ [ $server ] ] [ $+ [ . ] ] [ $+ [ $chan ] ] [ $+ [ . ] ] [ $+ [ $nick ] ],%x_notes,32)) {
  MSG $chan %note_from_to. [ $+ [ $server ] ] [ $+ [ . ] ] [ $+ [ $chan ] ] [ $+ [ . ] ] [ $+ [ $v1 ] ] [ $+ [ . ] ] [ $+ [ $nick ] ]      
  UNSET %note_from_to. [ $+ [ $server ] ] [ $+ [ . ] ] [ $+ [ $chan ] ] [ $+ [ . ] ] [ $+ [ $v1 ] ] [ $+ [ . ] ] [ $+ [ $nick ] ]
  INC %x_notes
}
UNSET %notes_for. [ $+ [ $server ] ] [ $+ [ . ] ] [ $+ [ $chan ] ] [ $+ [ . ] ] [ $+ [ $nick ] ]
  }
}

1 means run only once
2 means use a delay of two seconds before executing

To use this call postmessageDelayed instead of postmessage

Denny
  • 1,766
  • 3
  • 17
  • 37