Advertisement
Guest User

Untitled

a guest
Jul 1st, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. # Name: statuscolor-0.4.pl
  2. # Version: 0.4
  3. # Author: LifeIsPain < idontlikespam (at) orvp [dot] net >
  4. # Date: 2008-06-02
  5. # Description: Change the color of usernames, text, and mode symbol in channel text based on channels status
  6. # (op, voice, etc)
  7. # Modified: Miigotu , miigotu (at) gmail [dot] com >
  8.  
  9. # Version Histroy
  10. # 0.1 2008-01-13 The Birth!
  11. # 0.2 2008-03-02 Should use EAT_ALL instead of EAT_XCHAT
  12. # 0.3 2008-06-20 Problem with extra events being printed in some cases fixed (using
  13. # PRI_HIGH instead of PRI_LOW, as while LOW is more accurate as to when
  14. # I want it to perform, did cause a problem with a different script)
  15. # 0.4 2015-06-01 Color status symbol and text also - Miigotu
  16.  
  17. use strict;
  18. use warnings;
  19. use Xchat qw( :all );
  20.  
  21. my $NAME = 'Status Color for nicks and text';
  22. my $VERSION = '0.4 (Modded by: Miigotu)';
  23.  
  24. #############################################
  25. # CONFIGURATION #
  26. #############################################
  27. # The following list of events will have the user name coloroized. Place a '#' before the
  28. # line in order to not have that event have the color replaced
  29. my @events = (
  30. 'Channel Message',
  31. 'Channel Action',
  32. 'Channel Msg Hilight',
  33. 'Channel Action Hilight',
  34. 'Your Message',
  35. 'Your Action',
  36. );
  37.  
  38. # The following list of events determine the color of the nick. Use Preferences -> Colors
  39. # for available color codes. The list below approximates the colors of the icons in the
  40. # user list. The last line is commented, but is available if you wish to provide a color
  41. # for users with no nick.
  42. my %modes = (
  43. '+' => 19,
  44. '%' => 18,
  45. '@' => 20,
  46. '&' => 21,
  47. '~' => 21,
  48. '!' => 21,
  49. '*' => 21,
  50. '' => 30, # If user has no mode
  51. );
  52. #############################################
  53.  
  54. register($NAME, $VERSION, "Change the color of usernames, text, and mode symbol in channels based on channels status (op, voice, etc)");
  55. Xchat::print("Loading $NAME $VERSION");
  56.  
  57. for my $event (@events) {
  58. hook_print($event, \&color_message, { data => $event, priority => PRI_HIGH });
  59. }
  60.  
  61. my $exit;
  62.  
  63. sub color_message {
  64. $exit = 0;
  65.  
  66. my @msgdata = @{$_[0]};
  67. my $event = $_[1];
  68.  
  69. my $color = $modes{($msgdata[2] || '')};
  70.  
  71. if ($color) {
  72. if ($msgdata[0] =~ /^\003$color/) {
  73. $exit = 1;
  74. return EAT_NONE;
  75. }
  76.  
  77. # 0 => Nick, 1 => Text, 2 => Status symbol
  78. foreach my $i (0..0+@msgdata) {
  79. if ($msgdata[$i]) {
  80. $msgdata[$i] =~ s/\003\d{0,2}(?:,\d{1,2})?// ; # strip colors
  81. $msgdata[$i] = "\003$color$msgdata[$i]\003"; # add colors
  82. }
  83. }
  84.  
  85. emit_print($event, @msgdata) unless $exit;
  86. return EAT_ALL;
  87. }
  88. return EAT_ALL if $exit;
  89. return EAT_NONE;
  90. }
  91.  
  92. __END__
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement