Skip to content

Instantly share code, notes, and snippets.

@tung
Last active February 2, 2016 08:19
Show Gist options
  • Save tung/3599386 to your computer and use it in GitHub Desktop.
Save tung/3599386 to your computer and use it in GitHub Desktop.
XChat script to gray/dim messages from certain users
#!/usr/bin/perl
#
# graymsg-0.1.6.pl - color messages from certain users gray
#
# Change the nicks array to customize.
use strict;
use warnings;
my @supernicks = (
'Adeon',
'ais523',
'bhaak',
'callforjudgement',
'Chris_ANG',
'coppro',
'dtype',
'Grunt',
'kerio',
'lorimer',
'Patashu',
'paxed',
'remirol',
'sgrunt',
);
my @nicks = (
'Rodney',
'Rodney-e4',
'demogorgon',
'demogorgon2',
'devogorgon',
'GruntBot',
'Forkney',
'Unrodney',
'Announcy',
'Asidonhopo',
'Quadley',
'Assangeley',
'dHackley',
'Hackley',
'Randley',
'Slashley',
'travis-ci',
'Athame',
'Athame_',
);
my @ignoremsgs = (
'enters the dungeon as',
'resumes the adventure',
'taking a break from the hard life as an adventurer'
);
my $script_name = 'graymsg.pl';
my $script_version = '0.1.6';
my $script_description = 'color messages from certain users gray';
Xchat::register($script_name, $script_version, $script_description);
Xchat::print("\cB$script_name\cB version \cB$script_version\cB loaded\n");
Xchat::hook_print('Channel Message', \&do_gray);
sub do_gray {
my ($nick, $text) = @{ $_[0] };
my ($nick_only) = $nick =~ /^\x03\d{2}(.*)$/;
# 0.1.3 - ignore certain messages
for my $i (@ignoremsgs) {
return Xchat::EAT_XCHAT if ($text =~ /$i/i);
}
for my $i (@supernicks) {
# match 'foo' or 'foo_' or 'foo__'...
if ($nick_only =~ /${i}_*/) {
# \cC00 - color white (hopefully)
# \cO - stop formatting
Xchat::print("$nick\t\cC00$text\cO\n",
Xchat::get_info('channel'),
Xchat::get_info('server'));
return Xchat::EAT_XCHAT;
}
}
my $found = 0;
for my $i (@nicks) {
if ($nick_only eq $i) {
$found = 1;
}
}
return Xchat::EAT_NONE unless $found;
# 0.1.5 - ignore bot feedback unless they ascend
if ($text =~ /(BHnofarm|sambot|dumbbot|HlpngPhrndlyBot|kniggetbot)/) {
return Xchat::EAT_XCHAT unless ($text =~ /ascended/);
}
# \cC14 - color dark gray
# \cO - stop formatting
Xchat::print("$nick\t\cC14$text\cO\n",
Xchat::get_info('channel'),
Xchat::get_info('server'));
return Xchat::EAT_XCHAT;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment