Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 49 lines (39 sloc) 1.307 kb
84079a1 Aaron Toponce initial commit
authored
1 #!/usr/bin/python
2
3 import base64
4 import email.utils
5 import re
6 import smtplib
7 import time
8 import yaml
9 import zmq
10 from email.mime.text import MIMEText
11
12 context = zmq.Context()
13 socket = context.socket(zmq.SUB)
14 socket.setsockopt(zmq.SUBSCRIBE, '')
15 socket.connect('tcp://127.0.0.1:2428')
16
17 while True:
18 f = open('/var/log/0mq.log','a')
19 msg = socket.recv()
20 msg = re.sub('\n:', '\n', msg)
21 msg = re.sub('^---| !binary \|-\n','',msg)
22 y = yaml.load(msg)
23
24 f.write(msg)
25 f.close()
26
27 nick = base64.b64decode(y.items()[0][1][3])
28 server = base64.b64decode(y.items()[2][1])
29 epoch = base64.b64decode(y.items()[3][1])
30 message = base64.b64decode(y.items()[5][1])
31 channel = base64.b64decode(y.items()[7][1])
32
33 nick = re.sub('^nick_','',nick)
34 if nick == 'prefix_nick_white':
35 nick = 'eightyeight'
36
37 mt = time.localtime(int(epoch))
38 d = time.strftime('%H:%M:%S', mt)
39
40 fromaddr = 'weechat@irc.ae7.st'
41 toaddr = '8019206031@messaging.sprintpcs.com'
42 msg = MIMEText("{0}/{1}: <{2}> {3}".format(d, server, channel, nick, message))
43 msg['To'] = email.utils.formataddr(('eightyeight', toaddr))
44 msg['From'] = email.utils.formataddr(('WeeChat', fromaddr))
45
46 s = smtplib.SMTP('localhost')
47 s.sendmail(fromaddr, [toaddr], msg.as_string())
48 s.quit()
Something went wrong with that request. Please try again.