-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathutils.py
More file actions
60 lines (45 loc) · 1.52 KB
/
Copy pathutils.py
File metadata and controls
60 lines (45 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import csv
import re
import discord
from datetime import datetime, timezone
import colors
from configuration import Config
config = Config()
aceptar_emoji = "\N{WHITE HEAVY CHECK MARK}"
rechazar_emoji = "\N{CROSS MARK}"
def read_csv_dicts(path, delimiter=";"):
"""Read a semicolon-delimited CSV file (as written by csv.writer
elsewhere in this project) into a list of {column: value} dicts."""
with open(path, newline="") as f:
return list(csv.DictReader(f, delimiter=delimiter))
def get_message_to_moderate(message):
msg = (
f"{datetime.now(timezone.utc).replace(tzinfo=None)} UTC\n"
f"Mensaje enviado desde {message.channel.mention} por {message.author.mention}\n\n"
f"```\n{message.content}\n```\n\n**¿Cumple con todos los requisitos?**\n\n"
f"{aceptar_emoji} Para aceptarlo, envía el siguiente mensaje:\n\n"
f"`%aceptar {message.id}`\n\n"
f"{rechazar_emoji} Para rechazarlo, envía el siguiente mensaje:\n\n"
f"`%rechazar {message.id} 'razón del rechazo'`"
)
embed = discord.Embed(
title="Moderación de mensaje",
description=msg,
colour=colors.BRAND,
)
return embed
def strip_message(message):
m = message[:].lower()
# Remove newlines, and tabs
ft = (
("\n", " "),
("\r", " "),
("\t", " "),
)
for f, t in ft:
m = m.replace(f, t)
# Remove mentions
m = re.sub("<@[^>]*>", "", m)
# Remove multiple whitepaces
m = re.sub(r"\ +", " ", m)
return m.strip()