
Untitled
By: a guest on
Aug 20th, 2012 | syntax:
None | size: 1.21 KB | hits: 9 | expires: Never
#!/home/mash/perl5/perlbrew/perls/perl-5.12.3/bin/perl
use strict;
use warnings;
use Irssi;
use Config::Pit;
use Furl;
use vars qw($VERSION %IRSSI);
$VERSION = "0.1";
%IRSSI = (
authors => 'Masakazu OHTSUKA (mash)',
name => 'hilight2nakamap',
description => 'forward hilighted messages to nakamap as shout',
url => 'http://maaash.jp/',
changed => '2011-09-08',
);
my $config = pit_get( 'nakamap', require => {
access_token => 'oauth2 access token',
group_uid => 'group to post your message to',
});
my $furl = Furl->new( agent => 'hilight2nakamap/1.0', timeout => 10 );
sub forward_to_nakamap {
my ( $dest, $text, $stripped ) = @_;
if ( $dest->{level} & MSGLEVEL_HILIGHT ) {
my $res = $furl->post( 'https://thanks.nakamap.com/1/group/' . $config->{ group_uid } . '/chats',
[ 'Content-Type' => 'application/x-www-form-urlencoded' ],
[ token => $config->{ access_token },
message => 'irc:'.$dest->{target}.' '.$stripped,
type => 'shout', ] );
}
}
Irssi::signal_add( 'print text' => \&forward_to_nakamap );