Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import praw, time, subprocess
- def send_message(notify_text):
- subprocess.Popen(["notify-send", "Reddit Notifier", notify_text])
- return
- r = praw.Reddit('Reddit Monitor for /u/YourUsername')
- USER = 'YourUsername'
- PASS = 'YourPassword'
- r.login(USER, PASS)
- names = []
- send_message("Reddit Notifier started.")
- while True:
- inbox = r.get_unread()
- messages = []
- new_names = []
- for i in inbox:
- if not i.name in names:
- new_names.append(i.name)
- messages.append((i.subject, i.author.name))
- names = new_names
- count = len(messages)
- if count > 0:
- send_message("You have %d unread message%s in your inbox.\n\n%s" % (count, "" if count == 1 else "s", "\n".join(["'%s' from /u/%s" % (m[0], m[1]) for m in messages])))
- time.sleep(10)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement