SHARE
TWEET

Untitled

a guest Jul 21st, 2017 108 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import praw
  2. import time
  3. import config
  4.  
  5. def login():
  6.     r = praw.Reddit(user_agent = "test bot",
  7.                 username = config.username,
  8.                 password = config.password,
  9.                 client_id = config.client_id,
  10.                 client_secret = config.client_secret)
  11.     print("logged in")
  12.     return r
  13.  
  14.  
  15. cache = []
  16.  
  17. def run_bot(r):
  18.     subreddit = r.subreddit("Test")
  19.     comments = subreddit.get_comments(limit=25)
  20.     for comment in comments:
  21.         comment_text = comment.body.lower()
  22.         if "xD" in comment_text and comment.id not in cache:
  23.             comment.reply("xD")
  24.             cache.append(comment.id)
  25.  
  26. while True:
  27.     r = login()
  28.     run_bot(r)
  29.     time.sleep(5)
  30.    
  31. logged in
  32. Traceback (most recent call last):
  33.   File "xdbot.py", line 28, in <module>
  34.     run_bot(r)
  35.   File "xdbot.py", line 19, in run_bot
  36.     comments = subreddit.get_comments(limit=25)
  37.   File "D:ProgrammingPhytonlibsite-packagesprawmodelsredditbase.py", line 31, in __getattr__
  38.     self._fetch()
  39.   File "D:ProgrammingPhytonlibsite-packagesprawmodelsredditbase.py", line 66, in _fetch
  40.     params=self._info_params)
  41.   File "D:ProgrammingPhytonlibsite-packagesprawreddit.py", line 367, in get
  42.     data = self.request('GET', path, params=params)
  43.   File "D:ProgrammingPhytonlibsite-packagesprawreddit.py", line 451, in request
  44.     params=params)
  45.   File "D:ProgrammingPhytonlibsite-packagesprawcoresessions.py", line 174, in request
  46.     params=params, url=url)
  47.   File "D:ProgrammingPhytonlibsite-packagesprawcoresessions.py", line 108, in _request_with_retries
  48.     data, files, json, method, params, retries, url)
  49.   File "D:ProgrammingPhytonlibsite-packagesprawcoresessions.py", line 93, in _make_request
  50.     params=params)
  51.   File "D:ProgrammingPhytonlibsite-packagesprawcorerate_limit.py", line 32, in call
  52.     kwargs['headers'] = set_header_callback()
  53.   File "D:ProgrammingPhytonlibsite-packagesprawcoresessions.py", line 134, in _set_header_callback
  54.     self._authorizer.refresh()
  55.   File "D:ProgrammingPhytonlibsite-packagesprawcoreauth.py", line 328, in refresh
  56.     password=self._password)
  57.   File "D:ProgrammingPhytonlibsite-packagesprawcoreauth.py", line 142, in _request_token
  58.     payload.get('error_description'))
  59. prawcore.exceptions.OAuthException: invalid_grant error processing request
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top