more info when available
This commit is contained in:
@@ -37,21 +37,29 @@ class Counter:
|
||||
total_usage: int,
|
||||
counted: str = "time",
|
||||
transform: Optional[Callable[[int], str]] = None,
|
||||
ranking: bool = True,
|
||||
top: bool = True,
|
||||
) -> str:
|
||||
# place
|
||||
output = ""
|
||||
if i == 0:
|
||||
output += ":first_place:"
|
||||
elif i == 1:
|
||||
output += ":second_place:"
|
||||
elif i == 2:
|
||||
output += ":third_place:"
|
||||
if ranking:
|
||||
if i == 0:
|
||||
output += ":first_place: "
|
||||
elif i == 1:
|
||||
output += ":second_place: "
|
||||
elif i == 2:
|
||||
output += ":third_place: "
|
||||
else:
|
||||
output += f"**#{i + 1}** "
|
||||
else:
|
||||
output += f"**#{i + 1}**"
|
||||
output += f"- "
|
||||
sum = val_sum(self.usages)
|
||||
output += f" {name} - {plural(sum, counted)} ({percent(sum/total_usage)}, last {from_now(self.last_used)})"
|
||||
if sum > 0:
|
||||
output += f"{name} - {plural(sum, counted)} ({percent(sum/total_usage)}, last {from_now(self.last_used)})"
|
||||
else:
|
||||
output += f"{name} - unused"
|
||||
top_item = top_key(self.usages)
|
||||
if top_item != 0 and transform is not None:
|
||||
if top and top_item != 0 and transform is not None:
|
||||
if self.usages[top_item] == sum:
|
||||
output += f" (all{transform(top_item)})"
|
||||
else:
|
||||
|
||||
@@ -61,6 +61,7 @@ class ChannelsScanner(Scanner):
|
||||
total_usage=usage_count,
|
||||
counted="message",
|
||||
transform=lambda id: f" by {mention(id)}",
|
||||
top=len(self.members) != 1,
|
||||
)
|
||||
for name in names
|
||||
]
|
||||
|
||||
@@ -61,6 +61,8 @@ class MentionedScanner(Scanner):
|
||||
names.index(name),
|
||||
name,
|
||||
total_usage=usage_count,
|
||||
transform=lambda id: f" for {mention(id)}",
|
||||
top=len(self.members) != 1,
|
||||
)
|
||||
for name in names
|
||||
]
|
||||
@@ -85,6 +87,6 @@ class MentionedScanner(Scanner):
|
||||
mention(member_id)
|
||||
) + message.content.count(alt_mention(member_id))
|
||||
mentions[mention(message.author)].update_use(
|
||||
count, message.created_at
|
||||
count, message.created_at, member_id
|
||||
)
|
||||
return impacted
|
||||
|
||||
@@ -73,6 +73,8 @@ class MentionsScanner(Scanner):
|
||||
names.index(name),
|
||||
name,
|
||||
total_usage=usage_count,
|
||||
transform=lambda id: f" by {mention(id)}",
|
||||
top=len(self.members) != 1,
|
||||
)
|
||||
for name in names
|
||||
]
|
||||
@@ -103,24 +105,28 @@ class MentionsScanner(Scanner):
|
||||
count = message.content.count(name) + message.content.count(
|
||||
alt_mention(member_id)
|
||||
)
|
||||
mentions[name].update_use(count, message.created_at)
|
||||
mentions[name].update_use(count, message.created_at, message.author)
|
||||
if all_mentions:
|
||||
for role_id in message.role_mentions:
|
||||
name = role_mention(role_id)
|
||||
mentions[name].update_use(
|
||||
message.content.count(name), message.created_at
|
||||
message.content.count(name), message.created_at, message.author
|
||||
)
|
||||
for channel_id in message.channel_mentions:
|
||||
name = channel_mention(channel_id)
|
||||
mentions[name].update_use(
|
||||
message.content.count(name), message.created_at
|
||||
message.content.count(name), message.created_at, message.author
|
||||
)
|
||||
if "@everyone" in message.content:
|
||||
mentions["@\u200beveryone"].update_use(
|
||||
message.content.count("@everyone"), message.created_at
|
||||
message.content.count("@everyone"),
|
||||
message.created_at,
|
||||
message.author,
|
||||
)
|
||||
if "@here" in message.content:
|
||||
mentions["@\u200bhere"].update_use(
|
||||
message.content.count("@here"), message.created_at
|
||||
message.content.count("@here"),
|
||||
message.created_at,
|
||||
message.author,
|
||||
)
|
||||
return impacted
|
||||
|
||||
@@ -61,6 +61,7 @@ class MessagesScanner(Scanner):
|
||||
total_usage=usage_count,
|
||||
counted="message",
|
||||
transform=lambda id: f" in {channel_mention(id)}",
|
||||
top=self.channels != 1,
|
||||
)
|
||||
for name in names
|
||||
]
|
||||
|
||||
@@ -58,6 +58,7 @@ class ReactionsScanner(Scanner):
|
||||
total_usage=usage_count,
|
||||
counted="reaction",
|
||||
transform=lambda id: f" in {channel_mention(id)}",
|
||||
top=self.channels != 1,
|
||||
)
|
||||
for name in names
|
||||
]
|
||||
|
||||
+14
-7
@@ -27,6 +27,8 @@ from logs import (
|
||||
|
||||
|
||||
class Scanner(ABC):
|
||||
VALID_ARGS = ["me", "here", "fast", "fresh", "mobile", "mention"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
@@ -34,12 +36,16 @@ class Scanner(ABC):
|
||||
valid_args: List[str] = [],
|
||||
help: str,
|
||||
intro_context: str,
|
||||
all_args: bool = False,
|
||||
):
|
||||
self.has_digit_args = has_digit_args
|
||||
self.valid_args = valid_args
|
||||
self.all_args = all_args
|
||||
self.help = help
|
||||
self.intro_context = intro_context
|
||||
|
||||
self.other_args = []
|
||||
|
||||
self.members = []
|
||||
self.raw_members = []
|
||||
self.full = False
|
||||
@@ -86,19 +92,20 @@ class Scanner(ABC):
|
||||
)
|
||||
return
|
||||
if (
|
||||
arg
|
||||
not in self.valid_args
|
||||
+ ["me", "here", "fast", "fresh", "mobile", "mention"]
|
||||
arg not in self.valid_args + Scanner.VALID_ARGS
|
||||
and (not arg.isdigit() or not self.has_digit_args)
|
||||
and arg not in str_channel_mentions
|
||||
and arg not in str_mentions
|
||||
and arg not in other_mentions
|
||||
and not skip_check
|
||||
):
|
||||
await message.channel.send(
|
||||
f"Unrecognized argument: `{arg}`", reference=message
|
||||
)
|
||||
return
|
||||
if self.all_args:
|
||||
self.other_args += [arg]
|
||||
else:
|
||||
await message.channel.send(
|
||||
f"Unrecognized argument: `{arg}`", reference=message
|
||||
)
|
||||
return
|
||||
|
||||
self.start_date = None if len(dates) < 1 else min(dates)
|
||||
self.stop_date = None if len(dates) < 2 else max(dates)
|
||||
|
||||
@@ -8,11 +8,7 @@ import re
|
||||
from logs import ChannelLogs, MessageLog
|
||||
from .scanner import Scanner
|
||||
from data_types import Counter
|
||||
from utils import (
|
||||
generate_help,
|
||||
plural,
|
||||
precise,
|
||||
)
|
||||
from utils import generate_help, plural, precise, mention
|
||||
|
||||
|
||||
class WordsScanner(Scanner):
|
||||
@@ -68,13 +64,14 @@ class WordsScanner(Scanner):
|
||||
words.sort(key=lambda word: self.words[word].score(), reverse=True)
|
||||
words = words[: self.top]
|
||||
usage_count = Counter.total(self.words)
|
||||
print(len(self.words))
|
||||
res = [intro.format(self.letters)]
|
||||
res += [
|
||||
self.words[word].to_string(
|
||||
words.index(word),
|
||||
f"`{word}`",
|
||||
total_usage=usage_count,
|
||||
transform=lambda id: f" by {mention(id)}",
|
||||
top=len(self.members) != 1,
|
||||
)
|
||||
for word in words
|
||||
]
|
||||
@@ -121,5 +118,5 @@ class WordsScanner(Scanner):
|
||||
words[word] = words[word + case]
|
||||
del words[word + case]
|
||||
break
|
||||
words[word].update_use(1, message.created_at)
|
||||
words[word].update_use(1, message.created_at, message.author)
|
||||
return impacted
|
||||
|
||||
Reference in New Issue
Block a user