Last active
August 29, 2015 14:22
-
-
Save miigotu/de594708415fa09d067b to your computer and use it in GitHub Desktop.
Color nicks, text, and mode symbol based on status in hexchat/xchat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Name: statuscolor-0.4.pl | |
| # Version: 0.4 | |
| # Author: LifeIsPain < idontlikespam (at) orvp [dot] net > | |
| # Date: 2008-06-02 | |
| # Description: Change the color of usernames, text, and mode symbol in channel text based on channels status | |
| # (op, voice, etc) | |
| # Modified: Miigotu , miigotu (at) gmail [dot] com > | |
| # Version Histroy | |
| # 0.1 2008-01-13 The Birth! | |
| # 0.2 2008-03-02 Should use EAT_ALL instead of EAT_XCHAT | |
| # 0.3 2008-06-20 Problem with extra events being printed in some cases fixed (using | |
| # PRI_HIGH instead of PRI_LOW, as while LOW is more accurate as to when | |
| # I want it to perform, did cause a problem with a different script) | |
| # 0.4 2015-06-01 Color status symbol and text also - Miigotu | |
| use strict; | |
| use warnings; | |
| use Xchat qw( :all ); | |
| my $NAME = 'Status Color for nicks and text'; | |
| my $VERSION = '0.4 (Modded by: Miigotu)'; | |
| ############################################# | |
| # CONFIGURATION # | |
| ############################################# | |
| # The following list of events will have the user name coloroized. Place a '#' before the | |
| # line in order to not have that event have the color replaced | |
| my @events = ( | |
| 'Channel Message', | |
| 'Channel Action', | |
| 'Channel Msg Hilight', | |
| 'Channel Action Hilight', | |
| 'Your Message', | |
| 'Your Action', | |
| ); | |
| # The following list of events determine the color of the nick. Use Preferences -> Colors | |
| # for available color codes. The list below approximates the colors of the icons in the | |
| # user list. The last line is commented, but is available if you wish to provide a color | |
| # for users with no nick. | |
| my %modes = ( | |
| '+' => 19, | |
| '%' => 18, | |
| '@' => 20, | |
| '&' => 21, | |
| '~' => 21, | |
| '!' => 21, | |
| '*' => 21, | |
| '' => 30, # If user has no mode | |
| ); | |
| ############################################# | |
| register($NAME, $VERSION, "Change the color of usernames, text, and mode symbol in channels based on channels status (op, voice, etc)"); | |
| Xchat::print("Loading $NAME $VERSION"); | |
| for my $event (@events) { | |
| hook_print($event, \&color_message, { data => $event, priority => PRI_HIGH }); | |
| } | |
| my $exit; | |
| sub color_message { | |
| $exit = 0; | |
| my @msgdata = @{$_[0]}; | |
| my $event = $_[1]; | |
| my $color = $modes{($msgdata[2] || '')}; | |
| if ($color) { | |
| if ($msgdata[0] =~ /^\003$color/) { | |
| $exit = 1; | |
| return EAT_NONE; | |
| } | |
| # 0 => Nick, 1 => Text, 2 => Status symbol | |
| foreach my $i (0..0+@msgdata) { | |
| if ($msgdata[$i]) { | |
| $msgdata[$i] =~ s/\003\d{0,2}(?:,\d{1,2})?// ; # strip colors | |
| $msgdata[$i] = "\003$color$msgdata[$i]\003"; # add colors | |
| } | |
| } | |
| emit_print($event, @msgdata) unless $exit; | |
| return EAT_ALL; | |
| } | |
| return EAT_ALL if $exit; | |
| return EAT_NONE; | |
| } | |
| __END__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment