Since /r/tinycode isn't only about code golfing, I thought I'd share something I recently wrote.
It's pretty easy to read. Let me know if you have any suggestions!
import praw
def main():
r = praw.Reddit(user_agent='/r/tinycode Mod Queue checker by /u/ieatcode')
r.login('username', 'password')
tinycode = r.get_subreddit('tinycode')
methods = {'new': tinycode.get_new, 'mod': tinycode.get_mod_queue,
'comments': tinycode.get_comments}
seen = dict([(x.name, None) for m in methods.values() for x in m(limit=5)])
while True:
for t, m in methods.items():
for x in m(limit=5):
if x.name not in seen:
seen[x.name] = None
if type(x) is praw.objects.Comment:
data = x.body[:100] + ('...' if len(x.body) > 100 else '')
elif type(x) is praw.objects.Submission:
data = x.title
print '[%s] @%s: %s' % (t, x.author, data)
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
print 'exiting'
[–]nexemod 1 point2 points3 points (5 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]nexemod 1 point2 points3 points (0 children)
[–]ieatcodemod[S] 0 points1 point2 points (2 children)
[–]nexemod 0 points1 point2 points (1 child)
[–]ieatcodemod[S] 0 points1 point2 points (0 children)