Priority message sounds have separate flood protection.
This commit is contained in:
2
README
2
README
@@ -20,3 +20,5 @@ Example pattern: ^\S+-\d+ is requesting assistance\.$
|
||||
Matching public messages will use priority_sound_command instead of pub_sound_command.
|
||||
Use /set priority_messages_file to change the file path if needed.
|
||||
Reload the regex file with: /sound priority_reload
|
||||
Check a message against patterns with: /sound priority_check <message>
|
||||
Use /set priority_sound_flood to control priority alert cooldown.
|
||||
|
||||
30
sound.pl
30
sound.pl
@@ -24,6 +24,8 @@ $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 = '';
|
||||
@@ -92,12 +94,18 @@ sub priority_reload {
|
||||
|
||||
sub sound_command {
|
||||
my ($data, $server, $witem) = @_;
|
||||
my $command = $data // '';
|
||||
my $command = defined $data ? $data : '';
|
||||
if ($command =~ /^\s*priority_reload\s*$/i) {
|
||||
priority_reload();
|
||||
return;
|
||||
}
|
||||
Irssi::print("Usage: /sound priority_reload");
|
||||
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() {
|
||||
@@ -105,6 +113,11 @@ sub sound_overflow_timeout() {
|
||||
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) = @_;
|
||||
@@ -167,13 +180,13 @@ sub pub_msg {
|
||||
} else {
|
||||
if (message_is_priority($msg)) {
|
||||
if (my $prioritycmd = Irssi::settings_get_str("priority_sound_command")) {
|
||||
if ($flood_protect) {
|
||||
my $sound_flood = Irssi::settings_get_int('sound_flood');
|
||||
$sound_flood = 1000 if $sound_flood < 0;
|
||||
Irssi::timeout_remove($sound_tag);
|
||||
$sound_tag = Irssi::timeout_add($sound_flood, 'sound_overflow_timeout', undef);
|
||||
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);
|
||||
$flood_protect = 0;
|
||||
$priority_flood_protect = 0;
|
||||
}
|
||||
}
|
||||
return;
|
||||
@@ -340,6 +353,7 @@ $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 - norm -15 &> /dev/null&");
|
||||
Irssi::settings_add_str("misc", "part_sound_command",
|
||||
|
||||
Reference in New Issue
Block a user