我正在尝试编写一个简单的reddit机器人,它将进入一个subreddit,进入提交,阅读评论,如果评论说'感觉'它会发布一个感觉GIF.我收到此错误:'TypeError:类型'Comment'的参数在尝试在评论中执行has_feels ='feel'时是不可迭代的.
我的代码:
import praw
import time
r = praw.Reddit('Posts Feels gif in response to someone saying feels'
'by: Mjone77')
r.login('Feels_Bot', 'notrealpassword')
already_done = []
feels = ['feels']
while True:
subreddit = r.get_subreddit('bottest')
for submission in subreddit.get_new(limit=10):
#submission = next(submissions)
commentNum = 0
for comment in submission.comments:
print(comment)
print(comment.id)
has_feels = 'feels' in comment
if comment.id not in already_done and has_feels:
#comment.reply('[Relevant](http://i.imgur.com/pXBrf.gif)')
already_done.append(comment.id)
print('Commented')
time.sleep(1800)
Run Code Online (Sandbox Code Playgroud)
错误报告(前两行是代码的打印输出,直到它中断):
The feels are strong
ciafpqn
Traceback (most recent call last):
File "C:\Users\Me\Desktop\My Programs\Feels Bot\Feels …Run Code Online (Sandbox Code Playgroud)