Почему мой бот ретвитит твиты от пользователей в списке забаненных пользователей?
Следует отфильтровывать любые твиты по пользователям в списке запрещенных пользователей и предотвращать использование твита словами в списке запрещенных слов, но по какой-то причине это не
bannedwords = ["vote", "bot", "b0t", "tag" , "#teenchoice", "onlyfans"]
bannedusers = ["ProductReviewMY", "followandrt2win", 'b0t', 'bottybotbotl','bot', 'spot', 'lvbroadcasting', 'jflessauSpam', 'bryster125', 'MobileTekReview', 'ilove70315673', 'traunte', 'ericsonabby', '_aekkaphon'] # does not need to be the entire username! you can just put 'bot' for names like 'b0tspotter', etc.
twitter_client = API(auth)
friends = api.friends_ids(SCREEN_NAME)
def search(i):
if i.id > 1141668107372638208 :
if any(k in i.text.lower() for k in keywords) and any(k in i.text.lower() for k in secondaryWords) and not any(k in i.text.lower() for k in bannedwords):
if not any(k in i.author.screen_name.lower().replace("0", "o") for k in bannedusers):
if not i.retweeted:
try:
api.retweet(i.id)
print("rt " + (i.text))
if "follow" in i.text or "#follow" in i.text or "Follow" in i.text or "#Follow" in i.text or "FOLLOW" in i.text or "#FOLLOW" in i.text or "following" in i.text or "#following" in i.text or "FOLLOWING" in i.text or "#FOLLOWING" or "Following" in i.text or "#Following" in i.text:
user_id = i.retweeted_status.user.id
api.create_friendship(user_id)
except Exception:
pass
class MyStreamListener(StreamListener):
def on_status(self, data):
search(data)
return True
if __name__ == '__main__':
listener = MyStreamListener()
stream = Stream(auth, listener)
stream.filter(track=keywords)