Skip to content

Commit

Permalink
Primera versión funcional del registro
Browse files Browse the repository at this point in the history
Se basa en un archivo local CSV extraído de Eventbrite
  • Loading branch information
cmaureir committed Oct 3, 2023
1 parent 73d7637 commit 31b3fa0
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 574 deletions.
7 changes: 4 additions & 3 deletions EuroPythonBot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import configuration
from cogs.ping import Ping
from cogs.registration import Registration
from helpers.pretix_connector import PretixOrder
from helpers.eventbrite_connector import EventbriteOrder

load_dotenv(Path(__file__).resolve().parent.parent / ".secrets")
DISCORD_BOT_TOKEN = os.getenv("DISCORD_BOT_TOKEN")
Expand Down Expand Up @@ -75,14 +75,15 @@ async def main():
async with bot:
await bot.add_cog(Ping(bot))
await bot.add_cog(Registration(bot))
await bot.load_extension("extensions.programme_notifications")
# Amazing feature that was replaced by a simpler script
#await bot.load_extension("extensions.programme_notifications")
await bot.load_extension("extensions.organisers")
await bot.start(DISCORD_BOT_TOKEN)


if __name__ == "__main__":
bot = Bot()
orders = PretixOrder()
orders = EventbriteOrder()
try:
asyncio.run(main())
except KeyboardInterrupt:
Expand Down
63 changes: 32 additions & 31 deletions EuroPythonBot/cogs/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -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:
Expand All @@ -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)
Expand All @@ -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(
Expand All @@ -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)


Expand All @@ -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)
)


Expand All @@ -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()
Expand Down
101 changes: 18 additions & 83 deletions EuroPythonBot/config.toml
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
[server]
GUILD=1120766458528542794
GUILD=1125730669406998618

[roles]
ORGANISERS=1120775903274868857
VOLUNTEERS=1120776478825664532
VOLUNTEERS_ONSITE=1124379825826709544
VOLUNTEERS_REMOTE=1124379970173681664
SPEAKERS=1120776091393593426
SPONSORS=1120776149644087406
PARTICIPANTS=1122452618829107220
PARTICIPANTS_ONSITE=1120774936655568896
PARTICIPANTS_REMOTE=1120774557394014298
MODERATORS=1125756054001684560
ORGANISERS=1125756245626863697
VOLUNTEERS=1125756316942602400
SPEAKERS=1125756357820289024
SPONSORS=1125756395409649706
PARTICIPANTS=1125756876546646097
PARTICIPANTS_REMOTE=1125757073154646106

[registration]
REG_CHANNEL_ID=1120789543000477818
REG_HELP_CHANNEL_ID=1122535065377837116
REG_LOG_CHANNEL_ID=1120791994789265675
REG_CHANNEL_ID=1125911236857573486
REG_HELP_CHANNEL_ID=1125755854478651392
REG_LOG_CHANNEL_ID=1125755915526742077

[pretix]
PRETIX_BASE_URL = "https://pretix.eu/api/v1/organizers/europython/events/ep2023"
[eventbrite]
TICKET_TO_ROLES_JSON = "ticket_to_roles_prod.json"

[logging]
LOG_LEVEL = "INFO"

[programme_notifications]
timezone = "Europe/Prague"
timezone = "Atlantic/Canary"
timewarp = false
conference_days_first = "2023-07-19"
conference_days_last = "2023-07-21"
pretalx_schedule_url = "https://pretalx.com/api/events/europython-2023/schedules/latest/"
europython_session_base_url = "https://ep2023.europython.eu/session/{slug}"
europython_api_session_url = "https://ep2023.europython.eu/api/session/{code}"
conference_days_first = "2023-10-06"
conference_days_last = "2023-10-08"
pretalx_schedule_url = "https://pretalx.com/api/events/pycones-2023/schedules/latest/"
europython_session_base_url = "https://charlas.2023.es.pycon.org/pycones-2023/talk/{slug}"
europython_api_session_url = "https://charlas.2023.es.pycon.org/api/session/{code}"

[[programme_notifications.notification_channels]]
webhook_id = "PYTHON_DISCORD"
Expand All @@ -45,65 +42,3 @@ include_channel_in_embeds = true
# Forum Hall
webhook_id = "ROOM_2189"
discord_channel_id = "1120780288755253338"

[programme_notifications.rooms.2189.livestreams]
# Forum Hall Livestream ULRs
"2023-07-19" = "https://europython.eu/live/forum"
"2023-07-20" = "https://europython.eu/live/forum"
"2023-07-21" = "https://europython.eu/live/forum"


[programme_notifications.rooms.2190]
# South Hall 2A
webhook_id = "ROOM_2190"
discord_channel_id = "1120780345575477421"

[programme_notifications.rooms.2190.livestreams]
# South Hall 2A Livestream URLs
"2023-07-19" = "https://europython.eu/live/south-hall-2a"
"2023-07-20" = "https://europython.eu/live/south-hall-2a"
"2023-07-21" = "https://europython.eu/live/south-hall-2a"

[programme_notifications.rooms.2191]
# South Hall 2B
webhook_id = "ROOM_2191"
discord_channel_id = "1120780371622121612"

[programme_notifications.rooms.2191.livestreams]
# South Hall 2B Livestream URLs
"2023-07-19" = "https://europython.eu/live/south-hall-2b"
"2023-07-20" = "https://europython.eu/live/south-hall-2b"
"2023-07-21" = "https://europython.eu/live/south-hall-2b"

[programme_notifications.rooms.2194]
# North Hall
webhook_id = "ROOM_2194"
discord_channel_id = "1120780401791750315"

[programme_notifications.rooms.2194.livestreams]
# North Hall Livestream URLs
"2023-07-19" = "https://europython.eu/live/north-hall"
"2023-07-20" = "https://europython.eu/live/north-hall"
"2023-07-21" = "https://europython.eu/live/north-hall"

[programme_notifications.rooms.2192]
# Terrace 2A
webhook_id = "ROOM_2192"
discord_channel_id = "1120780461195657387"

[programme_notifications.rooms.2192.livestreams]
# Terrace 2A Livestream URLs
"2023-07-19" = "https://europython.eu/live/terrace-2a"
"2023-07-20" = "https://europython.eu/live/terrace-2a"
"2023-07-21" = "https://europython.eu/live/terrace-2a"

[programme_notifications.rooms.2193]
# Terrace 2B
webhook_id = "ROOM_2193"
discord_channel_id = "1120780490576777287"

[programme_notifications.rooms.2193.livestreams]
# Terrace 2B Livestream URLs
"2023-07-19" = "https://europython.eu/live/terrace-2b"
"2023-07-20" = "https://europython.eu/live/terrace-2b"
"2023-07-21" = "https://europython.eu/live/terrace-2b"
5 changes: 2 additions & 3 deletions EuroPythonBot/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ def __init__(self):
self.REG_HELP_CHANNEL_ID = int(config["registration"]["REG_HELP_CHANNEL_ID"])
self.REG_LOG_CHANNEL_ID = int(config["registration"]["REG_LOG_CHANNEL_ID"])

# Pretix
self.PRETIX_BASE_URL = config["pretix"]["PRETIX_BASE_URL"]
self.TICKET_TO_ROLES_JSON = config["pretix"]["TICKET_TO_ROLES_JSON"]
# Eventbrite
self.TICKET_TO_ROLES_JSON = config["eventbrite"]["TICKET_TO_ROLES_JSON"]

# Logging
self.LOG_LEVEL = config.get("logging", {}).get("LOG_LEVEL", "INFO")
Expand Down
8 changes: 2 additions & 6 deletions EuroPythonBot/extensions/organisers/organisers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@ async def participants(self, ctx: commands.Context) -> None:
embed.add_field(name="Members (total)", value=counts.everyone, inline=False)
embed.add_field(name="Unregistered", value=counts.not_registered, inline=False)
embed.add_field(name="Participants", value=counts.participants, inline=False)
embed.add_field(name="Onsite Participants", value=counts.participants_onsite, inline=False)
embed.add_field(name="Remote Participants", value=counts.participants_remote, inline=False)
embed.add_field(name="Sponsors", value=counts.sponsors, inline=False)
embed.add_field(name="Speakers", value=counts.speakers, inline=False)
embed.add_field(name="Volunteers", value=counts.volunteers, inline=False)
embed.add_field(name="Onsite Volunteers", value=counts.volunteers_onsite, inline=False)
embed.add_field(name="Remote Volunteers", value=counts.volunteers_remote, inline=False)
embed.add_field(name="Organisers", value=counts.organisers, inline=False)
embed.add_field(name="Moderators", value=counts.moderators, inline=False)
await ctx.send(embed=embed)

def _get_counts(self, guild: discord.Guild) -> "_RoleCount":
Expand Down Expand Up @@ -84,10 +82,8 @@ class _RoleCount:
not_registered: int
organisers: int
volunteers: int
volunteers_onsite: int
sponsors: int
speakers: int
volunteers_remote: int
participants: int
participants_onsite: int
participants_remote: int
moderators: int
6 changes: 2 additions & 4 deletions EuroPythonBot/extensions/organisers/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
class Roles:
"""Role mapping for the organisers extension."""

moderators: int
organisers: int
volunteers: int
volunteers_onsite: int
volunteers_remote: int
sponsors: int
speakers: int
sponsors: int
participants: int
participants_onsite: int
participants_remote: int
Loading

0 comments on commit 31b3fa0

Please sign in to comment.