full scanner
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
from typing import List
|
||||
from collections import defaultdict
|
||||
import discord
|
||||
|
||||
|
||||
# Custom libs
|
||||
|
||||
from .scanner import Scanner
|
||||
from data_types import Composition
|
||||
from . import EmotesScanner
|
||||
from data_types import Composition, Emote, get_emote_dict
|
||||
from logs import ChannelLogs, MessageLog
|
||||
|
||||
|
||||
@@ -27,14 +29,21 @@ class CompositionScanner(Scanner):
|
||||
)
|
||||
|
||||
async def init(self, message: discord.Message, *args: str) -> bool:
|
||||
guild = message.channel.guild
|
||||
self.comp = Composition()
|
||||
# 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 Composition.analyse_message(message, self.comp, self.raw_members)
|
||||
ret = CompositionScanner.analyse_message(message, self.comp, 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]:
|
||||
Composition.compute_results(self.comp)
|
||||
CompositionScanner.compute_results(self.comp)
|
||||
res = [intro]
|
||||
res += self.comp.to_string()
|
||||
return res
|
||||
@@ -46,6 +55,7 @@ class CompositionScanner(Scanner):
|
||||
impacted = False
|
||||
# If author is included in the selection (empty list is all)
|
||||
if len(raw_members) == 0 or message.author in raw_members:
|
||||
impacted = True
|
||||
pass # TODO
|
||||
return impacted
|
||||
|
||||
|
||||
Reference in New Issue
Block a user