Commit 6de543fd0404d59123805963208e42f3f0a5c5eb

Authored by sniker
1 parent afc98ecf

Final fixes I hope

Showing 1 changed file with 13 additions and 3 deletions   Show diff stats
pushover.pl
... ... @@ -18,6 +18,7 @@ use warnings;
18 18 # comma separated list of
19 19 # network tags that should
20 20 # be ignored.
  21 +# /set pushover_debug ON/OFF # Debug mode.
21 22 #
22 23 # "General hilight" basically referrs to ALL the hilights you have
23 24 # added manually in irssi, if many, it can get really bloated if
... ... @@ -42,6 +43,7 @@ use vars qw($VERSION %IRSSI);
42 43  
43 44 use LWP::UserAgent;
44 45 use HTTP::Request::Common;
  46 +use Data::Dumper;
45 47  
46 48 $VERSION = "0.1";
47 49  
... ... @@ -64,6 +66,7 @@ Irssi::settings_add_str("PushoverIrssi", "pushover_priority_channel", 0);
64 66 Irssi::settings_add_str("PushoverIrssi", "pushover_priority_pm", 0);
65 67 Irssi::settings_add_str("PushoverIrssi", "pushover_priority_general", 0);
66 68 Irssi::settings_add_str("PushoverIrssi", "pushover_ignore_nettag", "");
  69 +Irssi::settings_add_bool("PushoverIrssi", "pushover_debug", 0);
67 70  
68 71 sub send_noti {
69 72 my ($title, $text, $priority) = @_;
... ... @@ -84,7 +87,7 @@ sub send_noti {
84 87 $req = POST("https://api.pushover.net/1/messages.json",
85 88 [
86 89 token => $options{'token'},
87   - user => $options{'token'},
  90 + user => $options{'user'},
88 91 device => $options{'device'},
89 92 title => $options{'title'},
90 93 message => $options{'msg'},
... ... @@ -97,9 +100,16 @@ sub send_noti {
97 100 if ($response->is_success) {
98 101 # I guess it worked, eh?
99 102 # Debug:
100   - Irssi::print("What was posted: " . $req);
101   - Irssi::print("Notification not posted: " . $response->content);
  103 + if(Irssi::settings_get_bool("pushover_debug")){
  104 + Irssi::print("What was posted: " . Dumper(\%options));
  105 + Irssi::print("HTTP Code: " . $response->status_line());
  106 + Irssi::print("Notification posted: " . $response->content);
  107 + }
102 108 } else {
  109 + if(Irssi::settings_get_bool("pushover_debug")){
  110 + Irssi::print("What was posted: " . Dumper(\%options));
  111 + Irssi::print("HTTP Code: " . $response->status_line());
  112 + }
103 113 Irssi::print("Notification not posted: " . $response->content);
104 114 }
105 115 }
... ...