-
Notifications
You must be signed in to change notification settings - Fork 2
/
msg_to_notice.pl
49 lines (40 loc) · 1.39 KB
/
msg_to_notice.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
48
49
use strict;
use warnings;
use Irssi;
use vars qw($VERSION %IRSSI);
$VERSION = "1";
%IRSSI = (
authors => 'Fernando Vezzosi',
contact => '[email protected]',
name => 'Msg to Notice',
description => 'Transform messages from some nicknames into notices',
license => 'Public Domain',
url => 'http://irssi.org/',
changed => '2013-04-24T17:40+0200',
);
use constant {
I_SERVER => 0,
I_DATA => 1,
I_NICK => 2,
I_MASK => 3,
I_TARGET => 4,
};
sub handle_privmsg {
# my ($target, $message) = split /:/, $_[I_DATA];
# Irssi::print("server<$_[I_SERVER]> data<$_[I_DATA]>[$target:$message] nick<$_[I_NICK]> mask<$_[I_MASK]> target<@{[ $_[I_TARGET] // '(undef)' ]}>");
my $is_noticeable = 0;
for my $noticeable_nick ( split /[\s,]+/, Irssi::settings_get_str('noticeable_nicks') ) {
$noticeable_nick =~ s/\A \s+//x;
$noticeable_nick =~ s/\s+ \z//x;
if ( lc $noticeable_nick eq lc $_[I_NICK] ){
$is_noticeable = 1;
last;
}
}
return unless $is_noticeable;
Irssi::signal_emit('event notice', $_[I_SERVER], $_[I_DATA], $_[I_NICK], $_[I_MASK]);
Irssi::signal_stop();
}
Irssi::settings_add_str('msg_to_notice', 'noticeable_nicks', 'root,deploy');
Irssi::signal_add('event privmsg', 'handle_privmsg');
# vim: filetype=perl tabstop=4 shiftwidth=4 expandtab cindent: