Project

General

Profile

[Script] Typing Indicators (TAGMSG)

Added by westor (GR) 6 months ago

Description:

The following code is adding support for +typing (https://ircv3.net/specs/client-tags/typing.html) IRCv3 tag on AdiIRC Statusbar, it works as much it could be done to match the official tag, there are some settings on first lines you can play with, in order to work the IRCd must support the specific IRCv3 tag, tested under UnrealIRCd 5.x and InspIRCD 3.9.x with AdiIRC 4.0 version.

Contact:

Preview:

Code:

NOTE : It's recommended to use the GitHUB Gists link instead. https://gist.github.com/westor7/cc03f9998e6a7d44c8fee2fdbbc2ba9b

; --- Settings ---

alias -l tagmsg_receive { return 1 } ; 1 = Will receive any +typing spec messages, use 0 to disable it.
alias -l tagmsg_share { return 1 } ; 1 = Will send +typing spec when you write something on editbox, 0 to disable it.
alias -l tagmsg_share_delay { return 3 } ; 3 = The seconds that client will send the typing share, default says it is 3, do not get lower than that it will be spammy.
alias -l tagmsg_position { return 5 } ; 5 = the position number , use 1 to be in 1st place top left on the statusbar or whatever number you want.
alias -l tagmsg_auto_done_secs { return 6 } ; 6 = the automatically typing=done seconds, spec says 6 is the correct here.
alias -l tagmsg_icon_file { return $envvar(windir) $+ \System32\comres.dll } ; = Use only DLL that includes icons. (example: shell32.dll), works only on Windows
alias -l tagmsg_icon_index { return 6 } ; = The $tagmsg_icon_file DLL index icon number, works only on Windows.
alias -l tagmsg_icon_size { return 2 } ; 1 = small, 2 = large, 3 = actual, works only on Windows.

; --- Settings ---

ON *:KEYUP:*:*: {
  var %editbox = $editbox($active,0)
  var %editbox_old = $editboxhistory($active,1)

  if (!$tagmsg_share) || (!$ircv3caps(message-tags).enabled) || ($left(%editbox,1) == $comchar) || ($keychar == $null) || ($status !== connected) || (!$statusbar) { return }
  if ($servervars(CLIENTTAGDENY).key) && (!$istok($servervars(CLIENTTAGDENY).value,-typing,44)) { return }
  if ($active !ischan) && (!$query($active)) { return }

  if ($keyval == 13) && ($left(%editbox_old,1) == $comchar) { return }

  if ($istok(8 13,$keyval,32)) && (%editbox == $null) {
    if ($timer([TAGMSG_ $+ $me $+ ])) { .timer[TAGMSG_ $+ $me $+ ] off | .quote @+typing=done TAGMSG $active }

    return
  }

  if (!$timer([TAGMSG_ $+ $me $+ ])) { .quote @+typing=active TAGMSG $active }

  .timer[TAGMSG_ $+ $me $+ ] 1 $tagmsg_share_delay tagmsg_send $active
}

ON *:ACTIVE:*: { if ($activecid !== $lactivecid) { tagmsg_close } }
ON *:KICK:#: { if ($knick == $me) { tagmsg_close } | else { tagmsg_del $knick } }
ON *:PART:#: { if ($nick == $me) { tagmsg_close } | else { tagmsg_del $nick } }
ON *:QUIT: { if ($nick == $me) { tagmsg_close } | else { tagmsg_del $nick } }
ON !*:NICK: { tagmsg_del $nick }
ON *:DISCONNECT: { tagmsg_close }

RAW TAGMSG:*: { 
  if (!$tagmsg_receive) || (!$statusbar) || ($cid !== $activecid) { return }

  if ($msgtags(+typing) == done) { tagmsg_del $nick | return }
  if ($msgtags(+typing) !== active) { return }

  if ($active !== $nick) && ($active !== $1) { tagmsg_close | return }

  .timer[TAGMSG_ $+ $nick $+ ] 1 $tagmsg_auto_done_secs tagmsg_del $nick

  hadd -m TAGMSG $nick 1

  tagmsg_format
}

alias tagmsg_send {
  ; /tagmsg_send <target>

  if (!$1) || ($active !== $1) || ($status !== connected) { return }

  if ($editbox($active,0) !== $null) { .quote @+typing=paused TAGMSG $1 | return }

  .quote @+typing=active TAGMSG $1
}

alias tagmsg_close {
  ; /tagmsg_close

  .timer[TAGMSG_*] off

  if ($hget(TAGMSG)) { hfree $v1 }
  if ($statusbar(TAGMSG)) { statusbar -d $v1 }
}

alias tagmsg_format {
  ; /tagmsg_format

  var %total = $hget(TAGMSG,0).item

  if (!%total) { return }

  if (%total == 1) { var %line = $tagmsg_nicks is typing... }
  if (%total isnum 2-5) { var %line = $tagmsg_nicks are typing... }
  if (%total >= 6) { var %line = %total nicknames are typing... }

  if (!$statusbar(TAGMSG)) {
    if (!$iswine) { statusbar $+(-iz,$tagmsg_icon_size,n,$tagmsg_icon_index) $tagmsg_position TAGMSG $qt(%line) @TAGMSG $qt($tagmsg_icon_file) $qt(%line) }
    else { statusbar -i $tagmsg_position TAGMSG $qt(%line) @TAGMSG $qt(%line) }

    return
  }

  statusbar -g TAGMSG $qt(%line)
}

alias tagmsg_del {
  ; /tagmsg_del <nick>

  if (!$1) { return }

  if ($hget(TAGMSG,$1)) { hdel TAGMSG $1 }

  if (!$hget(TAGMSG,0).item) {
    .timer[TAGMSG_*] off

    if ($hget(TAGMSG)) { hfree $v1 }
    if ($statusbar(TAGMSG)) { statusbar -d $v1 }
  }
}

alias tagmsg_nicks {
  ; $tagmsg_nicks

  var %total = $hget(TAGMSG,0).item

  if (!%total) { return 0 }

  var %i = 1 
  while (%i <= %total) {
    var %nick = $hget(TAGMSG,%i).item

    if (%nick) { var %results = $addtok(%results,%nick,44) }

    inc %i
  }

  if (%results) { var %results = $replace(%results,$chr(44),$+($chr(44),$chr(32))) }

  return $iif(%results,$v1,0)
}