Compare commits
1 Commits
0045264250
...
89fd960f67
Author | SHA1 | Date | |
---|---|---|---|
|
89fd960f67 |
BIN
dist/Ragnar-1.3.37-py3-none-any.whl
vendored
BIN
dist/Ragnar-1.3.37-py3-none-any.whl
vendored
Binary file not shown.
BIN
dist/ragnar-1.3.37.tar.gz
vendored
BIN
dist/ragnar-1.3.37.tar.gz
vendored
Binary file not shown.
@ -48,7 +48,6 @@ class Bot:
|
|||||||
"helping",
|
"helping",
|
||||||
"quality",
|
"quality",
|
||||||
"unqiue",
|
"unqiue",
|
||||||
"@ragnar"
|
|
||||||
]
|
]
|
||||||
self.api = Api(username=self.username, password=self.password)
|
self.api = Api(username=self.username, password=self.password)
|
||||||
|
|
||||||
@ -68,8 +67,8 @@ class Bot:
|
|||||||
return rant_text.replace(" ", "").lower()
|
return rant_text.replace(" ", "").lower()
|
||||||
|
|
||||||
@method_cache
|
@method_cache
|
||||||
def is_sus_content(self, content):
|
def is_sus_rant(self, rant_id, rant_text):
|
||||||
clean_text = self.clean_rant_text(content)
|
clean_text = self.clean_rant_text(rant_text)
|
||||||
for trigger in self.triggers:
|
for trigger in self.triggers:
|
||||||
if type(trigger) == dict:
|
if type(trigger) == dict:
|
||||||
if trigger.get("regex"):
|
if trigger.get("regex"):
|
||||||
@ -82,10 +81,6 @@ class Bot:
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@method_cache
|
|
||||||
def is_sus_rant(self, rant_id, rant_text):
|
|
||||||
return self.is_sus_content(rant_text)
|
|
||||||
|
|
||||||
def is_flagged_as_sus(self, rant_id, num_comments):
|
def is_flagged_as_sus(self, rant_id, num_comments):
|
||||||
if not num_comments:
|
if not num_comments:
|
||||||
return False
|
return False
|
||||||
@ -109,16 +104,6 @@ class Bot:
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def is_comments_sus(self, rant_id):
|
|
||||||
log.info("Checking if comments are sus of rant {}.".format(rant_id))
|
|
||||||
rant = self.api.get_rant(rant_id)
|
|
||||||
for comment in rant.get("comments", []):
|
|
||||||
print("Checking if sus comment: ", comment['body'])
|
|
||||||
if self.is_sus_content(comment.get("body", "")):
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def mark_as_sus(self, rant):
|
def mark_as_sus(self, rant):
|
||||||
self.rsleepii()
|
self.rsleepii()
|
||||||
self.api.post_comment(rant["id"], self.mark_text)
|
self.api.post_comment(rant["id"], self.mark_text)
|
||||||
@ -137,10 +122,7 @@ class Bot:
|
|||||||
"{}: User {} is trusted.".format(self.name, rant["user_username"])
|
"{}: User {} is trusted.".format(self.name, rant["user_username"])
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
elif self.is_comments_sus(rant["id"]):
|
if not self.is_sus_rant(rant["id"], rant["text"]):
|
||||||
|
|
||||||
log.info("Comments of rant are sus + user sus. Will flag as spam.")
|
|
||||||
elif not self.is_sus_rant(rant["id"], rant["text"]):
|
|
||||||
log.info(
|
log.info(
|
||||||
"{}: Rant by {} is not sus.".format(
|
"{}: Rant by {} is not sus.".format(
|
||||||
self.name, rant["user_username"]
|
self.name, rant["user_username"]
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -22,7 +22,3 @@ class BotTestCase(unittest.TestCase):
|
|||||||
def test_is_sus_rant_regex_url_match_http_or_www(self):
|
def test_is_sus_rant_regex_url_match_http_or_www(self):
|
||||||
rant_text = "http:// www . google . nl"
|
rant_text = "http:// www . google . nl"
|
||||||
self.assertTrue(self.bot.is_sus_rant(42, rant_text))
|
self.assertTrue(self.bot.is_sus_rant(42, rant_text))
|
||||||
|
|
||||||
def test_is_sus_content(self):
|
|
||||||
rant_text = "I completely understand the frustration—it’s such a hassle to manage all those details manually. I recently started using a platform called best ai trip planner https://easytrip.ai/ and it’s been a game-changer for my travel planning. This AI-powered service analyzes your trip requirements and gives you a comprehensive plan with the best transportation options. Whether you’re looking for the fastest way to travel, the most scenic routes, or something within a specific budget, EasyTrip.ai does all the heavy lifting for you. It’s also great for last-minute plans because it quickly pulls together all the available options!"
|
|
||||||
self.assertTrue(self.bot.is_sus_content(rant_text))
|
|
Loading…
Reference in New Issue
Block a user