I programmed this irssi script for Prowl a year back or so, been using it ever since. It sends all your PMs and hilights on IRC as push notifications to your iPhone, using the Prowl API. Today I patched it, and I also made a version for Boxcar and Howl, since Boxcar is free and probably has a lot more users and Howl is preferred by some users. I figured it was about time I published them, because I haven't seen any scripts with the same features, at least not for Prowl. For Boxcar I haven't seen any script like this at all and same goes for Howl, so I figured there might be at least some nerds interested in this! Later on I will also publish PSC, which stands for "Prowl Server Checker", basically it's a combination of MySQL, Crontab, Python and PHP to send warnings to your iPhone if a server would go down. But I'll talk more about that in the next article. These three scripts only sends notifications when you're away. It's great to combine with autoaway.pl. First off, let's start with prowl.pl.
Okay ,so this is the script for prowl, nothing big really, very basic. It has settings for the API key, priority, "general highlight"(All highlights) etc. Nothing big really, in fact, the description header of the source code will probably tell you more. just remember to set your prowl API key before using it, otherwise it'll be useless. You can download it here and the source is below.
1. use strict; 2. use warnings; 3. 4. ##################################################################### 5. # This script sends notifications to your 6. # iPhone using the prowl API when you are away. 7. # 8. # This script is loosely based on Denis Lemire's 9. # script, you can find his page on: http://www.denis.lemire.name/ 10. # 11. # This script have some major differences in both code and usage 12. # from his script. The configuration he uses *won't* work with 13. # this script. 14. # 15. # Commands: 16. # /set prowl_api_key API_KEY 17. # /set prowl_general_hilight on/off 18. # /set prowl_priority_channel -2 up to 2 19. # /set prowl_priority_pm -2 up to 2 20. # /set prowl_priority_general -2 up to 2 21. # 22. # "General hilight" basically referrs to ALL the hilights you have 23. # added manually in irssi, if many, it can get really bloated if 24. # turned on. Default is Off. 25. # 26. # You will need the following packages: 27. # LWP::UserAgent (You can install this using cpan -i LWP::UserAgent) 28. # Crypt::SSLeay (You can install this using cpan -i Crypt::SSLeay) 29. # 30. # Or if you're using Debian GNU/Linux: 31. # apt-get update;apt-get install libwww-perl libcrypt-ssleay-perl 32. # 33. # 34. # eth0 will prevail. || irc.eth0.info 35. # 36. ##################################################################### 37. 38. 39. use Irssi; 40. use Irssi::Irc; 41. use vars qw($VERSION %IRSSI); 42. 43. use LWP::UserAgent; 44. 45. $VERSION = "0.4"; 46. 47. %IRSSI = ( 48. authors => "Caesar 'sniker' Ahlenhed", 49. contact => "sniker\@se.linux.org", 50. name => "prowl", 51. description => "Sends prowlnotifcations when away", 52. license => "GPLv2", 53. url => "http://sniker.codebase.nu", 54. changed => "Mon Mar 15 18:53:32 CET 2010", 55. ); 56. 57. # Configuration settings and default values. 58. Irssi::settings_add_str("prowl", "prowl_api_key", ""); 59. Irssi::settings_add_bool("prowl", "prowl_general_hilight", 0); 60. Irssi::settings_add_str("prowl", "prowl_priority_channel", 0); 61. Irssi::settings_add_str("prowl", "prowl_priority_pm", 0); 62. Irssi::settings_add_str("prowl", "prowl_priority_general", 0); 63. 64. # The whole "send_noti" function is pretty much taken from the prowl example script. 65. sub send_noti { 66. my ($event, $text, $priority) = @_; 67. 68. my %options = (); 69. 70. $options{'application'} ||= "Irssi"; 71. $options{'event'} = $event; 72. $options{'notification'} = $text; 73. $options{'priority'} = $priority; 74. 75. 76. # This check isn't really needed, just added if someone would 77. # would define $options{'apikey'} manually in the script. 78. if(!exists($options{'apikey'})){ 79. $options{'apikey'} = Irssi::settings_get_str("prowl_api_key"); 80. chomp $options{'apikey'}; 81. }else{ 82. Irssi::print("There is some kind of trouble with the API key."); 83. } 84. 85. $options{'application'} =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg; 86. $options{'event'} =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg; 87. $options{'notification'} =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg; 88. 89. my ($userAgent, $request, $response, $requestURL); 90. $userAgent = LWP::UserAgent->new; 91. $userAgent->agent("ProwlScript/1.0"); 92. 93. $requestURL = sprintf("https://prowl.weks.net/publicapi/add?apikey=%s&application=%s&event=%s&description=%s&priority=%d", 94. $options{'apikey'}, 95. $options{'application'}, 96. $options{'event'}, 97. $options{'notification'}, 98. $options{'priority'}); 99. 100. $request = HTTP::Request->new(GET => $requestURL); 101. $response = $userAgent->request($request); 102. 103. if ($response->is_success) { 104. # I guess it worked, eh? 105. } elsif ($response->code == 401) { 106. Irssi::print( "Notification not posted: incorrect API key."); 107. } else { 108. Irssi::print("Notification not posted: " . $response->content); 109. } 110. } 111. 112. sub pubmsg { 113. my ($server, $data, $nick) = @_; 114. 115. if($server->{usermode_away} == 1 && $data =~ /$server->{nick}/i){ 116. send_noti("Hilighted", $nick . ': ' . $data, Irssi::settings_get_str("prowl_priority_channel")); 117. } 118. } 119. 120. sub privmsg { 121. my ($server, $data, $nick) = @_; 122. if($server->{usermode_away} == 1){ 123. send_noti("PM", $nick . ': ' . $data, Irssi::settings_get_str("prowl_priority_pm")); 124. } 125. } 126. 127. sub genhilight { 128. my($dest, $text, $stripped) = @_; 129. my $server = $dest->{server}; 130. 131. if($dest->{level} & MSGLEVEL_HILIGHT) { 132. if($server->{usermode_away} == 1){ 133. if(Irssi::settings_get_bool("prowl_general_hilight")){ 134. send_noti("General Hilight", $stripped, Irssi::settings_get_str("prowl_priority_general")); 135. } 136. } 137. } 138. } 139. 140. Irssi::signal_add_last('message public', 'pubmsg'); 141. Irssi::signal_add_last('message private', 'privmsg'); 142. Irssi::signal_add_last('print text', 'genhilight');
This is the boxcar version of the script. I would really encourage you to get Prowl and the Prowl version, since prowl supports priority and a lot of other nice features, PSC which I talked about earlier isn't even ported to Boxcar simply because Boxcar lacks priority features which makes it useless for such things as server status notifications and such. This script is basically the same as Prowl, just that the Boxcar API is used instead of Prowl API(Obviously...) and it uses email and password to authenticate against the API, while Prowl simply uses a key, which is a superior solution in my opinion. Just remember to set your email and password, otherwise it'll be useless. You can download the script here end the source is below.
1. use strict; 2. use warnings; 3. 4. ##################################################################### 5. # This script sends notifications to your 6. # iPhone using your boxcar email and password when you are away. 7. # 8. # Originally I made this script for Prowl, but since people tend to 9. # be cheap and rather use boxcar(which is not as good) I ported it 10. # to boxcar. Boxcar lacks features such as priority. 11. # 12. # Commands: 13. # /set boxcar_email something@example.com 14. # /set boxcar_password password 15. # /set boxcar_general_hilight on/off 16. # 17. # "General hilight" basically referrs to ALL the hilights you have 18. # added manually in irssi, if many, it can get really bloated if 19. # turned on. Default is Off. 20. # 21. # You will need the following packages: 22. # LWP::UserAgent (You can install this using cpan -i LWP::UserAgent) 23. # Crypt::SSLeay (You can install this using cpan -i Crypt::SSLeay) 24. # 25. # Or if you're using Debian GNU/Linux: 26. # apt-get update;apt-get install libwww-perl libcrypt-ssleay-perl 27. # 28. # 29. # eth0 will prevail. || irc.eth0.info 30. # 31. ##################################################################### 32. 33. 34. use Irssi; 35. use Irssi::Irc; 36. use vars qw($VERSION %IRSSI); 37. use LWP::UserAgent; 38. use HTTP::Request::Common; 39. 40. $VERSION = "0.1"; 41. 42. %IRSSI = ( 43. authors => "Caesar 'sniker' Ahlenhed", 44. contact => "sniker\@se.linux.org", 45. name => "boxcarirssi", 46. description => "Sends notifcations when away", 47. license => "GPLv2", 48. url => "http://sniker.codebase.nu", 49. changed => "Sat Feb 12 23:56:32 CET 2011", 50. ); 51. 52. # Configuration settings and default values. 53. Irssi::settings_add_str("boxcarirssi", "boxcarirssi_email", ""); 54. Irssi::settings_add_str("boxcarirssi", "boxcarirssi_password", ""); 55. Irssi::settings_add_bool("boxcarirssi", "boxcarirssi_general_hilight", 0); 56. 57. sub send_noti { 58. my ($text) = @_; 59. 60. my %options = (); 61. 62. $options{'application'} ||= "Irssi"; 63. $options{'notification'} = $text; 64. 65. my ($userAgent, $req, $response); 66. $userAgent = LWP::UserAgent->new; 67. $userAgent->agent("BoxcarIrssi/1.0"); 68. 69. $req = HTTP::Request->new(POST => "https://boxcar.io/notifications"); 70. $req->content("notification[from_screen_name]=" . $options{'application'} . "¬ification[message]=" . $options{'notification'}); 71. $req->authorization_basic(Irssi::settings_get_str("boxcarirssi_email") => Irssi::settings_get_str("boxcarirssi_password")); 72. 73. $response = $userAgent->request($req); 74. 75. if ($response->is_success) { 76. # I guess it worked, eh? 77. } else { 78. Irssi::print("Notification not posted: " . $response->content); 79. } 80. } 81. 82. sub pubmsg { 83. my ($server, $data, $nick) = @_; 84. 85. if($server->{usermode_away} == 1 && $data =~ /$server->{nick}/i){ 86. send_noti("Hilighted - " . $nick . ': ' . $data); 87. } 88. } 89. 90. sub privmsg { 91. my ($server, $data, $nick) = @_; 92. if($server->{usermode_away} == 1){ 93. send_noti("PM - " . $nick . ': ' . $data); 94. } 95. } 96. 97. sub genhilight { 98. my($dest, $text, $stripped) = @_; 99. my $server = $dest->{server}; 100. 101. if($dest->{level} & MSGLEVEL_HILIGHT) { 102. if($server->{usermode_away} == 1){ 103. if(Irssi::settings_get_bool("boxcarirssi_general_hilight")){ 104. send_noti("General Hilight - " . $stripped); 105. } 106. } 107. } 108. } 109. 110. Irssi::signal_add_last('message public', 'pubmsg'); 111. Irssi::signal_add_last('message private', 'privmsg'); 112. Irssi::signal_add_last('print text', 'genhilight');
I noticed that Howl had an API for their app as well, so I figured, since I already made a script for Prowl and Boxcar, why not port it to Howl as well? It was just a matter of changing a few lines. The howl version supports priority just like Prowl, however, while testing, I didn't notice any difference what so ever between the different stages of priority, no difference in sound, no difference in look, no difference in anything. But I still left those options in the script, in case it was me who missed it. The Howl version also have a "Hostname" option, basically, it's used for sorting within Howl, it can be set to whatever, default value is "shell.server.com", you should probably change it to the IP/Hostname of the server you're running Irssi on. Be sure to set the username and password as well inside irssi, otherwise this script is worthless. And one last thing, to be able to use the Howl API you need an email address associated with your account, when you register it says email is optional, but be sure to enter one, otherwise you won't be able to use the API until you've mailed the developers and asked them to add one manually, don't make the same mistake I did. You can download it here. Source below.
1. use strict; 2. use warnings; 3. 4. ##################################################################### 5. # This script sends notifications to your 6. # iPhone using the Howl API when you are away. 7. # 8. # 9. # Commands: 10. # /set irssihowl_username USERNAME (Default NULL) 11. # /set irssihowl_password PASSWORD (Default NULL) 12. # /set irssihowl_general_hilight on/off (Default OFF) 13. # /set irssihowl_priority_channel -5 up to 5 (Default 0) 14. # /set irssihowl_priority_pm -5 up to 5 (Default 0) 15. # /set irssihowl_priority_general -5 up to 5 (Default 0) 16. # /set irssihowl_hostname HOSTNAME_OF_THE_SERVER (Default shell.server.com) 17. # 18. # "General hilight" basically referrs to ALL the hilights you have 19. # added manually in irssi, if many, it can get really bloated if 20. # turned on. Default is Off. 21. # 22. # You will need the following packages: 23. # LWP::UserAgent (You can install this using cpan -i LWP::UserAgent) 24. # Crypt::SSLeay (You can install this using cpan -i Crypt::SSLeay) 25. # 26. # Or if you're using Debian GNU/Linux: 27. # apt-get update;apt-get install libwww-perl libcrypt-ssleay-perl 28. # 29. # 30. # eth0 will prevail. || irc.eth0.info 31. # 32. ##################################################################### 33. 34. 35. use Irssi; 36. use Irssi::Irc; 37. use vars qw($VERSION %IRSSI); 38. 39. use LWP::UserAgent; 40. use HTTP::Request::Common; 41. 42. $VERSION = "0.1"; 43. 44. %IRSSI = ( 45. authors => "Caesar 'sniker' Ahlenhed", 46. contact => "sniker\@se.linux.org", 47. name => "irssihowl", 48. description => "Sends howlnotifications when away", 49. license => "GPLv2", 50. url => "http://sniker.codebase.nu", 51. changed => "Mon Feb 15 17:38:32 CET 2010", 52. ); 53. 54. # Configuration settings and default values. 55. Irssi::settings_add_bool("irssihowl", "irssihowl_general_hilight", 0); 56. Irssi::settings_add_str("irssihowl", "irssihowl_priority_channel", 0); 57. Irssi::settings_add_str("irssihowl", "irssihowl_priority_pm", 0); 58. Irssi::settings_add_str("irssihowl", "irssihowl_priority_general", 0); 59. Irssi::settings_add_str("irssihowl", "irssihowl_username", ""); 60. Irssi::settings_add_str("irssihowl", "irssihowl_password", ""); 61. Irssi::settings_add_str("irssihowl", "irssihowl_hostname", "shell.server.com"); # Set to a default value because I can't be arsed to actually look up the ip. 62. 63. sub send_noti { 64. my ($title, $text, $priority, $name) = @_; 65. 66. my %options = (); 67. 68. $options{'application'} ||= "Irssi"; 69. $options{'title'} = $title; 70. $options{'notification'} = $text; 71. $options{'priority'} = $priority; 72. $options{'name'} = $name; 73. 74. my ($userAgent, $req, $response); 75. $userAgent = LWP::UserAgent->new; 76. $userAgent->agent("irssihowl/1.0"); 77. 78. $req = HTTP::Request->new(POST => "https://howlapp.com/public/api/notification"); 79. $req->content("application=" . $options{'application'} . 80. "&name=" . $options{'name'} . 81. "&description=" . $options{'notification'} . 82. "&title= " . $options{'title'} . 83. "&priority=" . $options{'priority'} . 84. "&icon-name=console" . 85. "&hostname=" . Irssi::settings_get_str("irssihowl_hostname")); 86. $req->authorization_basic(Irssi::settings_get_str("irssihowl_username") => Irssi::settings_get_str("irssihowl_password")); 87. 88. $response = $userAgent->request($req); 89. 90. if ($response->is_success) { 91. # I guess it worked, eh? 92. } else { 93. Irssi::print("Notification not posted: " . $response->content); 94. } 95. } 96. 97. sub pubmsg { 98. my ($server, $data, $nick) = @_; 99. 100. if($server->{usermode_away} == 1 && $data =~ /$server->{nick}/i){ 101. send_noti("Hilighted", $nick . ': ' . $data, Irssi::settings_get_str("irssihowl_priority_channel"), "Irssi_Hilight"); 102. } 103. } 104. 105. sub privmsg { 106. my ($server, $data, $nick) = @_; 107. if($server->{usermode_away} == 1){ 108. send_noti("PM", $nick . ': ' . $data, Irssi::settings_get_str("irssihowl_priority_pm"), "Irssi_PM"); 109. } 110. } 111. 112. sub genhilight { 113. my($dest, $text, $stripped) = @_; 114. my $server = $dest->{server}; 115. 116. if($dest->{level} & MSGLEVEL_HILIGHT) { 117. if($server->{usermode_away} == 1){ 118. if(Irssi::settings_get_bool("irssihowl_general_hilight")){ 119. send_noti("General Hilight", $stripped, Irssi::settings_get_str("irssihowl_priority_general"), "Irssi_General_Hilight"); 120. } 121. } 122. } 123. } 124. 125. Irssi::signal_add_last('message public', 'pubmsg'); 126. Irssi::signal_add_last('message private', 'privmsg'); 127. Irssi::signal_add_last('print text', 'genhilight');
So I finally found a similar application for Android. However, Notifo is available for both iPhone and Android, so this script will work for both. It's the same API. You can download the script here, and as usual, the source can be found below.
1. use strict; 2. use warnings; 3. 4. ##################################################################### 5. # This script sends notifications to your 6. # iPhone using the Notifo API when you are away. 7. # 8. # 9. # Commands: 10. # /set irssinotifo_username USERNAME (Default NULL) 11. # /set irssinotifo_API API_KEY (Default NULL) 12. # /set irssinotifo_general_hilight on/off (Default OFF) 13. # 14. # "General hilight" basically referrs to ALL the hilights you have 15. # added manually in irssi, if many, it can get really bloated if 16. # turned on. Default is Off. 17. # 18. # You will need the following packages: 19. # LWP::UserAgent (You can install this using cpan -i LWP::UserAgent) 20. # Crypt::SSLeay (You can install this using cpan -i Crypt::SSLeay) 21. # 22. # Or if you're using Debian GNU/Linux: 23. # apt-get update;apt-get install libwww-perl libcrypt-ssleay-perl 24. # 25. # 26. # eth0 will prevail. || irc.eth0.info 27. # 28. ##################################################################### 29. 30. 31. use Irssi; 32. use Irssi::Irc; 33. use vars qw($VERSION %IRSSI); 34. 35. use LWP::UserAgent; 36. use HTTP::Request::Common; 37. use URI::Escape 38. 39. $VERSION = "0.1"; 40. 41. %IRSSI = ( 42. authors => "Caesar 'sniker' Ahlenhed", 43. contact => "sniker\@se.linux.org", 44. name => "irssinotifo", 45. description => "Sends notifonotifications when away (iOS AND ANDROID)", 46. license => "GPLv2", 47. url => "http://sniker.codebase.nu", 48. changed => "Mon Mar 17 23:59:32 CET 2011", 49. ); 50. 51. # Configuration settings and default values. 52. Irssi::settings_add_bool("irssinotifo", "irssinotifo_general_hilight", 0); 53. Irssi::settings_add_str("irssinotifo", "irssinotifo_username", ""); 54. Irssi::settings_add_str("irssinotifo", "irssinotifo_API", ""); 55. 56. sub send_noti { 57. my ($title, $text) = @_; 58. 59. my %options = (); 60. 61. $options{'label'} ||= "Irssi"; 62. $options{'title'} = $title; 63. $options{'msg'} = uri_escape($text); 64. 65. my ($userAgent, $req, $response); 66. $userAgent = LWP::UserAgent->new; 67. $userAgent->agent("irssinotifo/1.0"); 68. 69. $req = POST("https://api.notifo.com/v1/send_notification", 70. [ 71. label => $options{'label'}, 72. msg => $options{'msg'}, 73. title => $options{'title'}, 74. ] 75. ); 76. $req->authorization_basic(Irssi::settings_get_str("irssinotifo_username") => Irssi::settings_get_str("irssinotifo_API")); 77. 78. $response = $userAgent->request($req); 79. 80. if ($response->is_success) { 81. # I guess it worked, eh? 82. } else { 83. Irssi::print("Notification not posted: " . $response->content); 84. } 85. } 86. 87. sub pubmsg { 88. my ($server, $data, $nick) = @_; 89. 90. if($server->{usermode_away} == 1 && $data =~ /$server->{nick}/i){ 91. send_noti("Hilighted", $nick . ': ' . $data); 92. } 93. } 94. 95. sub privmsg { 96. my ($server, $data, $nick) = @_; 97. if($server->{usermode_away} == 1){ 98. send_noti("PM", $nick . ': ' . $data); 99. } 100. } 101. 102. sub genhilight { 103. my($dest, $text, $stripped) = @_; 104. my $server = $dest->{server}; 105. 106. if($dest->{level} & MSGLEVEL_HILIGHT) { 107. if($server->{usermode_away} == 1){ 108. if(Irssi::settings_get_bool("irssinotifo_general_hilight")){ 109. send_noti("General Hilight", $stripped); 110. } 111. } 112. } 113. } 114. 115. Irssi::signal_add_last('message public', 'pubmsg'); 116. Irssi::signal_add_last('message private', 'privmsg'); 117. Irssi::signal_add_last('print text', 'genhilight');
If you get the following error
-!- Irssi: Notification not posted: 500 Can't locate object method "new" via package "LWP::Protocol::https::Socket"
It means that the package libcrypt-ssleay-perl/Crypt::SSLeay isn't installed. However, if you're sure that package is installed, restart Irssi. For some reason, you sometimes have to restart Irssi before it works, I had to.
I assume anyone who reads this article knows how to install a script for Irssi. So I won't go over that. But if anyone who reads this know of any application similar to Prowl and Boxcar for Android, I'd love to hear about it. I want to make a script like these for Android as well. I've found such an app, it's called Notifo, thanks to xintron. However, if you know anything better, don't hesitate to comment below. I assume you've already seen the source for Notifo since you're reading this.
sniker[at]codebase[dot]nu
Updated Fri, 18 Mar 2011 16:24:56 +0100