|
|
|
@@ -24,12 +24,100 @@ $VERSION = '0.0.3';
|
|
|
|
|
|
|
|
|
|
my $flood_protect = 1;
|
|
|
|
|
my $sound_tag;
|
|
|
|
|
my $priority_flood_protect = 1;
|
|
|
|
|
my $priority_sound_tag;
|
|
|
|
|
my $priority_patterns_ref = [];
|
|
|
|
|
my $priority_patterns_mtime = -1;
|
|
|
|
|
my $priority_patterns_file = '';
|
|
|
|
|
|
|
|
|
|
sub expand_home_path {
|
|
|
|
|
my ($path) = @_;
|
|
|
|
|
if (defined $path && $path =~ /^~(\/|$)/) {
|
|
|
|
|
$path =~ s/^~/$ENV{HOME}/;
|
|
|
|
|
}
|
|
|
|
|
return $path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sub load_priority_patterns {
|
|
|
|
|
my $file = Irssi::settings_get_str("priority_messages_file");
|
|
|
|
|
$file = expand_home_path($file);
|
|
|
|
|
return [] if (!defined $file || $file eq '');
|
|
|
|
|
|
|
|
|
|
my $mtime = (stat($file))[9];
|
|
|
|
|
if (!defined $mtime) {
|
|
|
|
|
$priority_patterns_ref = [];
|
|
|
|
|
$priority_patterns_mtime = -1;
|
|
|
|
|
$priority_patterns_file = $file;
|
|
|
|
|
return $priority_patterns_ref;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($file eq $priority_patterns_file && $mtime == $priority_patterns_mtime) {
|
|
|
|
|
return $priority_patterns_ref;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
my @patterns = ();
|
|
|
|
|
if (open(my $fh, "<", $file)) {
|
|
|
|
|
while (my $line = <$fh>) {
|
|
|
|
|
chomp $line;
|
|
|
|
|
$line =~ s/^\s+//;
|
|
|
|
|
$line =~ s/\s+$//;
|
|
|
|
|
next if ($line eq '' || $line =~ /^#/);
|
|
|
|
|
my $regex = eval { qr/$line/ };
|
|
|
|
|
next if $@;
|
|
|
|
|
push @patterns, $regex;
|
|
|
|
|
}
|
|
|
|
|
close $fh;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$priority_patterns_ref = \@patterns;
|
|
|
|
|
$priority_patterns_mtime = $mtime;
|
|
|
|
|
$priority_patterns_file = $file;
|
|
|
|
|
return $priority_patterns_ref;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sub message_is_priority {
|
|
|
|
|
my ($msg) = @_;
|
|
|
|
|
my $patterns_ref = load_priority_patterns();
|
|
|
|
|
foreach my $regex (@{$patterns_ref}) {
|
|
|
|
|
return 1 if ($msg =~ $regex);
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sub priority_reload {
|
|
|
|
|
$priority_patterns_mtime = -1;
|
|
|
|
|
$priority_patterns_file = '';
|
|
|
|
|
my $patterns_ref = load_priority_patterns();
|
|
|
|
|
my $patternCount = scalar @{$patterns_ref};
|
|
|
|
|
Irssi::print("Priority message patterns reloaded ($patternCount).");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sub sound_command {
|
|
|
|
|
my ($data, $server, $witem) = @_;
|
|
|
|
|
my $command = defined $data ? $data : '';
|
|
|
|
|
if ($command =~ /^\s*priority_reload\s*$/i) {
|
|
|
|
|
priority_reload();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ($command =~ /^\s*priority_check\s+(.+?)\s*$/i) {
|
|
|
|
|
my $message = $1;
|
|
|
|
|
my $isMatch = message_is_priority($message) ? "yes" : "no";
|
|
|
|
|
Irssi::print("Priority match: $isMatch");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Irssi::print("Usage: /sound priority_reload | /sound priority_check <message>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sub sound_overflow_timeout() {
|
|
|
|
|
$flood_protect = 1;
|
|
|
|
|
Irssi::timeout_remove($sound_tag);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sub priority_sound_overflow_timeout() {
|
|
|
|
|
$priority_flood_protect = 1;
|
|
|
|
|
Irssi::timeout_remove($priority_sound_tag);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sub join_msg {
|
|
|
|
|
my ($server,$msg,$nick,$address,$target) = @_;
|
|
|
|
@@ -90,6 +178,19 @@ sub pub_msg {
|
|
|
|
|
if ($server && ! Irssi::settings_get_bool("sounds")) {
|
|
|
|
|
return;;
|
|
|
|
|
} else {
|
|
|
|
|
if (message_is_priority($msg)) {
|
|
|
|
|
if (my $prioritycmd = Irssi::settings_get_str("priority_sound_command")) {
|
|
|
|
|
if ($priority_flood_protect) {
|
|
|
|
|
my $priority_sound_flood = Irssi::settings_get_int('priority_sound_flood');
|
|
|
|
|
$priority_sound_flood = 1000 if $priority_sound_flood < 0;
|
|
|
|
|
Irssi::timeout_remove($priority_sound_tag);
|
|
|
|
|
$priority_sound_tag = Irssi::timeout_add($priority_sound_flood, 'priority_sound_overflow_timeout', undef);
|
|
|
|
|
system($prioritycmd);
|
|
|
|
|
$priority_flood_protect = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (my $pubcmd = Irssi::settings_get_str("pub_sound_command")) {
|
|
|
|
|
if ($flood_protect) {
|
|
|
|
|
my $sound_flood = Irssi::settings_get_int('sound_flood');
|
|
|
|
@@ -252,30 +353,35 @@ $window->{refnum} != $dest->{window}->{refnum})) {
|
|
|
|
|
#add settings and defaults
|
|
|
|
|
Irssi::settings_add_bool("lookandfeel", "sounds", 1);
|
|
|
|
|
Irssi::settings_add_int("lookandfeel", "sound_flood", 250);
|
|
|
|
|
Irssi::settings_add_int("lookandfeel", "priority_sound_flood", 250);
|
|
|
|
|
Irssi::settings_add_str("misc", "join_sound_command",
|
|
|
|
|
"play -qnV0 synth tri 1500 tri 1800 delay 0 .12 fade h 0 .2 remix - &. /dev/null&");
|
|
|
|
|
"play -qnV0 synth tri 1500 tri 1800 delay 0 .12 fade h 0 .2 remix - norm -15 &> /dev/null&");
|
|
|
|
|
Irssi::settings_add_str("misc", "part_sound_command",
|
|
|
|
|
"play -qnV0 synth tri 1800 tri 1500 delay 0 .12 fade h 0 .2 remix - &> /dev/null&");
|
|
|
|
|
"play -qnV0 synth tri 1800 tri 1500 delay 0 .12 fade h 0 .2 remix - norm -8 &> /dev/null&");
|
|
|
|
|
Irssi::settings_add_str("misc", "quit_sound_command",
|
|
|
|
|
"play -qnV0 synth pi fade h 0 1 1 pad 0 1 reverb overdrive riaa norm -7 &> /dev/null&");
|
|
|
|
|
"play -qnV0 synth pi fade h 0 1 1 pad 0 1 reverb overdrive riaa norm -20 &> /dev/null&");
|
|
|
|
|
Irssi::settings_add_str("misc", "pub_sound_command",
|
|
|
|
|
"play -qnV0 synth 0.09 tri E3:B3 &> /dev/null&");
|
|
|
|
|
"play -qnV0 synth 0.09 tri E3:B3 norm -15 &> /dev/null&");
|
|
|
|
|
Irssi::settings_add_str("misc", "priority_sound_command",
|
|
|
|
|
"play -q -n synth 2 sine 700:1000 sine 900:1200 fade 0 2 0 remix - norm -12 repeat 3 overdrive reverb speed 4 &> /dev/null&");
|
|
|
|
|
Irssi::settings_add_str("misc", "own_act_sound_command",
|
|
|
|
|
"play -qnV0 synth 0.25 tri G5:E1 tri B5:D1 remix - norm -5 &> /dev/null&");
|
|
|
|
|
"play -qnV0 synth 0.25 tri G5:E1 tri B5:D1 remix - norm -15 &> /dev/null&");
|
|
|
|
|
Irssi::settings_add_str("misc", "own_privmsg_sound_command",
|
|
|
|
|
"play -qnV0 synth pl G2 pl G3 pl B2 pl B3 pl D3 pl D4 pl G3 pl G4 pl D4 pl D4 pl G4 pl G4 delay 0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 remix - phaser fade p 0 0.5 0.3 norm -3 &> /dev/null&");
|
|
|
|
|
"play -qnV0 synth pl G2 pl G3 pl B2 pl B3 pl D3 pl D4 pl G3 pl G4 pl D4 pl D4 pl G4 pl G4 delay 0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 remix - phaser fade p 0 0.5 0.3 norm -15 &> /dev/null&");
|
|
|
|
|
Irssi::settings_add_str("misc", "action_sound_command",
|
|
|
|
|
"play -qnV0 synth 0.25 tri E1:G5 tri D1:B5 remix - norm -5 &> /dev/null&");
|
|
|
|
|
"play -qnV0 synth 0.25 tri E1:G5 tri D1:B5 remix - norm -15 &> /dev/null&");
|
|
|
|
|
Irssi::settings_add_str("misc", "own_msg_sound_command",
|
|
|
|
|
"play -qnV0 synth 0.09 tri B3:E3 &> /dev/null&");
|
|
|
|
|
"play -qnV0 synth 0.09 tri B3:E3 norm -15 &> /dev/null&");
|
|
|
|
|
Irssi::settings_add_str("misc", "own_notice_sound_command",
|
|
|
|
|
"play -nqV0 synth pi fade h 0 1 1 norm -15 pad 0 1 reverb overdrive riaa speed 32 repeat 3 &> /dev/null&");
|
|
|
|
|
"play -nqV0 synth pi fade h 0 1 1 norm -20 pad 0 1 reverb overdrive riaa speed 32 repeat 3 norm -15 &> /dev/null&");
|
|
|
|
|
Irssi::settings_add_str("misc", "notice_sound_command",
|
|
|
|
|
"play -nqV0 synth pi fade h 0 1 1 norm -15 pad 0 1 reverb overdrive riaa speed 32 reverse repeat 3 &> /dev/null&");
|
|
|
|
|
"play -nqV0 synth pi fade h 0 1 1 norm -35 pad 0 1 reverb overdrive riaa speed 32 reverse repeat 3 &> /dev/null&");
|
|
|
|
|
Irssi::settings_add_str("misc", "privmsg_sound_command",
|
|
|
|
|
"play -qnV0 synth pl G4 pl G4 pl D4 pl D4 pl D4 pl D3 pl G4 pl G3 pl B3 pl B2 pl G3 pl G2 delay 0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 remix - phaser fade p 0 0.5 0.3 norm -3 &> /dev/null&");
|
|
|
|
|
"play -qnV0 synth pl G4 pl G4 pl D4 pl D4 pl D4 pl D3 pl G4 pl G3 pl B3 pl B2 pl G3 pl G2 delay 0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 remix - phaser fade p 0 0.5 0.3 norm -8 &> /dev/null&");
|
|
|
|
|
Irssi::settings_add_str("misc", "hilight_sound_command",
|
|
|
|
|
"play -qnV0 synth 0.5 tri A3:D3 tri D3:A3 remix - &> /dev/null&");
|
|
|
|
|
"play -qnV0 synth 0.5 tri A3:D3 tri D3:A3 remix - norm -15 &> /dev/null&");
|
|
|
|
|
Irssi::settings_add_str("misc", "priority_messages_file",
|
|
|
|
|
"~/.irssi/priority_messages");
|
|
|
|
|
#add Signals
|
|
|
|
|
Irssi::signal_add_last("message public", "pub_msg");
|
|
|
|
|
Irssi::signal_add_last("message irc action", "action_msg");
|
|
|
|
@@ -290,4 +396,5 @@ Irssi::signal_add_last("event join", 'join_msg');
|
|
|
|
|
Irssi::signal_add_last("event quit", 'quit_msg');
|
|
|
|
|
Irssi::signal_add_last("event part", 'part_msg');
|
|
|
|
|
Irssi::signal_add_last("event kick", 'part_msg');
|
|
|
|
|
Irssi::command_bind('sound', 'sound_command');
|
|
|
|
|
#- end
|
|
|
|
|