这是我的密码。请注意,它不会引起任何错误,但也不会以正确的方式工作
import praw
import time
r = praw.Reddit(user_agent = "This is a program to check if anyone is cursing on the forum.")
r.login("BottyMcFooFoo","991319")
curseWords = ['nigger','bitch','faggot','shit','shit','dick','cock'] #Excuse my foul mouth
alreadyScolded = []
scoldedPosts = 0
scoldedComments = 0
looped = 0
def run_botA():
global looped
global postText
global commentText
global postle
global comment
subreddit = r.get_subreddit("test")
postle = subreddit.get_rising(limit = 20)
comment = subreddit.get_comments(limit=20)
for x in postle:
postText = x.selftext.lower()
for x in comment:
commentText = x.body.lower()
looped += 1
print("Configuring settings")
print()
print()
def run_botB():
global looped
global postText
global commentText
global curseWords
global postle
global comment
global alreadyScolded
global scoldedPosts
global scoldedComments
for posts in postle:
print("Checking posts for naughty language")
print()
print()
has_praw = any(string in postText for string in curseWords)
if has_praw == True and posts.id not in alreadyScolded:
r.send_message("I am a bot, but you should watch your mouth young man/woman/fire hydrant(I dont mean to misgender)")
alreadyScolded.append(posts.id)
scoldedPosts += 1
for comments in comment:
print("Checking comments for naughty language")
print()
print()
has_praw = any(string in commentText for string in curseWords)
if has_praw == True and comments.id not in alreadyScolded:
r.send_message("I am a bot, but you should watch your mouth young man/woman/fire hydrant(I dont mean to misgender)")
alreadyScoled.append(posts.id)
scoldedComments += 1
print("Done %d loops." %(looped))
print("Scolded %d posts and %d comments" %(scoldedPosts,scoldedComments))
for x in range(10):
print()
run_botA()
run_botB()
input("Press enter to close m8!")
我相信,至少在某种程度上,你的问题是从这里开始的:
这个循环相当于用
commentText
表示最后一个注释体的较低文本。您可能希望在列表中聚合注释:相关问题 更多 >
编程相关推荐