Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 54 lines (44 sloc) 1.63 kB
84079a1 @atoponce initial commit
authored
1 #!/usr/bin/python
2
3 import base64
4 import email.utils
5 import re
6 import smtplib
7 import yaml
8 import zmq
9 from email.mime.text import MIMEText
10
11 context = zmq.Context()
12 socket = context.socket(zmq.SUB)
13 socket.setsockopt(zmq.SUBSCRIBE, '')
14 socket.connect('tcp://127.0.0.1:2428')
15
16 while True:
17 f = open('/var/log/0mq.log','a')
18 msg = socket.recv()
19 msg = re.sub('\n:', '\n', msg)
20 msg = re.sub('^---| !binary \|-\n','',msg)
21 y = yaml.load(msg)
22
23 f.write(msg)
24 f.close()
25
0ec0ec8 @atoponce Fix day change bug
authored
26 # When day changes, the 'tags' value list will be empty. Ignore.
38b5594 @atoponce Fix logic for events that should not be sent
authored
27 if not y.values()[0]:
28 continue
0ec0ec8 @atoponce Fix day change bug
authored
29
30 # Format is:
31 # ['tags', 'away', 'server', 'date', 'highlight', 'message', 'type', 'channel']
32 # where 'tags' is another list of items.
33 server = base64.b64decode(y.values()[2])
34 channel = base64.b64decode(y.values()[7])
35 nick = base64.b64decode(y.values()[0][3])
36 nick = re.sub('^nick_','',nick)
37 message = base64.b64decode(y.values()[5])
84079a1 @atoponce initial commit
authored
38
fce9f08 @atoponce Add README with instructions. Make script changes.
authored
39 # If sending messages to the channel while away, it shows up as
40 # "prefix_nick_white". This can change it to your nick.
84079a1 @atoponce initial commit
authored
41 if nick == 'prefix_nick_white':
42 nick = 'eightyeight'
43
fce9f08 @atoponce Add README with instructions. Make script changes.
authored
44 # Change your email-to-sms address as provided by your mobile provider
45 fromaddr = 'weechat@irc.example.com'
46 toaddr = '1234567890@messaging.sprintpcs.com'
ca5534c @atoponce fix not needing date in sms
authored
47 msg = MIMEText("{0}/{1}: <{2}> {3}".format(server, channel, nick, message))
84079a1 @atoponce initial commit
authored
48 msg['To'] = email.utils.formataddr(('eightyeight', toaddr))
49 msg['From'] = email.utils.formataddr(('WeeChat', fromaddr))
50
51 s = smtplib.SMTP('localhost')
52 s.sendmail(fromaddr, [toaddr], msg.as_string())
53 s.quit()
Something went wrong with that request. Please try again.