rconradharris / smart-irc-notifier

Send notifications to email/SMS or terminal-notifier depending on idle time

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

smart-irc-notifier

Notify you of IRC messages both locally and, when you're away from the keyboard, by push notifications to your phone.

The local notifications are generated by terminal-notifier and show up as standard OS X notifications.

The remote notifications can be sent to email or to Pushover. Using an email-to-SMS gateway, you can send SMS messages using the email plugin.

An advanced feature is the ability to reply directly from the device receiving the notification (e.g. your phone). This works by providing a link for you to click that directs to a web page where you can enter a reply.

Requirements

  • irssi
  • terminal-notifier (get from Homebrew)
  • GNU screen or tmux on the server (since server-irc-notifier needs to run persistently even when you logout)
  • Python's requests, flask, and gunicorn modules

Design

There are two notification modes, terminal-notifier and email/SMS.

terminal-notifier notifications are handled client-side by remotely tailing the fnotify log file.

Email/SMS notifications are handled server-side so that they will continue to work even when your laptop is closed.

So that you don't get Email/SMS notifications when you're active at your computer, client-side code runs on your laptop to update the server-side file with your current-idle time.

If the current-idle time exceeds the threshold OR the last-modified age of that file exceeds the threshold, then an email/SMS notification is generated.

The reply mechanism is composed of three parts:

  1. server-irc-notifier which appends a reply link to messages if enabled
  2. reply-webserver which provides a web form for the user to enter their reply into
  3. The reply.pl irssi script which converts the webform reply into an actual IRC message

Setup

Client-side

The client-side (e.g. your laptop), needs run client-irc-notifier. This script generates terminal-notifications and updates the server-side with your idle time so that it knows if it should send email/SMS notifications.

The recommended way of running client-irc-notifier is by using a LocalCommand post-hook in your ssh config, like so:

Host irc
    Hostname <YOUR-IRC-BOUNCER-HOST>
    User <YOUR-USERNAME>
    PermitLocalCommand yes
    LocalCommand ~/bin/client-irc-notifier start

Server-side

First you need to setup reply.pl. You can do this by copying the script which is in the scripts directory into .irssi/scripts. You can then create .irssi/scripts/autorun (if it doesn't exist) and add a symlink.

Next you need to run create a config file in .irssi/server-irc-notifier.cfg, use examples directory for help.

Finally, you need to copy server-irc-notifier script to the server (e.g. your IRC bouncer) and run it in a screen session.

Reply Setup

Setting up the reply mechanism is a bit tricky but you only need to do it once.

The first thing you need to do is run the run-reply-webserver process in another screen session on your IRC server. Make sure that both inbound and outbound HTTP traffic on port 5000 is allowed.

Add the reply_server config to the configuration file and make sure it is set to the public IP address of your IRC server.

Tips

If necessary, you can always override behavior to force IDLE or NOT IDLE. This is useful if you're going to be away and still don't want to receive SMS messages.

To force IDLE run:

client-irc-notifier away

To force NOT IDLE:

client-irc-notifier here

To leave force mode and return to automatic idle checking, run:

client-irc-notifier auto

About

Send notifications to email/SMS or terminal-notifier depending on idle time


Languages

Language:Python 53.8%Language:HTML 22.1%Language:Shell 9.2%Language:Perl 7.8%Language:JavaScript 5.0%Language:CSS 2.1%