Skip to content
Browse files

Remove unnecessary code and format

Move f.open() with the rest of the file operations- it was driving me nuts.
Also, remove 'server' and 'channel' information. I likely already know what
server/channel they are in, and if not, can find the message easily enough
when getting back to my client.
  • Loading branch information...
1 parent b7a8a24 commit 2dab3d3662b6b64cf7e2a1b0eac4de2f3a535191 @atoponce committed Sep 3, 2012
Showing with 2 additions and 9 deletions.
  1. +2 −9 email-0mq.py
View
11 email-0mq.py
@@ -14,34 +14,27 @@
socket.connect('tcp://127.0.0.1:2428')
while True:
- f = open('/var/log/0mq.log','a')
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')
f.write(msg)
f.close()
# Ignore client events that aren't PUBLIC
if not y['tags'][3]:
continue
- server = base64.b64decode(y['server'])
- channel = base64.b64decode(y['channel'])
nick = base64.b64decode(y['tags'][3])
nick = re.sub('^nick_','',nick)
message = base64.b64decode(y['message'])
- # If sending messages to the channel while away, it shows up as
- # "prefix_nick_white". This can change it to your nick.
- if nick == 'prefix_nick_white':
- nick = 'eightyeight'
-
# Change your email-to-sms address as provided by your mobile provider
fromaddr = 'weechat@irc.example.com'
toaddr = '1234567890@messaging.sprintpcs.com'
- msg = MIMEText("{0}/{1}: <{2}> {3}".format(server, channel, nick, message))
+ msg = MIMEText("<{0}> {1}".format(nick, message))
msg['To'] = email.utils.formataddr(('eightyeight', toaddr))
msg['From'] = email.utils.formataddr(('WeeChat', fromaddr))

0 comments on commit 2dab3d3

Please sign in to comment.
Something went wrong with that request. Please try again.