Skip to content

Instantly share code, notes, and snippets.

@fser
Created January 3, 2015 16:32
Show Gist options
  • Save fser/4f5416ae1cfb9ac36b6e to your computer and use it in GitHub Desktop.
Save fser/4f5416ae1cfb9ac36b6e to your computer and use it in GitHub Desktop.
Inspired from hilight.pl for IRSSI, should strip it though.
# Print hilighted messages & private messages to window named "hilight"
# for irssi 0.7.99 by Timo Sirainen
use Irssi;
use URI;
use LWP;
use vars qw($VERSION %IRSSI);
$VERSION = "0.01";
$last_notif = 0;
$NOTIF_DELAY = 30;
# To be changed
%IRSSI = (
authors => "Timo \'cras\' Sirainen",
contact => "tss\@iki.fi",
name => "hilightwin",
description => "Print hilighted messages & private messages to window named \"hilight\"",
license => "Public Domain",
url => "http://irssi.org/",
changed => "2002-03-04T22:47+0100"
);
sub notify_android
{
my ($text) = @_;
my $url = URI->new('https://api.pushover.net/1/messages.json');
my $browser = LWP::UserAgent->new;
$browser->post($url,
[
'user' => 'je sais jamais qui est qui',
'token' => 'je sais jamais qui est qui',
'message' => $text
]
);
}
sub sig_printtext {
my ($dest, $text, $stripped) = @_;
my $server = $dest->{server};
# change to (MSGLEVEL_HILIGHT|MSGLEVEL_MSGS) to work for
# all privmsgs too
if (($dest->{level} & (MSGLEVEL_HILIGHT)) &&
($dest->{level} & MSGLEVEL_NOHILIGHT) == 0) {
if ($dest->{level} & MSGLEVEL_PUBLIC) {
$text = $dest->{target}.": ".$text;
}
$text =~ s/%/%%/g;
if ($server->{usermode_away}) {
my $now = time();
if(($now - $last_notif) > $NOTIF_DELAY)
{
notify_android $stripped;
$last_notif = $now;
}
}
}
}
Irssi::signal_add('print text', 'sig_printtext');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment