home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / ircii30.zip / script2 / ncolor < prev    next >
Text File  |  1996-02-03  |  7KB  |  195 lines

  1. # ncolor  irc script to assign a color to any regular msgs from a nickname
  2. # written by inkling 30-Jan-96 v1.1c
  3. #
  4. # you need mikhs' ircII beta 2.2 or later for OS/2 for this script to work
  5. # or some other ircII client that supports control c color schemes
  6. #
  7. #  NOTE:  you need to edit your .ircrc file pointed to by $HOME
  8. #              LOAD NCOLOR
  9. #
  10. #  NOTE:  do /NCSAVE the very first time you run this to create ircolorc
  11. #          otherwise you might get an error message if you try /ncload
  12. #
  13. # the four commands for this script
  14. # /ncsave save color definitions to ircolorc file
  15. # /ncload load color definitions from ircolorc file
  16. # /ucolor color will set your color
  17. # /ncolor nick [color [MSG] ] | [DEL]
  18. #    [] indicates optional, | indicates or (but not both)
  19. #         nick by itself shows color and value assigned to nick
  20. #         nick color sets color of nicks' name only
  21. #         nick color MSG sets color of nicks' name and full msg text
  22. #         nick DEL removes all color definitions for nick
  23. #
  24. # color is given as 2 digit hexadecimal values, where:
  25. #   left digit (top nibble) background color
  26. #   right digit (bottom nibble) foreground color
  27. #
  28. # mod history:
  29. #  v1.0 first version up and working on PUBLIC on current channel
  30. #  v1.1 version doing most all public messages
  31. #  v1.1a fix to correct nick display on /msg
  32. #  v1.1b added the following features:
  33. #              PUBLIC_OTHER msgs in right color, channel left, nick right
  34. #              PUBLIC_NOTICE msgs in right color same as above
  35. #              NC nick DEL to delete definitions for nick
  36. #              NC nick color MSG to color on full msg text (default nick only)
  37. #  v1.1c added the following:
  38. #              fixed colormsg/echo to more generic. only /colorecho now
  39. #              added color assignment save and load via /ncsave /ncload
  40. #              added different channel colors for current and other /cc
  41. #              color settings are saved in $HOME/ircolorc
  42. #
  43. # limitations:
  44. #              it seems to work better if loaded after your favorite script
  45. #              wont handle special chars in nick name. assign doesnt like em
  46. #              'ncolor |dolt| 1c' wont work, but 'ncolor _dolt_ 1c' will.
  47. #
  48. # disclaimer:
  49. #              this program is not guaranteed to work.
  50. #                   use it at your own risk.
  51. #
  52.  
  53. eval set cntlc_colors on
  54. set -input_prompt
  55. set novice off
  56.  
  57. echo 0CN0BC0AO0DL0EO07R 1.1c for mikhs' ircII (2.4 or later) port for OS/2
  58.  
  59. # channel colors. only supporting two colors right now, color for the
  60. #  current channel you are on and channels that you are on but no window
  61. # unlike the user color codes, these colors are not stored in an array
  62. # $0 is color to set current channel
  63. # $1 is color to set non-current channel to
  64. alias cc ncolorchannel
  65. alias ccolor ncolorchannel
  66. alias ncolorchannel
  67.      {
  68.        if ( [$0] != [] )
  69.        {
  70.          ^assign ncolor..current $0
  71.          ^on ^public "% % *" {/echo $ncolor..current<$0> $2-}
  72.        }
  73.        if ( [$1] != [] )
  74.        {
  75.          ^assign ncolor..other $1
  76.          ^on ^public_other "% % *" {/echo $ncolor..other<$1:$0> $2-}
  77.        }
  78.      }
  79.  
  80. # this is for making other nicks messages in color
  81. alias nc ncolornick
  82. alias ncolor ncolornick
  83.  
  84. # ncolornick definitions
  85. # $0 is nickname
  86. # $1 is color (00-FF) or DEL to stop after removing definitions
  87. # $2 is MSG to enable color nick and message (default is nick only)
  88. alias ncolornick
  89.      {
  90.         if ( [$0] == [] )
  91.         {
  92.           echo 0CN0BC0AO0DL0EO07R v1.1c   0AUsage: 0B/ncolor nick 0E[ color [MSG] ] | 0D[DEL]
  93.         }
  94.         {
  95.           if ( [$1] == [] )
  96.           {
  97.             if ( [$ncolor[$0]] != [] )
  98.             { echo 0CN0BC0AO0DL0EO07R nickname $ncolor[$0]$007 color $ncolor[$0] }
  99.           }
  100.           {
  101. # this reached if $0 and $1 nonblank
  102. # remove any old ON cmds for this nick
  103.             ^on ^action -$0
  104.             ^on ^msg -$0
  105.             ^on ^notice -$0
  106.             ^on ^public -$0
  107.             ^on ^public_other -$0
  108.             ^on ^public_notice -$0
  109.  
  110. # remove any old color code and msg flags for this nick
  111.             ^assign -ncolor.$0
  112.             ^assign -ncolor.msg.$0
  113.  
  114. # see if DEL was used in place of color. if so, we're done
  115. #            othwise add nick color responses
  116.             if ( [$1] != [DEL] )
  117.             {
  118. # specify the ncolor nick to add the color (simplicity itself)
  119.               ^assign ncolor.$0 $1
  120.  
  121. # check to enable flag for whole message text to be displayed in color
  122.               if ( [$2] == [MSG] ) {^assign ncolor.msg.$0 MSG}
  123.  
  124. # respond to the following ON message types matching nick
  125. #   ACTION, MSG, NOTICE, PUBLIC and PUBLIC_OTHER, PUBLIC_NOTICE
  126.  
  127.               ^on ^action $0 {/ncolorecho $0 *$0 $2-}
  128. # for jcc              ^on ^msg $0 {/ncolorecho $0 *$0* $1-}
  129.               ^on ^notice $0 {/ncolorecho $0 -$0: $1-}
  130.               ^on ^public $0 {/ncolorecho $0 <$0> $2-}
  131.               ^on ^public_notice $0 {/ncolorecho $0 -$1:$0: $2-}
  132.               ^on ^public_other $0 {/ncolorecho $0 [$1:$0] $2-}
  133.             }
  134.           }
  135.         }
  136.      }
  137.  
  138. # $0 is nick, $1 is style and $2 is full msg text
  139. # this echos nick in color and msg text if ncolor.msg.$nick non blank
  140. alias ncolorecho
  141.       {
  142.         @ncolor..temp = ncolor[$0]
  143.         if ( [$ncolor.msg[$0]] != [] )
  144.           { echo $ncolor..temp$1 $2- }
  145.           { echo $ncolor..temp$1$color_normal $2- }
  146.       }
  147. alias ncload
  148.      {
  149.        echo 0CN0BC0AO0DL0EO07R loading ircolorc file...
  150.        load $HOME/ircolorc
  151.      }
  152. alias ncsave
  153.      {
  154.        ^on ^exec_error "ncsave *" #
  155.        eval ^exec -name ncsave rm $HOME/ircolorc
  156.        wait %ncsave
  157.        eval ^exec -name ncosave cat >> $HOME/ircolorc
  158.        ^msg %ncosave # ncolor save file
  159.        if ( [$ncolor..user] != [] )
  160.          { ^msg %ncosave ucolor $ncolor..user }
  161.        if ( [$ncolor..current] != [] )
  162.          { ^msg %ncosave ccolor $ncolor..current $ncolor..other }
  163.        foreach ncolor ii
  164.               {
  165.                 if ( [$ncolor[$ii]] != [] )
  166.                   { ^msg %ncosave ncolor $ii $ncolor[$ii] $ncolor.msg[$ii] }
  167.               }
  168.        echo 0CN0BC0AO0DL0EO07R saved ircolorc file...
  169.        ^on ^exec_error -"ncsave *"
  170.        ^exec -close %ncosave
  171.        wait %ncosave
  172.      }
  173.  
  174. # this will save the color settings when you exit
  175. alias exit
  176.      {
  177.        ncsave
  178.        //exit
  179.      }
  180.  
  181. # this is for making all my own messages in color
  182. alias uc ncoloruser
  183. alias ucolor ncoloruser
  184. alias ncoloruser
  185.      {
  186.        ^assign ncolor..user $0
  187.        ncolor ${N} $0 MSG
  188.      }
  189.  
  190. on ^send_action * echo $ncolor..user* ${N} $1-
  191. on ^send_msg * echo $ncolor..user*$0* $1-
  192. on ^send_notice * echo $ncolor..user-$0: $1-
  193. on ^send_public * echo $ncolor..user<${N}> $1-
  194. ncload
  195.