#!/usr/bin/env perl -w # sends growlnotify on irssi messages use strict; use vars qw($VERSION %IRSSI $Notes $AppName); use Irssi; use Mac::Growl; $VERSION = '0.01'; %IRSSI = ( authors => '31d1', contact => '31d1@31d1.com', name => 'grrowl', description => 'Sends out Growl notifications for Irssi', license => 'BSD', url => 'http://growl.info/', ); $Notes = ["Script message", "Message notification"]; $AppName = "irssi"; Mac::Growl::RegisterNotifications($AppName, $Notes, $Notes); my $s = my $t = "off"; sub cmd_help () { Irssi::print($IRSSI{name}.': growl notify on messages.'); Irssi::print('>> status: pub'.$s.' pvt'.$t); Irssi::print('>> /grpub to toggle public.'); Irssi::print('>> /grpvt to toggle private.'); } sub cmd_toggle_pub () { if( $s eq "on" ) { $s = "off"; } else { $s = "on"; } Mac::Growl::PostNotification($AppName, "Message notification", "/grpub $s", ""); Irssi::print($IRSSI{name}.' pub: '.$s); } sub cmd_toggle_pvt () { if( $t eq "on" ) { $t = "off"; } else { $t = "on"; } Mac::Growl::PostNotification($AppName, "Message notification", "/grpvt $t", ""); Irssi::print($IRSSI{name}.' pvt: '.$t); } sub message_public () { return unless ( $s eq "on" ); my ($server, $data, $nick, $address, $chan) = @_; Mac::Growl::PostNotification($AppName, "Message notification", "$nick @ $chan ", "$data"); } sub message_private () { return unless ( $t eq "on" ); my ($server, $data, $nick, $address) = @_; Mac::Growl::PostNotification($AppName, "Message notification", "PM: $nick", "$data"); } Irssi::command_bind('gr', \&cmd_help); Irssi::command_bind('grpub', \&cmd_toggle_pub); Irssi::command_bind('grpvt', \&cmd_toggle_pvt); Irssi::signal_add_last('message public', \&message_public); Irssi::signal_add_last('message private', \&message_private); Irssi::print($IRSSI{name}.' '.$VERSION.' loaded (/gr for info)');