aboutsummaryrefslogtreecommitdiffstats
path: root/dimpid.pl
blob: b809dabadeb0f6b1da23fb3cd8b096dc05b8dfd7 (plain)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# dimpid.pl
#
# Outputs public messages from certain nicks in grey instead of standard black.
#
# Settings:
#
#     dimpid_nicks: a space-separated list of nicks whose public messages will
#                   be printed in grey.
#
#                   Example: /set dimpid_nicks nibbler hermes zoidberg
#
#
# Copyright (c) 2018 Teddy Wing
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

use strict;

use Irssi;

our $VERSION = '1.00';
our %IRSSI = {
	authors     => 'Teddy Wing',
	contact     => 'irssi@teddywing.com',
	name        => 'Dimpid',
	description => 'Dim messages from certain nicks',
	license     => 'GPL',
};


use constant ESCAPE => "\x{03}";
use constant GREY => '14';

Irssi::signal_add('message public', sub {
	my ($server, $text, $nick, @rest) = @_;

	my @nicks = split(' ', Irssi::settings_get_str('dimpid_nicks'));

	if (grep($_ eq $nick, @nicks)) {
		Irssi::signal_continue(
			$server,
			ESCAPE . GREY . $text . ESCAPE,
			$nick,
			@rest,
		);
	}
});


Irssi::settings_add_str('dimpid', 'dimpid_nicks', '');