-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreddit-check.py
executable file
·57 lines (38 loc) · 1.04 KB
/
reddit-check.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/python
from iniparse import INIConfig as ini
import traceback as tb
import praw
import sys
import os
version = [ 0, 1 ]
usr_agent = "redditChecker/{0}.{1} by zer0t3ch".format(version[0], version[1])
r = praw.Reddit(user_agent=usr_agent)
if len(sys.argv) > 1:
com = sys.argv[1]
else:
print("Missing a command")
sys.exit(1)
auth_file = os.path.join(os.path.dirname(__file__), "auth.ini")
creds = ini(open(auth_file))
r.login(creds.reddit['username'], creds.reddit['password'])
# TODO: Add unknown command output
####################################################
####################################################
def get_unread():
msgs = [ ]
unread_messages = r.get_unread()
for msg in unread_messages:
msgs.append(msg)
return "You have {0} unread messages".format(len(msgs))
##########################
commands = {
'unread' : get_unread
}
####################################################
####################################################
ret = ""
try:
ret = commands[com]()
except Exception,e:
ret = e
print(ret)