mirror of
https://github.com/stijndcl/didier.git
synced 2026-04-07 15:48:29 +02:00
parent
ecb7de062b
commit
09cad58f43
6 changed files with 68 additions and 5 deletions
10
data/regexes.py
Normal file
10
data/regexes.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import re
|
||||
|
||||
STEAM_CODE = {"pattern": "[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}", "flags": re.IGNORECASE}
|
||||
|
||||
|
||||
def contains(text: str, pattern: dict) -> bool:
|
||||
if "flags" in pattern:
|
||||
return re.search(pattern["pattern"], text, pattern["flags"]) is not None
|
||||
else:
|
||||
return re.search(pattern["pattern"], text) is not None
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
from enum import Enum
|
||||
|
||||
from attr import dataclass
|
||||
from data import regexes
|
||||
import discord
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class Action(Enum):
|
||||
|
|
@ -22,3 +23,17 @@ class Snipe:
|
|||
action: Action
|
||||
old: str
|
||||
new: str = None
|
||||
|
||||
|
||||
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue