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.
Merge pull request #2 from PYCONDE/dr-pycon-pydata-changes
pycon pydata changes
- Loading branch information
Showing
11 changed files
with
476 additions
and
179 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Deploy to server | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Deploy to some Server | ||
uses: easingthemes/ssh-deploy@v4 | ||
with: | ||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY_DISCORD }} | ||
SOURCE: "." | ||
REMOTE_HOST: "136.243.153.146" | ||
REMOTE_USER: "root" | ||
TARGET: "/home/discord/" | ||
EXCLUDE: "/dist/, /node_modules/" | ||
|
||
SCRIPT_BEFORE: | | ||
whoami | ||
ls -al | ||
SCRIPT_AFTER: | | ||
echo $RSYNC_STDOUT | ||
cd /root/discord | ||
docker compose down | ||
docker compose up --detach --build |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
3.11.4 |
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
from __future__ import annotations | ||
|
||
import logging | ||
|
||
import discord | ||
|
@@ -6,10 +8,13 @@ | |
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.pretix_connector import PretixOrder | ||
from helpers.tito_connector import TitoOrder | ||
|
||
config = Config() | ||
order_ins = PretixOrder() | ||
order_ins = TitoOrder() # PretixOrder() | ||
|
||
CHANGE_NICKNAME = True | ||
|
||
EMOJI_POINT = "\N{WHITE LEFT POINTING BACKHAND INDEX}" | ||
ZERO_WIDTH_SPACE = "\N{ZERO WIDTH SPACE}" | ||
|
@@ -19,18 +24,26 @@ | |
|
||
|
||
class RegistrationButton(discord.ui.Button["Registration"]): | ||
def __init__(self, x: int, y: int, label: str, style: discord.ButtonStyle): | ||
def __init__( | ||
self, | ||
registration_form: RegistrationForm, | ||
x: int = 0, | ||
y: int = 0, | ||
label: str = f"Register here {EMOJI_POINT}", | ||
style: discord.ButtonStyle = discord.ButtonStyle.green, | ||
): | ||
super().__init__(style=discord.ButtonStyle.secondary, label=ZERO_WIDTH_SPACE, row=y) | ||
self.x = x | ||
self.y = y | ||
self.label = label | ||
self.style = style | ||
self.registration_form = registration_form | ||
|
||
async def callback(self, interaction: discord.Interaction) -> None: | ||
assert self.view is not None | ||
|
||
# Launch the modal form | ||
await interaction.response.send_modal(RegistrationForm()) | ||
await interaction.response.send_modal(self.registration_form()) | ||
|
||
|
||
class RegistrationForm(discord.ui.Modal, title="Europython 2023 Registration"): | ||
|
@@ -48,7 +61,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="Your full name as printed on your ticket/badge", | ||
) | ||
|
||
async def on_submit(self, interaction: discord.Interaction) -> None: | ||
|
@@ -62,23 +75,38 @@ async def on_submit(self, interaction: discord.Interaction) -> None: | |
for role in roles: | ||
role = discord.utils.get(interaction.guild.roles, id=role) | ||
await interaction.user.add_roles(role) | ||
nickname = self.name.value[:32] # Limit to the max length | ||
await interaction.user.edit(nick=nickname) | ||
changed_nickname = True | ||
if CHANGE_NICKNAME: | ||
try: | ||
# TODO(dan): change nickname not working, because no admin permission? | ||
nickname = self.name.value[:32] # Limit to the max length | ||
await interaction.user.edit(nick=nickname) | ||
except discord.errors.Forbidden as ex: | ||
msg = f"Changing nickname for {self.name} did not work: {ex}" | ||
_logger.error(msg) | ||
await log_to_channel( | ||
channel=interaction.client.get_channel(config.REG_LOG_CHANNEL_ID), | ||
interaction=interaction, | ||
error=ex, | ||
) | ||
changed_nickname = False | ||
await log_to_channel( | ||
channel=interaction.client.get_channel(config.REG_LOG_CHANNEL_ID), | ||
interaction=interaction, | ||
name=self.name.value, | ||
order=self.order.value, | ||
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'.", | ||
ephemeral=True, | ||
delete_after=20, | ||
msg = f"Thank you {self.name.value}, you are now registered!" | ||
|
||
if CHANGE_NICKNAME and changed_nickname: | ||
msg += ( | ||
"\n\nAlso, your nickname was changed to the name you used to register your ticket. " | ||
"This is also the name that would be on your conference badge, which means that your nickname can be " | ||
"your 'virtual conference badge'." | ||
) | ||
|
||
await interaction.response.send_message(msg, 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 | ||
|
@@ -101,19 +129,36 @@ async def on_error(self, interaction: discord.Interaction, error: Exception) -> | |
|
||
|
||
class RegistrationView(discord.ui.View): | ||
def __init__(self): | ||
def __init__( | ||
self, | ||
registration_button: RegistrationButton = RegistrationButton, | ||
registration_form: RegistrationForm = RegistrationForm, | ||
): | ||
# We don't timeout to have a persistent View | ||
super().__init__(timeout=None) | ||
self.value = None | ||
self.add_item( | ||
RegistrationButton(0, 0, f"Register here {EMOJI_POINT}", discord.ButtonStyle.green) | ||
) | ||
self.add_item(registration_button(registration_form=registration_form)) | ||
|
||
|
||
class Registration(commands.Cog): | ||
def __init__(self, bot): | ||
def __init__(self, bot, registration_view: RegistrationView = RegistrationView): | ||
self.bot = bot | ||
self.guild = None | ||
self._title = "Welcome to EuroPython 2023 on Discord! 🎉🐍" | ||
self._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! 🐍💻🎉" | ||
) | ||
self.registration_view = registration_view | ||
|
||
_logger.info("Cog 'Registration' has been initialized") | ||
|
||
@commands.Cog.listener() | ||
|
@@ -127,25 +172,10 @@ async def on_ready(self): | |
await order_ins.fetch_data() | ||
order_ins.load_registered() | ||
|
||
_title = "Welcome to EuroPython 2023 on Discord! 🎉🐍" | ||
_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! 🐍💻🎉" | ||
) | ||
|
||
view = RegistrationView() | ||
embed = discord.Embed( | ||
title=_title, | ||
description=_desc, | ||
title=self._title, | ||
description=self._desc, | ||
colour=0xFF8331, | ||
) | ||
|
||
await reg_channel.send(embed=embed, view=view) | ||
await reg_channel.send(embed=embed, view=self.registration_view()) |
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# import logging | ||
|
||
import discord | ||
from discord.ext import commands | ||
|
||
# from configuration import Config | ||
# from error import AlreadyRegisteredError, NotFoundError | ||
# from helpers.channel_logging import log_to_channel | ||
# from helpers.tito_connector import TitoOrder | ||
from cogs.registration import Registration, RegistrationButton, RegistrationForm, RegistrationView | ||
|
||
# config = Config() | ||
# order_ins = TitoOrder() | ||
|
||
# CHANGE_NICKNAME = False | ||
|
||
EMOJI_POINT = "\N{WHITE LEFT POINTING BACKHAND INDEX}" | ||
|
||
# _logger = logging.getLogger(f"bot.{__name__}") | ||
|
||
|
||
# TODO(dan): make pydata subclass with changes | ||
|
||
class RegistrationButtonPyData(RegistrationButton): | ||
def __init__(self, registration_form: RegistrationForm,): | ||
super().__init__(registration_form=RegistrationFormPyData) | ||
|
||
class RegistrationFormPyData(RegistrationForm): | ||
def __init__(self): | ||
super().__init__(title="PyConDE/PyData Berlin 2024 Registration") | ||
|
||
|
||
class RegistrationViewPyData(RegistrationView): | ||
def __init__(self): | ||
super().__init__(registration_button=RegistrationButtonPyData, registration_form=RegistrationFormPyData) | ||
|
||
class RegistrationPyData(Registration, commands.Cog): | ||
def __init__(self, bot): | ||
super().__init__(bot, registration_view=RegistrationViewPyData) | ||
self._title = _title = "Welcome to PyConDE / PyData Berlin 2024 on Discord! 🎉🐍" | ||
# TODO(dan): update text | ||
self._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! 🐍💻🎉" | ||
) |
Oops, something went wrong.