Так что я пытаюсь запрограммировать бот-ответ Reddit на простую модерацию, и я довольно далеко в этом разбираюсь, но затем при тестировании кода python выдал мне длинную ошибку, которую я не понимаю. Я не пытался это исправить, потому что мои навыки в Python очень ограничены, поэтому я понятия не имею, что делать.
import praw
userAgent = 'Recomend Bot 0.1'
cID = 'rz8Gh2k8RS-NRA'
cSC= '9FR8Balfkd0OcgiKVosMSqAP2YM'
userN = ''
userP =''
numFound = 0
reddit = praw.Reddit(user_agent=userAgent, client_id=cID, client_secret=cSC, username=userN, password=userP)
subreddit = reddit.subreddit('empfehlen_testen')
bot_phrase = 'Test Reply 177013'
keywords = {'test', 'Test', 'recomendation'}
for submission in subreddit.new(limit=10):
n_title = submission.title.lower()
for i in keywords:
if i in n_title:
numFound = numFound + 1
print('Bot replying to: ')
print("Title: ", submission.title)
print("Text: ", submission.selftext)
print("Score: ", submission.score)
print("---------------------------------")
print('Bot saying: ', bot_phrase)
print()
submission.reply(bot_phrase)
if numFound == 0:
print()
print("Sorry, didn't find any posts with those keywords, try again!")
#credit for code goes to Phrynk for code all I did was get it to work on my coumputer
Это как-то заработало, а затем появилось это сообщение об ошибке
Traceback (most recent call last):
File "C:\Users\Dillon\Desktop\RedditBot\reddit_bot.py", line 26, in <module>
for submission in subreddit.new(limit=10): #this views the top 10 posts in that subbreddit
File "C:\Users\Dillon\Desktop\RedditBot\praw\models\listing\generator.py", line 52, in __next__
self._next_batch()
File "C:\Users\Dillon\Desktop\RedditBot\praw\models\listing\generator.py", line 62, in _next_batch
self._listing = self._reddit.get(self.url, params=self.params)
File "C:\Users\Dillon\Desktop\RedditBot\praw\reddit.py", line 446, in get
data = self.request("GET", path, params=params)
File "C:\Users\Dillon\Desktop\RedditBot\praw\reddit.py", line 581, in request
method, path, data=data, files=files, params=params
File "C:\Users\Dillon\AppData\Local\Programs\Python\Python37-32\lib\site-packages\prawcore\sessions.py", line 185, in request
params=params, url=url)
File "C:\Users\Dillon\AppData\Local\Programs\Python\Python37-32\lib\site-packages\prawcore\sessions.py", line 116, in _request_with_retries
data, files, json, method, params, retries, url)
File "C:\Users\Dillon\AppData\Local\Programs\Python\Python37-32\lib\site-packages\prawcore\sessions.py", line 101, in _make_request
params=params)
File "C:\Users\Dillon\AppData\Local\Programs\Python\Python37-32\lib\site-packages\prawcore\rate_limit.py", line 35, in call
kwargs['headers'] = set_header_callback()
File "C:\Users\Dillon\AppData\Local\Programs\Python\Python37-32\lib\site-packages\prawcore\sessions.py", line 145, in _set_header_callback
self._authorizer.refresh()
File "C:\Users\Dillon\AppData\Local\Programs\Python\Python37-32\lib\site-packages\prawcore\auth.py", line 328, in refresh
password=self._password)
File "C:\Users\Dillon\AppData\Local\Programs\Python\Python37-32\lib\site-packages\prawcore\auth.py", line 142, in _request_token
payload.get('error_description'))
prawcore.exceptions.OAuthException: invalid_grant error processing request