Advertisement
Guest User

Untitled

a guest
Jan 9th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. #! /usr/bin/env python
  2. # -*- coding: iso-8859-15 -*-
  3.  
  4. #===============
  5. # Python Script for checking for unread Reddit mails by /u/zd9
  6. #
  7. # Only tested in Python 2.7, try in other versions at your own risk.
  8. #
  9. # Dependencies: Praw
  10. # To install Praw, in Terminal type "sudo easy_install praw"
  11. #
  12. # Usage in Geektool:
  13. # 1) Save this script in a safe place with the extension .py
  14. # 2) Create a new script element in Geektool.
  15. # 3) In the script field, put:
  16. # cd /Users/USERNAME/Path/to/Script\ Folder/; python script.py REDDIT_USERNAME REDDIT_PASSWORD
  17. # 4) Set the delay to something reasonable like 300s.
  18. # 5) Make sure to have the Status Feedback Image checkbox checked! The only output is from this.
  19. # 6) Wait for some mail! The Status Feedback Image will be red (failure) when there is no new mail
  20. # and green (Success) when there is new mail. You can also use a custom image for each if you wish.
  21. #===============
  22.  
  23. import praw,sys
  24.  
  25. username = sys.argv[1]
  26. password = sys.argv[2]
  27. user_agent = ("PRAW script for "
  28. "checking the reddit inbox "
  29. "by /u/zd9")
  30. reddit = praw.Reddit(user_agent = user_agent)
  31. reddit.login(username = username, password = password)
  32.  
  33. mail = "false"
  34.  
  35. for msg in reddit.get_unread(limit=None):
  36. mail = "true"
  37.  
  38. if mail is "false":
  39. raise Exception('No Mail')
  40. else:
  41. print ''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement