2021-06-22 00:36:22 +02:00
|
|
|
from attr import dataclass
|
2021-06-30 21:55:17 +02:00
|
|
|
from data import regexes
|
|
|
|
import discord
|
|
|
|
from enum import Enum
|
2021-06-22 00:36:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Action(Enum):
|
|
|
|
"""
|
|
|
|
Enum to indicate what action was performed by the user
|
|
|
|
"""
|
|
|
|
Edit = 0
|
|
|
|
Remove = 1
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class Snipe:
|
|
|
|
"""
|
|
|
|
Dataclass to store Snipe info
|
|
|
|
"""
|
|
|
|
user: int
|
|
|
|
channel: int
|
|
|
|
guild: int
|
|
|
|
action: Action
|
|
|
|
old: str
|
|
|
|
new: str = None
|
2021-06-30 21:55:17 +02:00
|
|
|
|
|
|
|
|
|
|
|
def should_snipe(message: discord.Message) -> bool:
|
|
|
|
"""
|
|
|
|
Check if a message should be sniped or not
|
|
|
|
This could be a oneliner but that makes it unreadable
|
|
|
|
"""
|
|
|
|
if message.guild is None:
|
|
|
|
return False
|
|
|
|
|
|
|
|
if message.author.bot:
|
|
|
|
return False
|
|
|
|
|
|
|
|
return not regexes.contains(message.content, regexes.STEAM_CODE)
|