%words improvement
This commit is contained in:
@@ -20,7 +20,7 @@ class WordsScanner(Scanner):
|
||||
def help() -> str:
|
||||
return (
|
||||
"```\n"
|
||||
+ "%words: Rank words by their usage\n"
|
||||
+ "%words: (BETA) Rank words by their usage\n"
|
||||
+ "arguments:\n"
|
||||
+ COMMON_HELP_ARGS
|
||||
+ "* <n> - words containings <n> or more letters, default is 3\n"
|
||||
@@ -104,16 +104,13 @@ class WordsScanner(Scanner):
|
||||
or message.author in raw_members
|
||||
):
|
||||
impacted = True
|
||||
content = " ".join(
|
||||
[
|
||||
block
|
||||
for block in message.content.split()
|
||||
if not re.match(r"^\w+:\/\/", block)
|
||||
]
|
||||
)
|
||||
content = message.content
|
||||
content = re.sub(r"```.+```", "", content, flags=re.DOTALL)
|
||||
content = re.sub(r"`.+`", "", content, flags=re.DOTALL)
|
||||
content = re.sub(r"\w+:\/\/[^ ]+", "", content)
|
||||
for word in re.split("[^\w\-':]", content):
|
||||
m = re.match(
|
||||
r"(?!^:\w+:$)^[^\w]*((?![\d_])\w.*(?![\d_])\w)[^\w]*$", word
|
||||
r"(?!^:\w+:$)^[^\w]*((?![\d_])\w[\w\-']*(?![\d_])\w)[^\w]*$", word
|
||||
)
|
||||
if m:
|
||||
word = m[1].lower()
|
||||
@@ -126,7 +123,5 @@ class WordsScanner(Scanner):
|
||||
words[word] = words[word + case]
|
||||
del words[word + case]
|
||||
break
|
||||
words[word].update_use(
|
||||
message.content.count(word), message.created_at
|
||||
)
|
||||
words[word].update_use(1, message.created_at)
|
||||
return impacted
|
||||
|
||||
Reference in New Issue
Block a user