root/lang/perl/irssi/scripts/hilight2im.pl

Revision 566, 0.9 kB (checked in by typester, 21 months ago)

perl/irssi/scripts: Added hilight2im script for irssi

Line 
1use strict;
2use warnings;
3
4use Irssi;
5use POSIX ();
6
7use LWP::UserAgent;
8use HTTP::Request::Common;
9
10our $VERSION = '0.1';
11
12our %IRSSI = (
13    name        => 'hilight2im',
14    description => 'notify hilight message to IM via im.kayac.com api',
15    authors     => 'Daisuke Murase',
16);
17
18sub sig_printtext {
19    my ($dest, $text, $stripped) = @_;
20
21    if ( $dest->{level} & MSGLEVEL_HILIGHT ) {
22        my $pid = fork;
23        if ($pid) {
24            Irssi::pidwait_add($pid);
25        }
26        elsif (defined $pid) {
27            my $user = Irssi::settings_get_str('im_kayac_com_username');
28            LWP::UserAgent->new->request( POST "http://im.kayac.com/api/post/$user", [ message => "[irssi] $stripped" ]);
29            POSIX::_exit(1);
30        }
31    }
32}
33Irssi::signal_add('print text' => \&sig_printtext);
34Irssi::settings_add_str('im_kayac_com', 'im_kayac_com_username', 'username');
Note: See TracBrowser for help on using the browser.