home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / ncolor13.zip / ncolor
Text File  |  1996-12-30  |  10KB  |  305 lines

  1. # ncolor  irc script to assign colors under ircii 3.0 mikh code
  2. # written by inkling, last edited: 01-Jan-97, version: 1.3
  3. #
  4. # you need mikhs' ircII 3.0 or later for OS/2 for this script to work
  5. # or some other ircII client that supports ^c color and $% encoding
  6. #
  7. #  HINT:  latest mikh ircii3.0 works real well ;) ;)
  8. #
  9. #  NOTE:  you need to edit your .ircrc file pointed to by HOME
  10. #      LOAD NCOLOR
  11. #     at least if you want this script loaded automatically ;)
  12. #
  13. #  NOTE:
  14. #    [] indicates optional parameters,
  15. #    {} indicates mandatory parameters,
  16. #     | indicates exclusive-or (either but not both)
  17. #
  18. # THESE ARE THE SUPPORTED COMMANDS:
  19. # /ncload
  20. #        Load color definitions from ircolorc file in $HOME
  21. #
  22. # /ncsave
  23. #        Save color definitions to ircolorc file in $HOME
  24. #        NOTE:  /exit will do an /ncsave automatically
  25. #
  26. # /nclist
  27. #        List all current color settings
  28. #
  29. # /ucolor color
  30. #        Sets the color of the things you type
  31. #
  32. # /ccolor color #chan {color | DEL}
  33. #        Sets #channel to color, the # is needed
  34. #        DEL removes channel color definitions
  35. #
  36. # /ncolor [ nick [color [MSG]] | [DEL] ]
  37. #
  38. #        nick by itself shows nick color and msg settings
  39. #        nick color sets color of nicks' name only
  40. #        nick color MSG sets color of nicks' name and full msg text
  41. #        nick DEL removes all color definitions for nick
  42. #
  43. # color is given as 2 digit hexadecimal values, where:
  44. # left digit (top nibble) background color
  45. # right digit (bottom nibble) foreground color
  46. #
  47. #
  48. # mod history:
  49. #
  50. #  v1.0 first version up and working on PUBLIC on current channel
  51. #
  52. #  v1.1 version doing most all public messages
  53. #
  54. #  v1.1a fix to correct nick display on MSG
  55. #
  56. #  v1.1b added the following features:
  57. #       PUBLIC_OTHER msgs in right color, channel left, nick right
  58. #       PUBLIC_NOTICE msgs in right color same as above
  59. #       NC nick DEL to delete definitions for nick
  60. #       NC nick color MSG to color on full msg text (default nick only)
  61. #
  62. #  v1.1c added the following:
  63. #       fixed COLORMSG/COLORECHO to more generic. only COLORECHO now
  64. #       added color assignment save and load via NCSAVE and NCLOAD
  65. #       added channel colors for current and otherwise, CCOLOR or CC
  66. #       color settings are saved in $HOME/ircolorc
  67. #
  68. #  v1.1d added the following:
  69. #       NCLIST to display current ncolor nicks in current colors
  70. #
  71. #  v1.2 added following:
  72. #      removed limitations on nick/channel names via $%
  73. #      fixed nclist code to work with new $% encoded format
  74. #
  75. #      NC works with [dolt] and _dolt_ now using $encode/$decode
  76. #      CC multiple channels now,
  77. #      EX:   /CC #os/2 1F = #os/2 brt white on blue
  78. #      NOTE: nick colored will override channel settings
  79. #      NOTE: new support for illegal assign chars in nicknames
  80. #            and channels via the $% autoencode and $decode()
  81. #            functions, but only works on ircii30.zip + later
  82. #  v1.2a added the following:
  83. #       CCOLOR changes will echo current channel in its set color
  84. #       CC set channels will NOT display #chan# info, color clue only
  85. #
  86. #       fixed /ME messages from current and other channels
  87. #       fixed bad parsing of CC resulting in garbage on NCLIST
  88. #       fixed up documentation at top of file to reflect new changes
  89. #
  90. #  v1.3 rewrote logic on channel/nick color display
  91. #      instead of creating separate ON commands for each chan/nick it will
  92. #      use a single ON command for each possible message type. the color
  93. #      lookup is done in the ncolorecho routine now. the memory usage with
  94. #      this method is 1/n of previous method, where n is the number of
  95. #      chan/nicks stored in the ncolor array. bye bye wasteful ON programming
  96. #
  97. # limitations:
  98. #      It seems to work better if loaded after your favorite script.
  99. #
  100. # disclaimer:
  101. #              This program is NOT guaranteed to work.
  102. #                   USE IT AT YOUR OWN RISK!
  103. #
  104. # thanks:
  105. #              to mikh for doing such a nice job with the ircII port for OS/2!
  106. #              to anyone using this script in spite of all the peculiarities!
  107. #
  108. # *mikh* /eval echo $decode($%{[blah]})
  109. # *mikh* will display blah
  110. #
  111. #
  112. # GMJ/lms
  113.  
  114. eval set cntlc_colors on
  115. set -input_prompt
  116. set novice off
  117.  
  118. echo 0CN0BC0AO0DL0EO07R v1.3 for mikhs' ircII (3.0 or later) port for OS/2
  119.  
  120. #
  121. # this is the ncolor chan/nick lister
  122. #
  123. alias nclist
  124. {
  125.   ^set hold_mode on
  126.   echo *** 0CN0BC0AO0DL0EO07R CHANNEL colors:
  127.   foreach ncolor.chan jj
  128.          {
  129.            if ( [$ncolor.chan[$jj]] != [] )
  130.              { echo $ncolor.chan[$jj] $decode($jj)  $ncolor.chan[$jj] }
  131.          }
  132.  
  133.   echo *** 0CN0BC0AO0DL0EO07R NICKNAME colors:
  134.   foreach ncolor ii
  135.          {
  136.            if ( [$ncolor[$ii]] != [] )
  137.              {
  138.                if ( [$ncolor.msg[$ii]] != [] )
  139.                  { echo $ncolor[$ii] $decode($ii)  $ncolor[$ii]  $ncolor[$ii]$ncolor.msg[$ii] }
  140.                  { echo $ncolor[$ii] $decode($ii)  $ncolor[$ii] }
  141.              }
  142.          }
  143.   ^set hold_mode off
  144. }
  145. #
  146. # this is the channel color section
  147. # channel colors! now you can color any channel to any default you want.
  148. #  nickname colors will override the channel colors.
  149. # $0 is channel
  150. # $1 is color to set channel to
  151. #  NOTE: both parms need to be specified, i.e. /cc #OS2 1F, use /nclist to see
  152. alias cc ncolorchannel
  153. alias ccolor ncolorchannel
  154. alias ncolorchannel
  155. {
  156.   if ( [$1] != [] )
  157. # means only do this if two parms passed
  158.     {
  159. # delete old info for new assignment
  160.       ^assign -ncolor.chan[$%0]
  161.  
  162. # check to see if there will be new assignments
  163.       if ( [$1] != [DEL] )
  164.         {
  165.           ^assign ncolor.chan[$%0] $1
  166.         }
  167.     }
  168. }
  169.  
  170. # this is for making other nicks messages in color
  171. alias nc ncolornick
  172. alias ncolor ncolornick
  173.  
  174. # ncolornick definitions
  175. # $0 is nickname
  176. # $1 is color (00-FF) or DEL to stop after removing definitions
  177. # $2 is MSG to enable color nick and message (default is nick only)
  178. alias ncolornick
  179. {
  180.   if ( [$0] == [] )
  181.     { echo 0CN0BC0AO0DL0EO07R v1.3 0CUsage: 0B/ncolor [ 0Dnick 0E[ color [MSG] ] | 0D[DEL] 0B] }
  182. # implied else follows
  183.     {
  184.       if ( [$1] == [] )
  185.         {
  186.           if ( [$ncolor[$%0]] != [] )
  187.             { echo 0CN0BC0AO0DL0EO07R nickname $ncolor[$%0]$00F color $ncolor[$0] }
  188.         }
  189. # this reached if $0 and $1 nonblank
  190.     {
  191. # remove any old color code and msg flags for this nick
  192.       ^assign -ncolor[$%0]
  193.       ^assign -ncolor.msg[$%0]
  194.  
  195. # if not DEL specified (meaning done) then add nick color
  196.       if ( [$1] != [DEL] )
  197.         {
  198. # specify the ncolor nick to add the color (simplicity itself)
  199.           ^assign ncolor[$%0] $1
  200.  
  201. # check to enable flag for whole message text to be displayed in color
  202.           if ( [$2] == [MSG] ) {^assign ncolor.msg[$%0] MSG}
  203.         }
  204.       }
  205.     }
  206. }
  207.  
  208. # $0 is nick, $1 is channel $2 is nickformat and $3 is full msg text
  209. # this will display channel color (if exists) then nick color,
  210. # then nickformat, then message. if the color hasnt been assigned
  211. # it will display NULL character hopefully
  212. #
  213. # this echos nick in color if ncolor.$nick non-blank
  214. #  and msg text in color if ncolor.msg.$nick non-blank
  215. alias ncolorecho
  216. {
  217.   if ( [$ncolor.msg[$%0]] != [] )
  218.     { echo $ncolor.chan[$%1]$ncolor[$%0]$2 $3- }
  219.     { echo $ncolor.chan[$%1]$ncolor[$%0]$2$ncolor.chan[$%1] $3- }
  220. }
  221. alias ncload
  222. {
  223.   echo 0CN0BC0AO0DL0EO07R loading ircolorc file...
  224.   load $HOME/ircolorc
  225. }
  226. # this will allow saving of current ncolor settings
  227. # no abbreviation but it is run automatically with /exit
  228. alias ncsave
  229. {
  230.   ^on ^exec_error "ncsave *" #
  231.   eval ^exec -name ncsave rm $HOME/ircolorc
  232.   wait %ncsave
  233.   eval ^exec -name ncosave cat >> $HOME/ircolorc
  234.   ^msg %ncosave # ncolor save file
  235.   if ( [$ncolor..user] != [] )
  236.     { ^msg %ncosave ucolor $ncolor..user }
  237.  
  238. # write all current channel colors to file
  239.   foreach ncolor.chan jj
  240.          {
  241.            if ( [ncolor.chan[$jj] != [] )
  242.              { ^msg %ncosave ccolor $decode($jj) $ncolor.chan[$jj] }
  243.          }
  244. # write all current nick colors to file
  245.   foreach ncolor ii
  246.          {
  247.            if ( [$ncolor[$ii]] != [] )
  248.              { ^msg %ncosave ncolor $decode($ii) $ncolor[$ii] $ncolor.msg[$ii] }
  249.          }
  250.   echo 0CN0BC0AO0DL0EO07R saved ircolorc file...
  251.   ^on ^exec_error -"ncsave *"
  252.   ^exec -close %ncosave
  253.   wait %ncosave
  254. }
  255.  
  256. # this will save the color settings when you exit
  257. alias exit
  258. {
  259.   ncsave
  260.   //exit
  261. }
  262.  
  263. # this is for making all my own messages in color
  264. alias uc ncoloruser
  265. alias ucolor ncoloruser
  266. alias ncoloruser
  267. {
  268.   ^assign ncolor..user $0
  269.   ncolor ${N} $0 MSG
  270. }
  271.  
  272. # specify the current user (you) colors for messages sent by you
  273. #
  274. on ^send_action * echo $ncolor..user* ${N} $1-
  275. on ^send_msg * echo $ncolor..user*$0* $1-
  276. on ^send_notice * echo $ncolor..user-$0: $1-
  277. on ^send_public * echo $ncolor..user<${N}> $1-
  278.  
  279. #
  280. # specify a generic color lookup for all these possible msgs
  281. # ACTION, MSG, NOTICE, PUBLIC and PUBLIC_OTHER, PUBLIC_NOTICE
  282. ##
  283. ###
  284. ####
  285. #####  here is where you can put some customizations (change whats below)
  286. ####
  287. ###
  288. ##
  289. #
  290. on ^action * {/ncolorecho $0 $1 ->$0 $2-}
  291. on ^msg * {/ncolorecho $0 $C *$0* $1-}
  292. on ^notice * {/ncolorecho $0 $C +$0+ $1-}
  293. on ^public * {/ncolorecho $0 $1 <$0> $2-}
  294. on ^public_notice * {/ncolorecho $0 $1 +$0:$1+: $2-}
  295. on ^public_other * {/ncolorecho $0 $1 <$0:$1> $2-}
  296.  
  297. #
  298. # as last thing, load all the current colors defined in ircolorc
  299. #
  300. ncload
  301.  
  302. #
  303. # GMJ/lms 1/1/97
  304.  
  305.