Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Send a notification to Simplepush.io when you receive a new private message and are not attached to screen.
use strict;
use warnings;
use Irssi;
use vars qw($VERSION %IRSSI);
$VERSION = "1.0";
%IRSSI = (
authors => 'x70b1',
name => 'simplepush.pl',
description =>
'Send a notification to Simplepush.io when you receive a new private message and are not attached to screen.',
url => 'https://gist.github.com/x70b1/9ee8b1ce067e3d31d626f6a3af99955d',
changed => '2017-11-16',
);
my $username = "username";
my $silence = 30;
my $timestamp = time() - $silence;
sub simplepush {
my ( $title, $message ) = @_;
my $screen = system("screen -ls | grep -q Detached");
if ( !$screen ) {
if ( ( $timestamp + $silence ) < time() ) {
system("bash ~/.irssi/scripts/send-encrypted.sh -k xxxx -p xxxx -s xxxx -e irssi -t '$title' -m '$message'");
$timestamp = time();
} else {
$timestamp = time();
}
}
}
sub push_message {
my ( $server, $msg, $nick, $address, $target ) = @_;
simplepush( "$nick", "Ping!" );
}
sub push_mention {
my ( $server, $msg, $nick, $address, $target ) = @_;
if ( index( $msg, $username ) != -1 ) {
simplepush( "$target", "$nick: $msg" );
}
}
Irssi::signal_add_last( 'message private', 'push_message' );
Irssi::signal_add_last( 'message public', 'push_mention' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.