Skip to content
Browse files

Add priority level verification/clamping

  • Loading branch information...
1 parent 16fa21b commit e0a4b5736c262b55b015782726a7b65dbdde39f3 @henrikbrixandersen committed Apr 25, 2012
Showing with 13 additions and 4 deletions.
  1. +13 −4 prowl.pl
View
17 prowl.pl
@@ -30,7 +30,6 @@
# TODO:
# - IRC URL support
-# - priority verification
# - on/off/auto support
# - include/exclude channels regex
# - async $prowl->verify -- example at https://github.com/shabble/irssi-scripts/blob/master/feature-tests/pipes.pl
@@ -70,9 +69,17 @@
sub setup_changed_handler {
$config{debug} = Irssi::settings_get_bool('prowl_debug');
- $config{priority_msgs} = Irssi::settings_get_int('prowl_priority_msgs');
- $config{priority_hilight} = Irssi::settings_get_int('prowl_priority_hilight');
- $config{priority_cmd} = Irssi::settings_get_int('prowl_priority_cmd');
+
+ for (qw/msgs hilight cmd/) {
+ my $priority = Irssi::settings_get_int("prowl_priority_$_");
+ if ($priority < -2 || $priority > 2) {
+ $priority = -2 if ($priority < -2);
+ $priority = 2 if ($priority > 2);
+ Irssi::settings_set_int("prowl_priority_$_", $priority);
+ Irssi::signal_emit('setup changed');
+ }
+ $config{"priority_$_"} = $priority;
+ }
my $apikey = Irssi::settings_get_str('prowl_apikey');
if ($apikey) {
@@ -127,6 +134,8 @@ sub prowl_command_handler {
my $text = $options[1];
$args->{priority} = $config{priority_cmd} unless exists $args->{priority};
+ $args->{priority} = -2 if ($args->{priority} < -2);
+ $args->{priority} = 2 if ($args->{priority} > 2);
$text = ' ' unless $text;
prowl('Manual Message', $text, $args->{priority}, $args->{url});
}

0 comments on commit e0a4b57

Please sign in to comment.
Something went wrong with that request. Please try again.