Reddit Notifications

Check your Reddit messages in your status bar!

Image preview of Reddit Notifications plugin.

redditnotify.30s.py

Edit
Open on GitHub
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# <xbar.title>Reddit Notifications</xbar.title>
# <xbar.version>v1.0.0</xbar.version>
# <xbar.author>HeyItsShuga</xbar.author>
# <xbar.author.github>Shugabuga</xbar.author.github>
# <xbar.desc>Check your Reddit messages in your status bar!</xbar.desc>
# <xbar.image>http://i.imgur.com/ohM8E6u.png</xbar.image>
# <xbar.dependencies>python,praw</xbar.dependencies>

############################################################################
#                      Reddit Notifications for BitBar                     #
#                            by /u/HeyItsShuga                             #
#                                                                          #
#                              Configuration                               #
#  Tip: Make sure that the quotes stay as real quotes (if using TextEdit). #
############################################################################

USERNAME = "" # Please put your username inside of the quotes.
PASSWORD = "" # Please put your password inside of the quotes.

############################################################################
#                        End Configuration. Enjoy!                         #
############################################################################

import os
import praw

if USERNAME == '':
    print "Not Configured! | color=#e51b1b"
    print "---"
    print "Click here to open the config in nano. | color=#e51b1b bash=' nano", __file__, '"'
    os.system("open " + __file__)

message_noteInt = "No Messages!"
messageCount = 0

r = praw.Reddit(user_agent="Reddit Notifications for BitBar",disable_update_check=True)
r.login(USERNAME, PASSWORD, disable_warning=True)

unreadInt = r.get_unread()
unread = r.get_unread()

for messages in unreadInt:
    message_noteInt = str(messages)
    messageCount = messageCount + 1

if message_noteInt == "No Messages!":
    print "| image=iVBORw0KGgoAAAANSUhEUgAAABkAAAAQCAMAAADUOCSZAAAAA3NCSVQICAjb4U/gAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAJ9QTFRFAAAAAAAAgICAgICAbW1tgICAeHh4gICAgICAfHx8fHx8fX19fX19e3t7fX19fHx8fn5+fHx8fn5+fHx8fn5+fn5+fHx8fX19fn5+fX19fHx8fn5+fX19fn5+fX19fX19fX19fX19fX19fX19fX19fn5+fn5+fX19fX19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k2wQAAAABJRU5ErkJggg=="

print "---"
print "Messages: ", messageCount, "| font=HelveticaNeue-Bold href=https://www.reddit.com/message/unread/"
print "---"
if message_noteInt == "No Messages!":
    print "No Unread Messages! | color=teal"
for messages in unread:
    print str(messages), " | color=teal"
    print "---"