Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
44 lines (35 sloc) 1.12 KB
import base64
import email.utils
import re
import smtplib
import yaml
import zmq
from email.mime.text import MIMEText
context = zmq.Context()
socket = context.socket(zmq.SUB)
socket.setsockopt(zmq.SUBSCRIBE, '')
while True:
msg = socket.recv()
msg = re.sub('\n:', '\n', msg)
msg = re.sub('^---| !binary \|-\n','',msg)
y = yaml.load(msg)
f = open('/var/log/0mq.log','a')
# Ignore client events that aren't PUBLIC
if not y['tags'][3]:
nick = base64.b64decode(y['tags'][3])
nick = re.sub('^nick_','',nick)
message = base64.b64decode(y['message'])
# Change your email-to-sms address as provided by your mobile provider
fromaddr = ''
toaddr = ''
msg = MIMEText("{0}: {1}".format(nick, message))
msg['To'] = email.utils.formataddr(('eightyeight', toaddr))
msg['From'] = email.utils.formataddr(('WeeChat', fromaddr))
s = smtplib.SMTP('localhost')
s.sendmail(fromaddr, [toaddr], msg.as_string())
Something went wrong with that request. Please try again.