コード例 #1
0
ファイル: poster.py プロジェクト: Yuhao93/NoContextBot
def run():
  no_context = [ '/r/nocontext' ]
  banned_subreddits = [ 'wishlist', 'cringepics', 'askreddit' ]
  r = login.init()
  my_id = login.my_id(r)
  while True:
    try:
      for comment in praw.helpers.comment_stream(r, 'all', verbosity=0):
        subreddit = comment.subreddit.display_name.lower()
        if subreddit in banned_subreddits:
          continue
        text = util.txt(comment).lower().strip()
        if text in no_context \
            and not comment.is_root \
            and not db.has_replied(comment.id):
          db.reply(comment.id)
          login.refresh_praw(r)
          reply(r, comment)
    except praw.errors.OAuthInvalidToken:
      login.refresh_praw(r)