-
Notifications
You must be signed in to change notification settings - Fork 234
/
Copy pathcolorswap.pl
47 lines (38 loc) · 1.3 KB
/
colorswap.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Swap between green and white format for public messages. I think this
# helps readability. Assumes you haven't changed message formats.
# for irssi 0.7.98 by Timo Sirainen
use Irssi;
use strict;
use vars qw($VERSION %IRSSI);
$VERSION = "0.1";
%IRSSI = (
authors => "Timo \'cras\' Sirainen",
contact => "tss\@iki.fi",
name => "colorswap",
description => "Swap between green and white format for public messages. I think this helps readability. Assumes you haven't changed message formats.",
license => "Public Domain",
url => "http://irssi.org/",
changed => "2002-03-04T22:47+0100"
);
my %setnext = {};
sub change_formats {
my $target = lc shift;
if ($setnext{$target}) {
Irssi::command('^format own_msg {ownmsgnick %G$2 {ownnick %G$0}}%g$1');
Irssi::command('^format pubmsg {pubmsgnick %g$2 {pubnick %g$0}}%g$1');
} else {
Irssi::command('^format -reset own_msg');
Irssi::command('^format -reset pubmsg');
}
$setnext{$target} = !$setnext{$target};
}
sub sig_public {
my ($server, $msg, $nick, $address, $target) = @_;
change_formats($server->{tag}."/".$target);
}
sub sig_own_public {
my ($server, $msg, $target) = @_;
change_formats($server->{tag}."/".$target);
}
Irssi::signal_add('message public', 'sig_public');
Irssi::signal_add('message own_public', 'sig_own_public');