我运行代码,它会给我一堆错误,比如“无效的授权错误处理请求”。在我的实际代码中,我的id和密码设置正确。我做错什么了?你知道吗
import random
import praw
jokes = open('jokelist.txt').read().splitlines()
joke = ''
#Sets up base of bot
reddit = praw.Reddit(client_id='',
client_secret = '',
username = 'JokeMeBot',
password = '',
user_agent = 'JokeMeBot by /u/Tawkins')
#sets the subreddit
subreddit = reddit.subreddit('dadjokes')
#how to call the bot
keyword = '!JokeMe'
#Checks if the keyword is in the subreddit
for comment in subreddit.stream.comments():
if keyword in comment.body:
#sets to a random joke and posts
joke = random.choice(jokes)
comment.reply(joke)
print('posted')
else:
print("oops")
从praw文件:
https://praw.readthedocs.io/en/latest/getting_started/authentication.html#script-application
所以我会仔细检查你的证件,看看能不能解决这个问题。 请记住,用户名是您的reddit帐户名,而不是bot的名称。你知道吗
相关问题 更多 >
编程相关推荐