Project

General

Profile

[script] Random Nick Color message

Added by Mr. BS almost 11 years ago

Sharing a script I made to make channel message follow random nick color (CONFIG).

The features

- Menu for each pick: disable whole script¹ / on|off timestamp¹ / apply color to action messages¹ / color prefix¹.
- The script reads the config.ini to get the user custom config for action/nick.
- Supports both AdiIRC feature: Random/Custom Nick Colors.

¹: enabled by default.

Observations

- I will not apply the effect to your own messages (On Input event), because you lost sequential spaces for message that you send. A long history, classic MSL limitation/issue.
- If you upgrade the script by pasting the new version in editor, be sure to Reload it in File menu or by F5 to load ini config.

Screenshot

Changelog

  • v0.4
    - Added preliminary support for tips (it follows user CONFIG).
  • v0.3
    - By request, now is possible to set custom color for nick status prefixes: !~&@%+
    Check new RColor submenu to change default colors.
    - Changed the way bnc playback is detected to support some ZNC fork, example "Buffer Playback..." vs "Starting Buffer Playback...".
    - Fixed blank nick on znc playback <>. I hope it works.
    - Fixed action display on znc and the colors.
    - Minor changes/fixes/improvements in code.
  • v0.2
    - support for any identifier for message nick/emote config: $pnick, $status, $user.
    - added an experimental basic znc buffer playback support. Please don't complain for my newbish implementation, I'm glad it is working fine.
    ps: only compatible with timestamp enabled in znc options (on by default).
  • v0.1
    - initial release.

Script

; http://dev.adiirc.com/boards/5/topics/163
; outputs same nick random color for the message
; v0.4 by pereba

; Script

on 1:LOAD: {
  UserConf
  setPrefixColors
  UserIni
}

; to update vars when reload the script
on 1:START: {
  UserIni
}

on 1:UNLOAD: {
  unset %RColor.*
}
;$readini(config.ini, Tips, UseTips) tips: $readini(config.ini, Tips, Tips)
alias -l UserIni {
  set %RColor.nickConfig $strip($readini(config.ini, Messages, prefixuser),c)
  set %RColor.actionConfig $strip($readini(config.ini, Messages, prefixemote),c)
  set %RColor.TipTimes $readini(config.ini, Tips, TipTimes)
  set %RColor.isntFocusedTips $readini(config.ini, Tips, FocusedTips)
  set %RColor.msgTips $left($readini(config.ini, Tips, Tips),1)
}

alias -l UserConf {
  set %RColor.Enabled 1
  set %RColor.Timestamp.Enabled 1
  set %RColor.Action.Enabled 1
  set %RColor.prefixColored 1
}

alias -l setPrefixColors {
  set %RColor.prefixColorAdmin 4
  set %RColor.prefixColorOwner 4    
  set %RColor.prefixColorProtect 9
  set %RColor.prefixColorOp 7
  set %RColor.prefixColorHalfOp 11
  set %RColor.prefixColorVoice 13
}

;channel
on ^*:TEXT:*:#: {
  if (%RColor.Enabled == 1) {
    ; znc playback
    if ($nick == ***) && (Buffer Playback... isin $1-) {
      set -e %RColor.znc.playback. [ $+ [ $cid ] $+ . $+ [ $chan ] ] 1
      echo $EchoMode # $nickFormated $1-
    }
    if ($znc.playback) && ($nick != ***) {
      echo $TheColor -rlmbf # $iif(%RColor.Timestamp.Enabled == 1,$1) $nickFormated $2-
    }
    if ($nick == ***) && (Playback Complete. isin $1-) {
      unset %RColor.znc.playback. [ $+ [ $cid ] $+ . $+ [ $chan ] ]
      echo $EchoMode # $nickFormated $1-
      halt
    }
    ; normal messages
    if (!$znc.playback) {
      echo $TheColor $EchoMode # $nickFormated $1-
      if ($tips) && (%RColor.msgTips == 1) { 
        if ($appactive) && (%RColor.isntFocusedTips == true) { halt }
        noop $tip(messages,Channel Message $network,$nick on # says $+ : $strip($1-),%RColor.TipTimes)
      }
    }
    halt
  }
}

;action
on ^*:ACTION:*:#: {
  if ($znc.playback) {
    echo $iif(%RColor.Action.Enabled == 1, $TheColor) $EchoMode # $actionFormated $2-
  halt
  }
  if (%RColor.Action.Enabled == 1) {
    echo $TheColor $EchoMode # $actionFormated $1-
    if ($tips) && (%RColor.msgTips == 1) { 
      if ($appactive) && (%RColor.isntFocusedTips == true) { halt }
      noop $tip(messages,Channel Action $network,$nick on # $+ : $strip($1-),%RColor.TipTimes)
    }
    halt
  }
}

alias -l TheColor {
  if ($nick(#,$nick).color > 0) {
    return $nick(#,$nick).color
  }
}

alias -l EchoMode {
  if (%RColor.Timestamp.Enabled == 1) {
    return -trlmbf
  }
  return -rlmbf  
}

alias -l actionFormated { var %nc $replace(%RColor.actionConfig, $!pnick, $iif($nick == ***, ***, $nick($chan,$nick).pnick), $!status, $left($nick(#,$nick,a,r).pnick,1), $!nick, $nick) | return $prefixReplace(%nc) }
alias -l nickFormated { var %nc $replace(%RColor.nickConfig, $!pnick, $iif($nick == ***, ***, $left($nick(#,$nick,a,r).pnick,1) $+ $nick), $!status, $left($nick(#,$nick,a,r).pnick,1), $!nick, $nick) | return $prefixReplace(%nc) }
alias -l prefixReplace {
  var %prefix $left($nick(#,$nick,a,r).pnick,1)
  if ($regex(%prefix,/([!~&@%+])/)) && (%RColor.prefixColored == 1) {
    ; ! = $chr(33) ~ = $chr(126) & = $chr(38) @ $chr(64) % = $chr(37) + = $chr(43)
    return $replace($1, $chr(33), $+($chr(3),%RColor.prefixColorAdmin,$chr(126),$chr(3)), $chr(126), $+($chr(3),%RColor.prefixColorOwner,$chr(126),$chr(3)), $chr(38), $+($chr(3),%RColor.prefixColorProtect,$chr(38),$chr(3)), $chr(64), $+($chr(3),%RColor.prefixColorOp,$chr(64),$chr(3)), $chr(37), $+($chr(3),%RColor.prefixColorHalfOp,$chr(37),$chr(3)), $chr(43), $+($chr(3),%RColor.prefixColorVoice,$chr(43),$chr(3)))
  }
  return $1
}
alias -l znc.playback { return %RColor.znc.playback. [ $+ [ $cid ] $+ . $+ [ $chan ] ] }

alias RColorPreview {
  echo -ag $+( $chr(3), %RColor.prefixColorAdmin, $chr(2), $chr(33), $chr(2), $chr(3), Admin, $chr(160) $chr(3), %RColor.prefixColorOwner, $chr(2), $chr(126), $chr(2), $chr(3), Owner, $chr(160) $chr(3), %RColor.prefixColorProtect, $chr(2), $chr(38), $chr(2), $chr(3), Protect, $chr(160) $chr(3), %RColor.prefixColorOp, $chr(2), $chr(64), $chr(2), $chr(3), Op, $chr(160) $chr(3), %RColor.prefixColorHalfOp, $chr(2), $chr(37), $chr(2), $chr(3), HalfOp, $chr(160) $chr(3), %RColor.prefixColorVoice, $chr(2), $chr(43), $chr(2), $chr(3), Voice)
}

menu menubar {
  -
  $iif(%RColor.Enabled == 1, $style(1),)

Replies (1)

    (1-1/1)