use predefined msg_count and total_msg
This commit is contained in:
@@ -5,7 +5,7 @@ class Composition:
|
||||
def __init__(self):
|
||||
pass # TODO
|
||||
|
||||
def to_string(self) -> List[str]:
|
||||
def to_string(self, msg_count: int) -> List[str]:
|
||||
return [
|
||||
# f"- **avg characters / message**: n",
|
||||
# f"- **plain text messages**: n - %",
|
||||
|
||||
@@ -15,15 +15,20 @@ class Presence:
|
||||
self.channel_total = defaultdict(int)
|
||||
self.mentions = defaultdict(int)
|
||||
self.mention_others = defaultdict(int)
|
||||
self.msg_count = 0
|
||||
self.total_msg = 0
|
||||
self.mention_count = 0
|
||||
|
||||
def to_string(self, *, show_top_channel: bool, member_specific: bool) -> List[str]:
|
||||
def to_string(
|
||||
self,
|
||||
msg_count: int,
|
||||
total_msg: int,
|
||||
*,
|
||||
show_top_channel: bool,
|
||||
member_specific: bool,
|
||||
) -> List[str]:
|
||||
ret = []
|
||||
if member_specific:
|
||||
ret += [
|
||||
f"- **messages**: {self.msg_count} ({percent(self.msg_count/self.total_msg)} of server's)"
|
||||
f"- **messages**: {msg_count} ({percent(msg_count/total_msg)} of server's)"
|
||||
]
|
||||
if show_top_channel:
|
||||
top_channel = sorted(self.channel_usage)[-1]
|
||||
|
||||
@@ -38,6 +38,7 @@ class FullScanner(Scanner):
|
||||
self.member_specific = len(self.members) > 0
|
||||
# Create emotes dict from custom emojis of the guild
|
||||
self.emotes = get_emote_dict(message.channel.guild)
|
||||
self.total_msg = 0
|
||||
if self.member_specific:
|
||||
self.emotes_all = get_emote_dict(message.channel.guild)
|
||||
else:
|
||||
@@ -45,6 +46,7 @@ class FullScanner(Scanner):
|
||||
return True
|
||||
|
||||
def compute_message(self, channel: ChannelLogs, message: MessageLog):
|
||||
self.total_msg += 1
|
||||
FrequencyScanner.analyse_message(message, self.freq, self.raw_members)
|
||||
CompositionScanner.analyse_message(message, self.comp, self.raw_members)
|
||||
PresenceScanner.analyse_message(channel, message, self.pres, self.raw_members)
|
||||
@@ -65,9 +67,11 @@ class FullScanner(Scanner):
|
||||
res += ["__Frequency__:"]
|
||||
res += self.freq.to_string()
|
||||
res += ["__Composition__:"]
|
||||
res += self.comp.to_string()
|
||||
res += self.comp.to_string(self.msg_count)
|
||||
res += ["__Presence__:"]
|
||||
res += self.pres.to_string(
|
||||
self.msg_count,
|
||||
self.total_msg,
|
||||
show_top_channel=len(self.channels) > 1,
|
||||
member_specific=self.member_specific,
|
||||
)
|
||||
|
||||
@@ -31,6 +31,7 @@ class PresenceScanner(Scanner):
|
||||
|
||||
async def init(self, message: discord.Message, *args: str) -> bool:
|
||||
self.pres = Presence()
|
||||
self.total_msg = 0
|
||||
self.member_specific = len(self.members) > 0
|
||||
# Create emotes dict from custom emojis of the guild
|
||||
self.emotes = get_emote_dict(message.channel.guild)
|
||||
@@ -41,6 +42,7 @@ class PresenceScanner(Scanner):
|
||||
return True
|
||||
|
||||
def compute_message(self, channel: ChannelLogs, message: MessageLog):
|
||||
self.total_msg += 1
|
||||
EmotesScanner.analyse_message(
|
||||
message, self.emotes, self.raw_members, all_emojis=True
|
||||
)
|
||||
@@ -54,6 +56,8 @@ class PresenceScanner(Scanner):
|
||||
PresenceScanner.compute_results(self.pres, self.emotes, self.emotes_all)
|
||||
res = [intro]
|
||||
res += self.pres.to_string(
|
||||
self.msg_count,
|
||||
self.total_msg,
|
||||
show_top_channel=(len(self.channels) > 1),
|
||||
member_specific=self.member_specific,
|
||||
)
|
||||
@@ -79,7 +83,6 @@ class PresenceScanner(Scanner):
|
||||
if mention in raw_members:
|
||||
pres.mentions[message.author] += 1
|
||||
pres.mention_count += 1
|
||||
pres.total_msg += 1
|
||||
return impacted
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user