template for new scanners

This commit is contained in:
klemek
2021-01-11 12:42:59 +01:00
parent 11921ffee9
commit e11bbf0327
5 changed files with 39 additions and 12 deletions
+16 -1
View File
@@ -6,4 +6,19 @@ class Composition:
pass # TODO
def to_string(self) -> List[str]:
return [] # TODO
return [
# f"- **avg characters / message**: n",
# f"- **plain text messages**: n - %",
# f"- **emojis in messages**: n - %",
# f"- **spoilers in messages**: n - %",
# f"- **emoji-only messages**: n - %",
# f"- **most used emoji**: xx (see more with %emotes)",
# f"- **answers**: n - %",
# f"- **links**: n - %",
# f"- **images**: n - %",
# f"- **other media**: n - %",
# f"- **mentions**: n - %",
# f"- **most mentioned member**: @x",
# f"- **everyone/here**: n - %",
# f"- **edited messages**: n - %",
] # TODO
+6 -1
View File
@@ -6,4 +6,9 @@ class Other:
pass # TODO
def to_string(self) -> List[str]:
return [] # TODO
return [
# f"- **most visited channel**: #c",
# f"- **mostly mentioned by**: @x",
# f"- **reactions**: n %",
# f"- **most used reaction**: xx (see more with %emotes)",
] # TODO
+3 -3
View File
@@ -1,4 +1,4 @@
from typing import List
from typing import List, Dict
from collections import defaultdict
import discord
@@ -43,7 +43,7 @@ class CompositionScanner(Scanner):
return ret
def get_results(self, intro: str) -> List[str]:
CompositionScanner.compute_results(self.comp)
CompositionScanner.compute_results(self.comp, self.emotes)
res = [intro]
res += self.comp.to_string()
return res
@@ -60,5 +60,5 @@ class CompositionScanner(Scanner):
return impacted
@staticmethod
def compute_results(comp: Composition):
def compute_results(comp: Composition, emotes: Dict[str, Emote]):
pass # TODO
+2 -2
View File
@@ -49,8 +49,8 @@ class FullScanner(Scanner):
def get_results(self, intro: str) -> List[str]:
FrequencyScanner.compute_results(self.freq)
CompositionScanner.compute_results(self.comp)
OtherScanner.compute_results(self.other)
CompositionScanner.compute_results(self.comp, self.emotes)
OtherScanner.compute_results(self.other, self.emotes)
res = [intro]
res += ["__Frequency__:"]
res += self.freq.to_string()
+12 -5
View File
@@ -1,11 +1,12 @@
from typing import List
from typing import List, Dict
import discord
# Custom libs
from .scanner import Scanner
from data_types import Other
from . import EmotesScanner
from data_types import Other, Emote, get_emote_dict
from logs import ChannelLogs, MessageLog
@@ -28,13 +29,19 @@ class OtherScanner(Scanner):
async def init(self, message: discord.Message, *args: str) -> bool:
self.other = Other()
# Create emotes dict from custom emojis of the guild
self.emotes = get_emote_dict(message.channel.guild)
return True
def compute_message(self, channel: ChannelLogs, message: MessageLog):
return OtherScanner.analyse_message(message, self.other, self.raw_members)
ret = OtherScanner.analyse_message(message, self.other, self.raw_members)
ret &= EmotesScanner.analyse_message(
message, self.emotes, self.raw_members, all_emojis=True
)
return ret
def get_results(self, intro: str) -> List[str]:
OtherScanner.compute_results(self.other)
OtherScanner.compute_results(self.other, self.emotes)
res = [intro]
res += self.other.to_string()
return res
@@ -51,5 +58,5 @@ class OtherScanner(Scanner):
return impacted
@staticmethod
def compute_results(other: Other):
def compute_results(other: Other, emotes: Dict[str, Emote]):
pass # TODO