forked from EuroPython/discord
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Primera versión funcional del registro
Se basa en un archivo local CSV extraído de Eventbrite
- Loading branch information
Showing
12 changed files
with
143 additions
and
574 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,19 +6,22 @@ | |
from configuration import Config | ||
from error import AlreadyRegisteredError, NotFoundError | ||
from helpers.channel_logging import log_to_channel | ||
from helpers.pretix_connector import PretixOrder | ||
from helpers.eventbrite_connector import EventbriteOrder | ||
|
||
config = Config() | ||
order_ins = PretixOrder() | ||
order_ins = EventbriteOrder() | ||
|
||
EMOJI_POINT = "\N{WHITE LEFT POINTING BACKHAND INDEX}" | ||
EMOJI_ONE = "1️⃣" | ||
EMOJI_TWO = "2️⃣" | ||
EMOJI_THREE = "3️⃣" | ||
ZERO_WIDTH_SPACE = "\N{ZERO WIDTH SPACE}" | ||
REGISTERED_LIST = {} | ||
|
||
_logger = logging.getLogger(f"bot.{__name__}") | ||
|
||
|
||
class RegistrationButton(discord.ui.Button["Registration"]): | ||
class RegistrationButton(discord.ui.Button["Registro"]): | ||
def __init__(self, x: int, y: int, label: str, style: discord.ButtonStyle): | ||
super().__init__(style=discord.ButtonStyle.secondary, label=ZERO_WIDTH_SPACE, row=y) | ||
self.x = x | ||
|
@@ -33,13 +36,13 @@ async def callback(self, interaction: discord.Interaction) -> None: | |
await interaction.response.send_modal(RegistrationForm()) | ||
|
||
|
||
class RegistrationForm(discord.ui.Modal, title="Europython 2023 Registration"): | ||
class RegistrationForm(discord.ui.Modal, title="Registro PyConES23"): | ||
order = discord.ui.TextInput( | ||
label="Order", | ||
label="N. de Pedido", | ||
required=True, | ||
min_length=4, | ||
max_length=6, | ||
placeholder="5-character combination of capital letters and numbers", | ||
min_length=10, | ||
max_length=12, | ||
placeholder="Número de 10 dígitos que viene luego de un '#'", | ||
) | ||
|
||
name = discord.ui.TextInput( | ||
|
@@ -48,7 +51,7 @@ class RegistrationForm(discord.ui.Modal, title="Europython 2023 Registration"): | |
min_length=3, | ||
max_length=50, | ||
style=discord.TextStyle.short, | ||
placeholder="Your Full Name as printed on your ticket/badge", | ||
placeholder="Tu nombre completo como está en tu ticket", | ||
) | ||
|
||
async def on_submit(self, interaction: discord.Interaction) -> None: | ||
|
@@ -58,7 +61,7 @@ async def on_submit(self, interaction: discord.Interaction) -> None: | |
name=self.name.value, | ||
order=self.order.value, | ||
) | ||
_logger.info("Assigning %r roles=%r", self.name.value, roles) | ||
_logger.info("Asignando %r roles=%r", self.name.value, roles) | ||
for role in roles: | ||
role = discord.utils.get(interaction.guild.roles, id=role) | ||
await interaction.user.add_roles(role) | ||
|
@@ -72,17 +75,17 @@ async def on_submit(self, interaction: discord.Interaction) -> None: | |
roles=roles, | ||
) | ||
await interaction.response.send_message( | ||
f"Thank you {self.name.value}, you are now registered!\n\nAlso, your nickname was" | ||
f"changed to the name you used to register your ticket. This is also the name that" | ||
f" would be on your conference badge, which means that your nickname can be your" | ||
f"'virtual conference badge'.", | ||
f"Gracias {self.name.value}, ¡ya tienes tu registro!\n\nTambién, tu nickname fue" | ||
f" cambiado al nombre que usaste para registrar tu ticket. Este es también el nombre que" | ||
f" estará en tu credencial en la conferencia, lo que significa que tu nickname puede ser" | ||
f" tu 'credencial virtual' de la conferencia.", | ||
ephemeral=True, | ||
delete_after=20, | ||
) | ||
|
||
async def on_error(self, interaction: discord.Interaction, error: Exception) -> None: | ||
# Make sure we know what the error actually is | ||
_logger.error("An error occurred!", exc_info=error) | ||
_logger.error("Ocurrió un error!", exc_info=error) | ||
|
||
# log error message in discord channel | ||
await log_to_channel( | ||
|
@@ -91,12 +94,12 @@ async def on_error(self, interaction: discord.Interaction, error: Exception) -> | |
error=error, | ||
) | ||
if isinstance(error, AlreadyRegisteredError): | ||
_msg = "You have already registered! If you think it is not true" | ||
_msg = "¡Ya te registraste! Si crees que no es verdad" | ||
elif isinstance(error, NotFoundError): | ||
_msg = "We cannot find your ticket, double check your input and try again, or" | ||
_msg = "No podemos encontrar tu ticket, verifica nuevamente la información que ingresaste, o" | ||
else: | ||
_msg = "Something went wrong," | ||
_msg += f" ask for help in <#{config.REG_HELP_CHANNEL_ID}>" | ||
_msg = "Algo no salió bien, " | ||
_msg += f" pide ayuda en <#{config.REG_HELP_CHANNEL_ID}>" | ||
await interaction.response.send_message(_msg, ephemeral=True, delete_after=180) | ||
|
||
|
||
|
@@ -106,7 +109,7 @@ def __init__(self): | |
super().__init__(timeout=None) | ||
self.value = None | ||
self.add_item( | ||
RegistrationButton(0, 0, f"Register here {EMOJI_POINT}", discord.ButtonStyle.green) | ||
RegistrationButton(0, 0, f"Registrate aquí {EMOJI_POINT}", discord.ButtonStyle.green) | ||
) | ||
|
||
|
||
|
@@ -127,18 +130,16 @@ async def on_ready(self): | |
await order_ins.fetch_data() | ||
order_ins.load_registered() | ||
|
||
_title = "Welcome to EuroPython 2023 on Discord! 🎉🐍" | ||
_title = "Te damos la bienvenida al discord de la PyConES23 🎉🐍" | ||
_desc = ( | ||
"Follow these steps to complete your registration:\n\n" | ||
f'1️⃣ Click on the green "Register Here {EMOJI_POINT}" button.\n\n' | ||
'2️⃣ Fill in the "Order" (found by clicking the order URL in your confirmation ' | ||
'email from [email protected] with the Subject: Your order: XXXX) and "Full Name" ' | ||
"(as printed on your ticket/badge).\n\n" | ||
'3️⃣ Click "Submit". We\'ll verify your ticket and give you your role based on ' | ||
"your ticket type.\n\n" | ||
"Experiencing trouble? Ask for help in the registration-help channel or from a " | ||
"volunteer in yellow t-shirt at the conference.\n\n" | ||
"See you on the server! 🐍💻🎉" | ||
"Sigue los siguientes paso para completar el registro:\n\n" | ||
f'{EMOJI_ONE} Haz clic en el botón verde "Registrate Aquí {EMOJI_POINT}".\n\n' | ||
f'{EMOJI_TWO} Rellena el "Número de pedido" (que encuentras en el email de Eventbrite cuando ' | ||
'adquiriste tu entrada con el asunto: "Tus entradas para el evento PyConES 2023 ' | ||
'Tenerife", sin "#") y "Nombre Completo" (como está en la misma orden).\n\n' | ||
f'{EMOJI_THREE} Haz clic "Submit". Verificaremos tu ticket y te asignaremos el rol basado en el tipo..\n\n' | ||
f"¿Tienes algún problema? Pide ayuda en el canal <#{config.REG_HELP_CHANNEL_ID}>.\n\n" | ||
"¡Nos vemos en el servidor! 🐍💻🎉" | ||
) | ||
|
||
view = RegistrationView() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.