irissi Prowl Script

An iPhone client for Growl available on the App Store.
Posts: 1
Joined: Wed Jul 08, 2009 10:20 pm

irissi Prowl Script

Postby ixtli » Wed Jul 08, 2009 10:47 pm

The following script will notify you when someone uses a hilight word or msg's you in irssi:

Code: Select all

# todo: grab topic changes

use strict;
use vars qw($VERSION %IRSSI);

#use lib '/System/Library/Perl/Extras/5.8.8';
use LWP::UserAgent;

use Irssi;
$VERSION = '0.0.3';
%IRSSI = (
   authors     => 'Thorsten Leemhuis',
   contact     => '',
   name        => 'fnotify',
   description => 'Write a notification to a file that shows who is talking to you in which channel.',
   url         => '',
   license     => 'GNU General Public License',
   changed     => '$Date: 2007-01-13 12:00:00 +0100 (Sat, 13 Jan 2007) $'

# In parts based on 0.1.1 by Hugo Haas
# which is based on 0.3.3 by Jeroen Coekaerts, Koenraad Heijlen
# Other parts based on from Luke Macken

# Private message parsing

sub priv_msg {
   my ($server,$msg,$nick,$address,$target) = @_;
   prowlNotification($server->{chatnet}, $nick, $msg);

# Printing hilight's

sub hilight {
   my ($dest, $text, $stripped) = @_;
   return if (!$dest->{server} || !($dest->{level} & MSGLEVEL_HILIGHT) );
   #change the following two lines to put the user's nick in $x[0]
   my @x = split(/>/,$stripped);
   my @y = split(/\|\s/, $x[0]);
   $x[0] = $y[1];
   prowlNotification($dest->{target},$x[0], $x[1]);


# The actual printing

sub filewrite {
   my ($text) = @_;
   # FIXME: there is probably a better way to get the irssi-dir...
   print FILE $text . "\n";
        close (FILE);

# post a prowl notification
sub prowlNotification {

   my ($app, $event, $not) = @_;
   my (%options) = ();
   $options{'application'} = $app;
   $options{'event'} = $event;
   $options{'notification'} = $not;
   $options{'priority'} = 0;
   $options{'apikey'} = "KEY";

   # URL encode our arguments
   $options{'application'} =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
   $options{'event'} =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
   $options{'notification'} =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;

   # Generate our HTTP request.
   my ($userAgent, $request, $response, $requestURL);
   $userAgent = LWP::UserAgent->new;

   $requestURL = sprintf("",
   $request = HTTP::Request->new(GET => $requestURL);

   $response = $userAgent->request($request);
   if( !$response->is_success) {
      print "ERROR: Notification not posted: ".$response->content;

# Irssi::signal_add_last / Irssi::command_bind

Irssi::signal_add_last("message private", "priv_msg");
Irssi::signal_add_last("print text", "hilight");

#- end

Save this script to ~/.irssi/scripts/
You must make sure that you have irssi built with perl. Try doing /load perl to make sure. If it doesnt work then do:

Code: Select all

port install irssi +perl.

Then, if you installed irssi using macports, do the following:

Code: Select all

sudo /opt/local/bin/perl -MCPAN -e 'install HTML::Parser'
sudo /opt/local/bin/perl -MCPAN -e 'install Crypt::SSLeay'
(Note that you have to have these two packages no matter how you installed perl/irssi, it's just that macports presents some interesting configuration difficulties when utilities overlap.)

Following that you must edit all of the lines marked with #changeme. It's not hard: the first one is a regexp that selects the user's name from the message that contained the hilighted word. I don't know how to make this automatic, since the handler is passed the full text of the line, and the formatting is different based on your theme. For reference, my lines look like this:

Code: Select all

19:21 | ag > I just use the default.
and the two "split" commands isolate "ag" and put it into $x[0]. The second required change is just to substitute your API key for "KEY" in the line:

Code: Select all

$options{'apikey'} = "KEY";

Then, in irssi do

Code: Select all

/script load fnotify

Return to “Prowl”

Who is online

Users browsing this forum: No registered users