Last active
August 29, 2015 14:03
-
-
Save maurice-audin/8a11104216e904abdf74 to your computer and use it in GitHub Desktop.
Use IrssiNotifier with mcabber, "set events_command = ~/.mcabber.d/notifier.py"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
import sys | |
import string | |
import urllib | |
import urllib2 | |
import shlex | |
from subprocess import Popen, PIPE | |
encryption_password = "XXX" | |
API_TOKEN = "XXX" | |
def mcabber_notify(kind, direction, jid, message): | |
if kind == "MSG" and (direction == "IN" or direction == "MUC"): | |
show_notification(jid, jid, open(message).read()) | |
def encrypt(text): | |
command = "openssl enc -aes-128-cbc -salt -base64 -A -pass pass:%s" % \ | |
(encryption_password) | |
output, errors = Popen(shlex.split(command), stdin=PIPE, stdout=PIPE, | |
stderr=PIPE).communicate(text + " ") | |
output = string.replace(output, "/", "_") | |
output = string.replace(output, "+", "-") | |
output = string.replace(output, "=", "") | |
return output | |
def show_notification(chan, nick, message): | |
if API_TOKEN != "": | |
url = "https://irssinotifier.appspot.com/API/Message" | |
postdata = urllib.urlencode({'apiToken': API_TOKEN, | |
'nick': encrypt(nick), | |
'channel': encrypt(chan), | |
'message': encrypt(message), | |
'version': 13}) | |
u = urllib2.urlopen(url, postdata) | |
if __name__ == "__main__": | |
mcabber_notify(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment