Project

General

Profile

[Script] Use ZNC Playback to only replay new messages

Added by Per Amundsen about 1 month ago

Saves the timestamp of the last received message and then asks ZNC playback to only replay new messages received after the last timestamp.

raw CAP:*LS*:{
  if (znc.in/playback isin $1-) {
    CAP REQ :znc.in/playback
  }
}

raw CAP:*ACK*:{
  if (znc.in/playback isin $1-) {  
    set -e % [ $+ [ $networkident ] ] 1
  }
}

on *:DISCONNECT:{
  unset % $+ $networkident
}

raw 376:*:requestplayback
raw 422:*:requestplayback

on *:TEXT:*:*:{
  if ( % [ $+ [ $networkident ] ] ) {
    set % $+ $networktime $iif($msgstamp, $v1, $ctime)
  }
}

on *:ACTION:*:*:{
  if ( % [ $+ [ $networkident ] ] ) {
    set % $+ $networktime $iif($msgstamp, $v1, $ctime)
  }
}

alias -l requestplayback {
  var %time = % [ $+ [ $networktime ] ]
  if (!%time) {
    %time = 0
  }

  if ( % [ $+ [ $networkident ] ] ) {
    .quote PRIVMSG *playback :play * %time
  }
}

alias -l networkident { return $+($servertarget,.,$username,.zncplayback) }
alias -l networktime { return $+($servertarget,.,$username,.zncplayback.time) }