Commit cdc55294f9da30dd0221ee036e6bf0239a292e7b

Authored by Caesar Ahlenhed
1 parent 6d12f6ae

v0.2

Showing 1 changed file with 18 additions and 11 deletions   Show diff stats
irssiNMA.pl
... ... @@ -12,6 +12,10 @@ use warnings;
12 12 # /set nma_priority_channel -2 up to 2
13 13 # /set nma_priority_pm -2 up to 2
14 14 # /set nma_priority_general -2 up to 2
  15 +# /set prowl_ignore_nettag NETWORKS # Networks in this case is a
  16 +# comma separated list of
  17 +# network tags that should
  18 +# be ignored.
15 19 #
16 20 # "General hilight" basically referrs to ALL the hilights you have
17 21 # added manually in irssi, if many, it can get really bloated if
... ... @@ -39,16 +43,16 @@ use vars qw($VERSION %IRSSI);
39 43 use LWP::UserAgent;
40 44 use HTTP::Request::Common;
41 45  
42   -$VERSION = "0.1";
  46 +$VERSION = "0.2";
43 47  
44 48 %IRSSI = (
45 49 authors => "Caesar 'sniker' Ahlenhed",
46   - contact => "sniker\@se.linux.org",
  50 + contact => "sniker\@codebase.nu",
47 51 name => "irssiNMA",
48 52 description => "Sends notifonotifications when away",
49 53 license => "GPLv2",
50 54 url => "http://sniker.codebase.nu",
51   - changed => "Mon Mar 12 12:33:32 CET 2012",
  55 + changed => "Mon Jun 23 18:13:25 CEST 2014",
52 56 );
53 57  
54 58 # Configuration settings and default values.
... ... @@ -57,6 +61,7 @@ Irssi::settings_add_bool("irssiNMA", "nma_general_hilight", 0);
57 61 Irssi::settings_add_str("irssiNMA", "nma_priority_channel", 0);
58 62 Irssi::settings_add_str("irssiNMA", "nma_priority_pm", 0);
59 63 Irssi::settings_add_str("irssiNMA", "nma_priority_general", 0);
  64 +Irssi::settings_add_str("irssiNMA", "nma_ignore_nettag", "");
60 65  
61 66 sub send_noti {
62 67 my ($title, $text, $priority) = @_;
... ... @@ -77,7 +82,7 @@ sub send_noti {
77 82  
78 83 my ($userAgent, $req, $response);
79 84 $userAgent = LWP::UserAgent->new;
80   - $userAgent->agent("irssiNMA/0.1");
  85 + $userAgent->agent("irssiNMA/0.2");
81 86  
82 87 $req = POST("https://www.notifymyandroid.com/publicapi/notify",
83 88 [
... ... @@ -99,17 +104,19 @@ sub send_noti {
99 104 }
100 105  
101 106 sub pubmsg {
102   - my ($server, $data, $nick) = @_;
  107 + my ($server, $data, $nick, $nick_addr, $target) = @_;
103 108  
104   - if($server->{usermode_away} == 1 && $data =~ /$server->{nick}/i){
105   - send_noti("Hilighted", $nick . ': ' . $data, Irssi::settings_get_str("nma_priority_channel"));
  109 + if(!Irssi::settings_get_bool("nma_general_hilight")){
  110 + if($server->{usermode_away} == 1 && $data =~ /$server->{nick}/i && index(Irssi::settings_get_str("nma_ignore_nettag"), $server->{tag}) == -1){
  111 + send_noti("Hilighted" . $server->{tag} . "/" . $target, $nick . ': ' . $data, Irssi::settings_get_str("nma_priority_channel"));
  112 + }
106 113 }
107 114 }
108 115  
109 116 sub privmsg {
110 117 my ($server, $data, $nick) = @_;
111   - if($server->{usermode_away} == 1){
112   - send_noti("PM", $nick . ': ' . $data, Irssi::settings_get_str("nma_priority_pm"));
  118 + if($server->{usermode_away} == 1 && index(Irssi::settings_get_str("nma_ignore_nettag"), $server->{tag}) == -1){
  119 + send_noti("PM @ " . $server->{tag}, $nick . ': ' . $data, Irssi::settings_get_str("nma_priority_pm"));
113 120 }
114 121 }
115 122  
... ... @@ -118,9 +125,9 @@ sub genhilight {
118 125 my $server = $dest->{server};
119 126  
120 127 if($dest->{level} & MSGLEVEL_HILIGHT) {
121   - if($server->{usermode_away} == 1){
  128 + if($server->{usermode_away} == 1 && index(Irssi::settings_get_str("nma_ignore_nettag"), $server->{tag}) == -1){
122 129 if(Irssi::settings_get_bool("nma_general_hilight")){
123   - send_noti("General Hilight", $stripped, Irssi::settings_get_str("nma_priority_general"));
  130 + send_noti("General Hilight" . $server->{tag} . "/" . $dest->{target}, $stripped, Irssi::settings_get_str("nma_priority_general"));
124 131 }
125 132 }
126 133 }
... ...