prepare history scanner for images
This commit is contained in:
@@ -14,5 +14,8 @@ class FirstScanner(HistoryScanner):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(help=FirstScanner.help())
|
super().__init__(help=FirstScanner.help())
|
||||||
|
|
||||||
|
def allow_message(self, *_) -> bool:
|
||||||
|
return True
|
||||||
|
|
||||||
def get_results(self, intro: str) -> List[str]:
|
def get_results(self, intro: str) -> List[str]:
|
||||||
return self.history.to_string(type="first")
|
return self.history.to_string(type="first")
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from typing import List
|
from typing import Callable, List
|
||||||
import discord
|
import discord
|
||||||
|
|
||||||
# Custom libs
|
# Custom libs
|
||||||
@@ -10,10 +10,10 @@ from logs import ChannelLogs, MessageLog
|
|||||||
|
|
||||||
|
|
||||||
class HistoryScanner(Scanner, ABC):
|
class HistoryScanner(Scanner, ABC):
|
||||||
def __init__(self, *, help: str):
|
def __init__(self, *, valid_args: List[str] = [], help: str):
|
||||||
super().__init__(
|
super().__init__(
|
||||||
has_digit_args=True,
|
has_digit_args=True,
|
||||||
valid_args=["all", "everyone"],
|
valid_args=["all", "everyone"] + valid_args,
|
||||||
help=help,
|
help=help,
|
||||||
intro_context="",
|
intro_context="",
|
||||||
)
|
)
|
||||||
@@ -30,12 +30,17 @@ class HistoryScanner(Scanner, ABC):
|
|||||||
self.history,
|
self.history,
|
||||||
self.raw_members,
|
self.raw_members,
|
||||||
all_messages=self.all_messages,
|
all_messages=self.all_messages,
|
||||||
|
allow_message=self.allow_message,
|
||||||
)
|
)
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get_results(self, intro: str):
|
def get_results(self, intro: str):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def allow_message(self, channel: ChannelLogs, message: MessageLog) -> bool:
|
||||||
|
pass
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def analyse_message(
|
def analyse_message(
|
||||||
channel: ChannelLogs,
|
channel: ChannelLogs,
|
||||||
@@ -44,14 +49,19 @@ class HistoryScanner(Scanner, ABC):
|
|||||||
raw_members: List[int],
|
raw_members: List[int],
|
||||||
*,
|
*,
|
||||||
all_messages: bool,
|
all_messages: bool,
|
||||||
|
allow_message: Callable
|
||||||
) -> bool:
|
) -> bool:
|
||||||
impacted = False
|
impacted = False
|
||||||
# If author is included in the selection (empty list is all)
|
# If author is included in the selection (empty list is all)
|
||||||
if (
|
if (
|
||||||
(not message.bot or all_messages)
|
(
|
||||||
and len(raw_members) == 0
|
(not message.bot or all_messages)
|
||||||
or message.author in raw_members
|
and len(raw_members) == 0
|
||||||
) and (message.content or message.attachment):
|
or message.author in raw_members
|
||||||
|
)
|
||||||
|
and (message.content or message.attachment)
|
||||||
|
and allow_message(channel, message)
|
||||||
|
):
|
||||||
impacted = True
|
impacted = True
|
||||||
history.messages += [message]
|
history.messages += [message]
|
||||||
return impacted
|
return impacted
|
||||||
|
|||||||
@@ -14,5 +14,8 @@ class LastScanner(HistoryScanner):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(help=LastScanner.help())
|
super().__init__(help=LastScanner.help())
|
||||||
|
|
||||||
|
def allow_message(self, *_) -> bool:
|
||||||
|
return True
|
||||||
|
|
||||||
def get_results(self, intro: str) -> List[str]:
|
def get_results(self, intro: str) -> List[str]:
|
||||||
return self.history.to_string(type="last")
|
return self.history.to_string(type="last")
|
||||||
|
|||||||
@@ -14,5 +14,8 @@ class RandomScanner(HistoryScanner):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(help=RandomScanner.help())
|
super().__init__(help=RandomScanner.help())
|
||||||
|
|
||||||
|
def allow_message(self, *_) -> bool:
|
||||||
|
return True
|
||||||
|
|
||||||
def get_results(self, intro: str) -> List[str]:
|
def get_results(self, intro: str) -> List[str]:
|
||||||
return self.history.to_string(type="random")
|
return self.history.to_string(type="random")
|
||||||
|
|||||||
Reference in New Issue
Block a user