Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python
- # -*- coding: iso-8859-15 -*-
- #===============
- # Python Script for checking for unread Reddit mails by /u/zd9
- #
- # Only tested in Python 2.7, try in other versions at your own risk.
- #
- # Dependencies: Praw
- # To install Praw, in Terminal type "sudo easy_install praw"
- #
- # Usage in Geektool:
- # 1) Save this script in a safe place with the extension .py
- # 2) Create a new script element in Geektool.
- # 3) In the script field, put:
- # cd /Users/USERNAME/Path/to/Script\ Folder/; python script.py REDDIT_USERNAME REDDIT_PASSWORD
- # 4) Set the delay to something reasonable like 300s.
- # 5) Make sure to have the Status Feedback Image checkbox checked! The only output is from this.
- # 6) Wait for some mail! The Status Feedback Image will be red (failure) when there is no new mail
- # and green (Success) when there is new mail. You can also use a custom image for each if you wish.
- #===============
- import praw,sys
- username = sys.argv[1]
- password = sys.argv[2]
- user_agent = ("PRAW script for "
- "checking the reddit inbox "
- "by /u/zd9")
- reddit = praw.Reddit(user_agent = user_agent)
- reddit.login(username = username, password = password)
- mail = "false"
- for msg in reddit.get_unread(limit=None):
- mail = "true"
- if mail is "false":
- raise Exception('No Mail')
- else:
- print ''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement