Hotfix: more filters and force recheck command
This commit is contained in:
parent
86339e2c2e
commit
54d6c2c960
|
@ -52,6 +52,31 @@ async def on_check(message: Message):
|
||||||
else:
|
else:
|
||||||
await message.reply(":shrug:")
|
await message.reply(":shrug:")
|
||||||
|
|
||||||
|
@dp.message(Command("force"))
|
||||||
|
async def on_force(message: Message):
|
||||||
|
if not message.reply_to_message:
|
||||||
|
return
|
||||||
|
detected_links: list[tuple[str, float]] = []
|
||||||
|
for entity in message.reply_to_message.entities or []:
|
||||||
|
if entity.type in ("text_link", "url") and message.text:
|
||||||
|
if entity.type == "url":
|
||||||
|
entity.url = message.text[
|
||||||
|
entity.offset : entity.offset + entity.length
|
||||||
|
]
|
||||||
|
if not entity.url:
|
||||||
|
continue
|
||||||
|
confidence = await verify_link(entity.url)
|
||||||
|
detected_links.append((entity.url, confidence))
|
||||||
|
n_links = len(detected_links)
|
||||||
|
n_harmful = len(list(filter(lambda lnk: lnk[1] > 0.9, detected_links)))
|
||||||
|
if n_harmful > 0:
|
||||||
|
await message.reply_to_message.delete()
|
||||||
|
await message.reply(f"Found {n_links} links, {n_harmful} of which look sus")
|
||||||
|
elif not detected_links:
|
||||||
|
await message.reply(f"No links found")
|
||||||
|
else:
|
||||||
|
await message.reply(f"Out of {n_links}, none pass minimal threshold")
|
||||||
|
|
||||||
FORM_URL = "https://docs.google.com/forms/d/e/1FAIpQLScPby92blkuDRcbsb9kAQ35tK3EXYtXVFwgGBMlp6REw_ZNgw/viewform"
|
FORM_URL = "https://docs.google.com/forms/d/e/1FAIpQLScPby92blkuDRcbsb9kAQ35tK3EXYtXVFwgGBMlp6REw_ZNgw/viewform"
|
||||||
def form_for(message: Message, link: str) -> str:
|
def form_for(message: Message, link: str) -> str:
|
||||||
assert message.from_user != None
|
assert message.from_user != None
|
||||||
|
|
|
@ -24,8 +24,8 @@ URL_PATTERNS: list[tuple[float, Pattern, str]] = [
|
||||||
REGEX_PATTERNS: list[tuple[float, Pattern, str]] = [
|
REGEX_PATTERNS: list[tuple[float, Pattern, str]] = [
|
||||||
(1.0, regexp(r"\bp2e\b", IGNORECASE), "Play-to-earn keyword"),
|
(1.0, regexp(r"\bp2e\b", IGNORECASE), "Play-to-earn keyword"),
|
||||||
(5.0, regexp(r"play\-to\-earn", IGNORECASE), "Play-to-earn directly"),
|
(5.0, regexp(r"play\-to\-earn", IGNORECASE), "Play-to-earn directly"),
|
||||||
(3.0, regexp(r"encryption\.js", IGNORECASE), "encryption.js"),
|
(10.0, regexp(r"encryption\.js", IGNORECASE), "encryption.js"),
|
||||||
(3.0, regexp(r"web3-ethers\.js", IGNORECASE), "web3-ethers.js"),
|
(10.0, regexp(r"web3-ethers\.js", IGNORECASE), "web3-ethers.js"),
|
||||||
(1.0, regexp(r"\bweb3\b", IGNORECASE), "Web3 mention"),
|
(1.0, regexp(r"\bweb3\b", IGNORECASE), "Web3 mention"),
|
||||||
(1.0, regexp(r"\bnft\b", IGNORECASE), "NFT mention"),
|
(1.0, regexp(r"\bnft\b", IGNORECASE), "NFT mention"),
|
||||||
(3.0, regexp(r"What The Fluff | CLAIM ALL !", IGNORECASE), "WTF Claim all"),
|
(3.0, regexp(r"What The Fluff | CLAIM ALL !", IGNORECASE), "WTF Claim all"),
|
||||||
|
@ -35,6 +35,8 @@ REGEX_PATTERNS: list[tuple[float, Pattern, str]] = [
|
||||||
(3.0, regexp(r"Discover what \ \w+ will become your", IGNORECASE), "Some random button from common scam website"),
|
(3.0, regexp(r"Discover what \ \w+ will become your", IGNORECASE), "Some random button from common scam website"),
|
||||||
(3.0, regexp(r"fluff (token|coin)", IGNORECASE), "fluff token/coin"),
|
(3.0, regexp(r"fluff (token|coin)", IGNORECASE), "fluff token/coin"),
|
||||||
(3.0, regexp(r"A collection of \w+ NFTs", IGNORECASE), "Collection of [some] NFTs"),
|
(3.0, regexp(r"A collection of \w+ NFTs", IGNORECASE), "Collection of [some] NFTs"),
|
||||||
|
(5.0, regexp(r"claim free \$\w+", IGNORECASE), "Claim free shitcoin"),
|
||||||
|
(6.0, regexp(r"melondrop.app", IGNORECASE), "Sus developer URL")
|
||||||
]
|
]
|
||||||
|
|
||||||
MAX_SCORE = 30 # sum(t[0] for t in REGEX_PATTERNS)
|
MAX_SCORE = 30 # sum(t[0] for t in REGEX_PATTERNS)
|
||||||
|
|
Loading…
Reference in New Issue