return sprintf "\003%d%s", $rcolors[$col % @rcolors], $nick;
}
+my %gui_commands = (
+ 'clear' => [ 'COLOR 0' ],
+ 'highlight' => [ 'FLASH' => 'COLOR 3' ],
+);
+
+sub gui {
+ my $commands = $gui_commands{$_[0] || 'nope'};
+ die 'Invalid command' unless defined $commands;
+ command "GUI $_" for @$commands;
+}
+
sub save_context {
my $cur_cxt = get_context;
bless \$cur_cxt, 'Xchat::XPI::Utils::ContextGuard';
our @EXPORT = ();
our %EXPORT_TAGS = ('funcs' => [ qw<
dye_nick
+ gui
save_context local_context
called_from_script
> ]);
use lib get_info 'xchatdir';
use Xchat::XPI;
use Xchat::XPI::Events qw<filter>;
+use Xchat::XPI::Utils qw<gui>;
our $VERSION = '0.04';
my $ph;
-sub guihl {
- command 'GUI FLASH';
- command 'GUI COLOR 3';
-}
-
-sub guiclear {
- command 'GUI COLOR 0';
-}
-
-hook_print 'Private Message to Dialog', sub { guihl; return EAT_NONE };
+hook_print 'Private Message to Dialog', sub {
+ gui 'highlight';
+ return EAT_NONE;
+};
my %hl = (
'#cpantesters' => [ qw<
filter 'Channel Action' => sub {
my $chan = lc get_info 'channel';
if ($hl{$chan} and $_[1] =~ /$hl{$chan}/) {
- guihl;
+ gui 'highlight';
1;
} else {
0;
filter 'Channel Action Hilight' => sub {
my $chan = lc get_info 'channel';
if ($skip{$chan} and $_[1] =~ /$skip{$chan}/) {
- guiclear;
+ gui 'clear';
1;
} else {
0;
use lib get_info 'xchatdir';
use Xchat::XPI;
-use Xchat::XPI::Utils qw<save_context>;
+use Xchat::XPI::Utils qw<gui save_context>;
use constant MAX_MATCHES => 10;
my $guard = save_context;
for (get_list 'channels') {
set_context $_->{context};
- command 'GUI COLOR 0';
+ gui 'clear';
}
return EAT_ALL;
}, {