This commit is contained in:
parent
3bcae7e847
commit
f51ac60a2e
@ -17,7 +17,7 @@ class Bot:
|
|||||||
self.name = self.username.split("@")[0]
|
self.name = self.username.split("@")[0]
|
||||||
|
|
||||||
self.amount_of_rants_to_check = 30
|
self.amount_of_rants_to_check = 30
|
||||||
self.sus_users = ["Buffon"]
|
self.sus_users = vic.get_spammers()
|
||||||
self.names = {
|
self.names = {
|
||||||
"no-spam": "Anna",
|
"no-spam": "Anna",
|
||||||
"no-spam1": "Ira",
|
"no-spam1": "Ira",
|
||||||
@ -74,6 +74,18 @@ class Bot:
|
|||||||
def clean_rant_text(self, rant_text):
|
def clean_rant_text(self, rant_text):
|
||||||
return rant_text.replace(" ", "").lower()
|
return rant_text.replace(" ", "").lower()
|
||||||
|
|
||||||
|
def get_mentions(self, rant_text):
|
||||||
|
return re.findall(r"@\w+", rant_text)
|
||||||
|
|
||||||
|
def is_comment_deletable(self, rant_id, username):
|
||||||
|
rant = self.api.get_rant(rant_id)
|
||||||
|
for comment in rant.get("comments", []):
|
||||||
|
print("Checking if sus comment: ", comment["body"])
|
||||||
|
if comment.get("user_username") == username and comment.get("user_score") <= 10:
|
||||||
|
vic.register_spammer(comment["user_username"])
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
@method_cache
|
@method_cache
|
||||||
def is_sus_content(self, content):
|
def is_sus_content(self, content):
|
||||||
clean_text = self.clean_rant_text(content)
|
clean_text = self.clean_rant_text(content)
|
||||||
@ -85,6 +97,19 @@ class Bot:
|
|||||||
log.info(f"Regex trigger {regex} matched!")
|
log.info(f"Regex trigger {regex} matched!")
|
||||||
return True
|
return True
|
||||||
elif trigger in clean_text:
|
elif trigger in clean_text:
|
||||||
|
if trigger == "ragnar":
|
||||||
|
mentions = self.get_mentions(content)
|
||||||
|
for mention in mentions:
|
||||||
|
if mention == "@ragnar":
|
||||||
|
continue
|
||||||
|
username = mention.strip("@")
|
||||||
|
if self.is_comment_deletable(username):
|
||||||
|
vic.register_spammer(mention.strip("@"))
|
||||||
|
self.api.post_comment(rant_id, f"User {username} is sucessfully registered as spammer.")
|
||||||
|
else:
|
||||||
|
self.api.post_comment(rant_id, f"Can't register user {username} as spammer. User is trusted.")
|
||||||
|
if len(mentions) > 1:
|
||||||
|
return False
|
||||||
log.info(f"Trigger {trigger} matched!")
|
log.info(f"Trigger {trigger} matched!")
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
@ -121,6 +146,11 @@ class Bot:
|
|||||||
self.rsleepii()
|
self.rsleepii()
|
||||||
rant = self.api.get_rant(rant_id)
|
rant = self.api.get_rant(rant_id)
|
||||||
for comment in rant.get("comments", []):
|
for comment in rant.get("comments", []):
|
||||||
|
for spammer in self.sus_users:
|
||||||
|
if comment['user_username'] == spammer:
|
||||||
|
vic.downvote_comment(comment['id'])
|
||||||
|
return False
|
||||||
|
|
||||||
print("Checking if sus comment: ", comment["body"])
|
print("Checking if sus comment: ", comment["body"])
|
||||||
if "@ragnar" in comment.get("body", "").lower():
|
if "@ragnar" in comment.get("body", "").lower():
|
||||||
print("Ragnar is mentioned, so flagging as sus comment.")
|
print("Ragnar is mentioned, so flagging as sus comment.")
|
||||||
|
Loading…
Reference in New Issue
Block a user