template for new scanners
This commit is contained in:
@@ -1,2 +1,4 @@
|
||||
from .emote import Emote
|
||||
from .frequency import Frequency
|
||||
from .composition import Composition
|
||||
from .other import Other
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
from typing import List
|
||||
|
||||
|
||||
class Composition:
|
||||
def __init__(self):
|
||||
pass # TODO
|
||||
|
||||
def to_string(self) -> List[str]:
|
||||
return [] # TODO
|
||||
@@ -0,0 +1,9 @@
|
||||
from typing import List
|
||||
|
||||
|
||||
class Other:
|
||||
def __init__(self):
|
||||
pass # TODO
|
||||
|
||||
def to_string(self) -> List[str]:
|
||||
return [] # TODO
|
||||
+21
-6
@@ -2,7 +2,7 @@ from miniscord import Bot
|
||||
import logging
|
||||
|
||||
from utils import emojis
|
||||
from scanners import EmotesScanner, FrequencyScanner
|
||||
from scanners import EmotesScanner, FrequencyScanner, CompositionScanner, OtherScanner
|
||||
|
||||
logging.basicConfig(
|
||||
format="[%(asctime)s][%(levelname)s][%(module)s] %(message)s", level=logging.INFO
|
||||
@@ -15,18 +15,33 @@ bot = Bot(
|
||||
"1.6(wip)",
|
||||
alias="%",
|
||||
)
|
||||
|
||||
bot.log_calls = True
|
||||
bot.client.bot = bot # TODO place in miniscord
|
||||
|
||||
bot.register_command(
|
||||
"freq(ency)?",
|
||||
lambda *args: FrequencyScanner().compute(*args),
|
||||
"freq: Frequency analysis",
|
||||
FrequencyScanner.help(),
|
||||
"other",
|
||||
lambda *args: OtherScanner().compute(*args),
|
||||
"other: other data analysis",
|
||||
OtherScanner.help(),
|
||||
)
|
||||
bot.register_command(
|
||||
"emotes",
|
||||
lambda *args: EmotesScanner().compute(*args),
|
||||
"emotes: Emotes analysis",
|
||||
"emotes: emotes analysis",
|
||||
EmotesScanner.help(),
|
||||
)
|
||||
bot.register_command(
|
||||
"comp(osition)?",
|
||||
lambda *args: CompositionScanner().compute(*args),
|
||||
"comp: composition analysis",
|
||||
CompositionScanner.help(),
|
||||
)
|
||||
bot.register_command(
|
||||
"freq(ency)?",
|
||||
lambda *args: FrequencyScanner().compute(*args),
|
||||
"freq: frequency analysis",
|
||||
FrequencyScanner.help(),
|
||||
)
|
||||
|
||||
bot.start()
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
from .emotes_scanner import EmotesScanner
|
||||
from .frequency_scanner import FrequencyScanner
|
||||
from .composition_scanner import CompositionScanner
|
||||
from .other_scanner import OtherScanner
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
from typing import List
|
||||
import discord
|
||||
|
||||
|
||||
# Custom libs
|
||||
|
||||
from .scanner import Scanner
|
||||
from data_types import Composition
|
||||
from logs import ChannelLogs, MessageLog
|
||||
|
||||
|
||||
class CompositionScanner(Scanner):
|
||||
@staticmethod
|
||||
def help() -> str:
|
||||
return "```\n"
|
||||
+"%comp : Show composition statistics\n"
|
||||
+"arguments:\n"
|
||||
+"* @member : filter for one or more member\n"
|
||||
+"* #channel : filter for one or more channel\n"
|
||||
+"Example: %comp #mychannel1 @user\n"
|
||||
+"```"
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
help=CompositionScanner.help(),
|
||||
intro_context="Composition",
|
||||
)
|
||||
|
||||
async def init(self, message: discord.Message, *args: str) -> bool:
|
||||
self.comp = Composition()
|
||||
return True
|
||||
|
||||
def compute_message(self, channel: ChannelLogs, message: MessageLog):
|
||||
return Composition.analyse_message(message, self.comp, self.raw_members)
|
||||
|
||||
def get_results(self, intro: str) -> List[str]:
|
||||
Composition.compute_results(self.comp)
|
||||
res = [intro]
|
||||
res += self.comp.to_string()
|
||||
return res
|
||||
|
||||
@staticmethod
|
||||
def analyse_message(
|
||||
message: MessageLog, comp: Composition, raw_members: List[int]
|
||||
) -> bool:
|
||||
impacted = False
|
||||
# If author is included in the selection (empty list is all)
|
||||
if len(raw_members) == 0 or message.author in raw_members:
|
||||
pass # TODO
|
||||
return impacted
|
||||
|
||||
@staticmethod
|
||||
def compute_results(comp: Composition):
|
||||
pass # TODO
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
from typing import List
|
||||
import discord
|
||||
|
||||
|
||||
# Custom libs
|
||||
|
||||
from .scanner import Scanner
|
||||
from data_types import Other
|
||||
from logs import ChannelLogs, MessageLog
|
||||
|
||||
|
||||
class OtherScanner(Scanner):
|
||||
@staticmethod
|
||||
def help() -> str:
|
||||
return "```\n"
|
||||
+"%other : Show other statistics\n"
|
||||
+"arguments:\n"
|
||||
+"* @member : filter for one or more member\n"
|
||||
+"* #channel : filter for one or more channel\n"
|
||||
+"Example: %other #mychannel1 @user\n"
|
||||
+"```"
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
help=OtherScanner.help(),
|
||||
intro_context="Other data",
|
||||
)
|
||||
|
||||
async def init(self, message: discord.Message, *args: str) -> bool:
|
||||
self.other = Other()
|
||||
return True
|
||||
|
||||
def compute_message(self, channel: ChannelLogs, message: MessageLog):
|
||||
return OtherScanner.analyse_message(message, self.other, self.raw_members)
|
||||
|
||||
def get_results(self, intro: str) -> List[str]:
|
||||
OtherScanner.compute_results(self.other)
|
||||
res = [intro]
|
||||
res += self.other.to_string()
|
||||
return res
|
||||
|
||||
@staticmethod
|
||||
def analyse_message(
|
||||
message: MessageLog, other: Other, raw_members: List[int]
|
||||
) -> bool:
|
||||
impacted = False
|
||||
# If author is included in the selection (empty list is all)
|
||||
if len(raw_members) == 0 or message.author in raw_members:
|
||||
pass # TODO
|
||||
return impacted
|
||||
|
||||
@staticmethod
|
||||
def compute_results(other: Other):
|
||||
pass # TODO
|
||||
|
||||
Reference in New Issue
Block a user