Skip to content

Commit

Permalink
fix some texts
Browse files Browse the repository at this point in the history
  • Loading branch information
Mari-W committed Oct 11, 2023
1 parent a3f012c commit 1803345
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 71 deletions.
94 changes: 34 additions & 60 deletions src/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
accept_support_send,
SupportRequestDeclineInput,
decline_support_send,
links_embed,
)
from .env import env

Expand All @@ -86,6 +87,8 @@ def __init__(self, **options) -> None:
async def on_ready(self):
# create #about message
await self.about()
# create #links message
await self.links()
# create #authenticate message
await self.authenticate()
# create #accounts message
Expand All @@ -101,6 +104,12 @@ async def about(self):
# update message
await message.edit(content="", embed=about_embed)

async def links(self):
# get about channel
message = await last_or_new_channel_message(channel_by_name(self, "links"))
# update message
await message.edit(content="", embed=links_embed)

async def authenticate(self):
# get authenticate channel
message = await last_or_new_channel_message(
Expand Down Expand Up @@ -138,10 +147,7 @@ async def on_update(input: AccountTokenInput, interaction: Interaction):
# opens token modal for sync
async def account_token_modal(interaction: Interaction):
account_token_input = AccountTokenInput()
account_token_input.on_submit = MethodType(
on_update,
account_token_input
)
account_token_input.on_submit = MethodType(on_update, account_token_input)
await interaction.response.send_modal(account_token_input)

account_update_button.callback = account_token_modal
Expand All @@ -153,10 +159,7 @@ async def on_rename(input: AccountNameInput, interaction: Interaction):
# opens name modal for new name
async def account_name_modal(interaction: Interaction):
account_name_input = AccountNameInput()
account_name_input.on_submit = MethodType(
on_rename,
account_name_input
)
account_name_input.on_submit = MethodType(on_rename, account_name_input)
await interaction.response.send_modal(account_name_input)

account_name_button.callback = account_name_modal
Expand All @@ -165,9 +168,7 @@ async def account_name_modal(interaction: Interaction):

async def channels(self):
# get channels channel
message = await last_or_new_channel_message(
channel_by_name(self, "channels")
)
message = await last_or_new_channel_message(channel_by_name(self, "channels"))

# opens the request modal
async def channel_request_modal(interaction: Interaction):
Expand All @@ -183,9 +184,7 @@ async def offtopic_channel_request_modal(interaction: Interaction):
offtopic_channel_request_input.on_submit = MethodType(
on_request, offtopic_channel_request_input
)
await interaction.response.send_modal(
offtopic_channel_request_input
)
await interaction.response.send_modal(offtopic_channel_request_input)

# sends the request to admin channel
async def on_request(
Expand All @@ -201,17 +200,11 @@ async def on_request(
channels_request_button.callback = channel_request_modal
offtopic_request_button.callback = offtopic_channel_request_modal

await message.edit(
content="",
embed=channel_embed,
view=channel_view()
)
await message.edit(content="", embed=channel_embed, view=channel_view())

async def support(self):
# get support channel
message = await last_or_new_channel_message(
channel_by_name(self, "support")
)
message = await last_or_new_channel_message(channel_by_name(self, "support"))

# opens the request modal
async def support_request_modal(interaction: Interaction):
Expand All @@ -230,16 +223,9 @@ async def on_request(

support_request_button.callback = support_request_modal

await message.edit(content="",
embed=support_embed,
view=support_view()
)
await message.edit(content="", embed=support_embed, view=support_view())

async def voice(self,
member: Member,
before: VoiceState,
after: VoiceState
):
async def voice(self, member: Member, before: VoiceState, after: VoiceState):
create = utils.get(member.guild.voice_channels, name="create")
category = utils.get(member.guild.categories, name="voice")
category_support = utils.get(member.guild.categories, name="support")
Expand Down Expand Up @@ -290,8 +276,10 @@ async def voice(self,
await member.move_to(channel)
if (
before.channel != after.channel
and (before.channel.category == category or
before.channel.category == category_support)
and (
before.channel.category == category
or before.channel.category == category_support
)
and not before.channel.members
and before.channel.id != int(env.create_voice_channel_id)
):
Expand All @@ -302,10 +290,7 @@ async def voice(self,
# Functionality ###############################################################


async def authorize_token(token: str,
interaction: Interaction,
message=True
) -> bool:
async def authorize_token(token: str, interaction: Interaction, message=True) -> bool:
# token is valid
if token in state:
# get user information
Expand Down Expand Up @@ -341,9 +326,7 @@ async def authorize_token(token: str,
# token is invalid
else:
# send failure message
await send_decaying_response_message(interaction.response,
auth_login_failure
)
await send_decaying_response_message(interaction.response, auth_login_failure)
return False


Expand All @@ -366,9 +349,7 @@ async def disconnect_account(interaction: Interaction, message=True) -> bool:
pass

if message:
await send_decaying_response_message(interaction.response,
auth_logout_success
)
await send_decaying_response_message(interaction.response, auth_logout_success)
return True


Expand Down Expand Up @@ -432,12 +413,10 @@ async def on_accept(
)

await request_interaction.user.send(
channel_request_accepted(
channel_request_accept_input.name_of_channel.value)
channel_request_accepted(channel_request_accept_input.name_of_channel.value)
)
embed = accept_interaction.message.embeds[0]
embed = embed.set_footer(
text=f"Accepted by {accept_interaction.user.nick}")
embed = embed.set_footer(text=f"Accepted by {accept_interaction.user.nick}")
await accept_interaction.message.edit(embed=embed, view=None)
await send_decaying_response_message(
accept_interaction.response, accept_channel_send
Expand All @@ -451,8 +430,7 @@ async def on_decline(
await request_interaction.user.send(decline_message)

embed = decline_interaction.message.embeds[0]
embed = embed.set_footer(
text=f"Declined by {decline_interaction.user.nick}")
embed = embed.set_footer(text=f"Declined by {decline_interaction.user.nick}")
await decline_interaction.message.edit(embed=embed, view=None)
await send_decaying_response_message(
decline_interaction.response, decline_channel_send
Expand Down Expand Up @@ -518,8 +496,7 @@ async def on_accept(
)
)
embed = accept_interaction.message.embeds[0]
embed = embed.set_footer(
text=f"Accepted by {accept_interaction.user.nick}")
embed = embed.set_footer(text=f"Accepted by {accept_interaction.user.nick}")
await accept_interaction.message.edit(embed=embed, view=None)
await send_decaying_response_message(
accept_interaction.response, accept_offtopic_channel_send
Expand All @@ -533,8 +510,7 @@ async def on_decline(
await request_interaction.user.send(decline_message)

embed = decline_interaction.message.embeds[0]
embed = embed.set_footer(
text=f"Declined by {decline_interaction.user.nick}")
embed = embed.set_footer(text=f"Declined by {decline_interaction.user.nick}")
await decline_interaction.message.edit(embed=embed, view=None)
await send_decaying_response_message(
decline_interaction.response, decline_offtopic_channel_send
Expand All @@ -551,6 +527,7 @@ async def on_decline(
request_interaction.response, accept_channel_request_send
)


# Support ####################################################################


Expand Down Expand Up @@ -597,11 +574,10 @@ async def on_accept(
},
category=utils.get(
accept_interaction.user.guild.categories, name="support"
)
),
)
embed = accept_interaction.message.embeds[0]
embed = embed.set_footer(
text=f"Accepted by {accept_interaction.user.nick}")
embed = embed.set_footer(text=f"Accepted by {accept_interaction.user.nick}")
invite = await channel.create_invite(max_age=120, max_uses=2)
await request_interaction.user.send(
support_request_accepted(request_interaction.user.nick, invite)
Expand All @@ -619,8 +595,7 @@ async def on_decline(
await request_interaction.user.send(decline_message)

embed = decline_interaction.message.embeds[0]
embed = embed.set_footer(
text=f"Declined by {decline_interaction.user.nick}")
embed = embed.set_footer(text=f"Declined by {decline_interaction.user.nick}")
await decline_interaction.message.edit(embed=embed, view=None)
await send_decaying_response_message(
decline_interaction.response, decline_support_send
Expand All @@ -644,8 +619,7 @@ async def get_or_create_role(guild: Any, name: str) -> Role:
if role is None:
role = await guild.create_role(
name=name,
colour=Colour.from_rgb(
randint(0, 255), randint(0, 255), randint(0, 255)),
colour=Colour.from_rgb(randint(0, 255), randint(0, 255), randint(0, 255)),
hoist=True,
)
await role.edit(position=2)
Expand Down
56 changes: 45 additions & 11 deletions src/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@

# #about ######################################################################

about_embed_description = """This is the official Discord server of the Technical Faculty of the University of Freiburg by the Fachschaft."""
about_embed_overview = """- text channel \\\\- voice channel \\\\- Forum \\\\- support"""
about_embed_description = """Welcome to the inofficial Discord server of the Technical Faculty of the University of Freiburg by the Fachschaft."""
about_embed_overview = """The server consists of five categories.
- General: These channels are ready only and used to manage your account or distribute important links or information.
- Support: Here you can request support regarding the discord server or anything Fachschaft related.
- Voice: You can create a new voice channel by joining the `create` voice channel. Channels will be deleted as soon as they are empty.
- Channels: These are the channels linked to lectures or similar events. For more information see the `#channels` channel.
- Offtopic: Offtopic channels are all other channels that are not linked to any lecture or event. For mire information see the `#channels` channel
-
"""
about_embed_auth = """To get full access to this server authenticate yourself via the `#authenticate` channel."""
about_embed_rules = """Please behave reasonable and respectful. Be aware that you are not anonymous on this server as your account is linked to your university account. Misconduct can lead to a temporary or a lifetime ban from this server."""
about_embed_rules = """Please behave reasonable and respectful. Be aware that you are not anonymous on this server as your account is linked to your university account. Misconduct can lead to exclusion from this server."""

about_embed = Embed(
type="rich",
Expand All @@ -35,15 +42,42 @@
value=about_embed_auth, inline=False)
about_embed.add_field(name="Rules", value=about_embed_rules, inline=False)

# #links ######################################################################

links_embed_description = """This channel tries to list all important links for your studies. If you feel like there is something missing, please request the addition of a link using the `forum`."""
links_embed_overview = """
## General
- Course Management: https://campus.uni-freiburg.de
- E-Learning: https://ilias.uni-freiburg.de
## Fachschaft
- Fachschaft: https://fachschaft.tf
- Exam Database: https://db.fachschaft.tf
- Hedgedoc: https://hedgedoc.fachschaft.tf/
"""

links_embed = Embed(
type="rich",
title="Important Links",
colour=Colour.blurple(),
timestamp=datetime.now(),
description=links_embed_description,
)

links_embed.set_footer(text=footer)

links_embed.add_field(name="Links",
value=links_embed_overview, inline=False)

# #auth #######################################################################

auth_login_success = "Login successful."
auth_login_failure = "Invalid Token. A token is valid only for 5 Minutes. You might want to generate a new token by reloading the website."
auth_login_failure = "Invalid Token. A token is only valid for 5 minutes. You can generate a new token by reloading the page."
auth_logout_success = "Logout successful."

auth_embed_description = """This server is and only is for members of the University of Freiburg. Authenticate yourself with your university account as described by the following steps."""
auth_embed_description = """This server is though to be only for members of the University of Freiburg. In consequence, you need to authenticate yourself with your university account as described by the following steps."""
auth_embed_get_token = """To get your token click the `Get Auth Token` button below. Log in with your university account and copy the token by clicking on the green box. Then continue with the next step."""
auth_embed_enter_token = """Once you've copied your token click the `Enter Auth Token` button below and paste in your token. Once submitted you gain full access to this server."""
auth_embed_enter_token = """Once you've copied your token click the `Enter Auth Token` button below and paste your token. You should then have gained full access to the server."""


class AuthTokenInput(Modal, title="Enter Authentication Token"):
Expand Down Expand Up @@ -82,8 +116,8 @@ class AuthTokenInput(Modal, title="Enter Authentication Token"):

account_embed_description = """Manage your account."""
account_embed_disconnect = """By pressing the `Disconnect` button the connection between your university and discord account is removed. You can reconnect at any time via the `#authenticate` channel."""
account_embed_sync = """If there are any changes in your role or subject of study at the University of Freiburg you can update your discord account via the `Get Sync Token` and the `Enter Sync Token` buttons."""
account_embed_name = """You can change your server nickname at any time and as often as you want via the `Update Nickname` button. However, you can't change your nickname via your server profile as we want to ensure the naming guidlines."""
account_embed_sync = """If there are any changes in your role or subject of study at the University of Freiburg you can update your discord account via the `Get Sync Token` and the `Enter Sync Token` buttons. Copy the token from the page opened via the `Get Sync Token` button by clicking the green box. Paste the token in the dialog opened when pressing `Enter Sync Token`."""
account_embed_name = """You can change your server nickname at any time and as often as you want via the `Update Nickname` button. However, you can't change your nickname via your server profile as we want to ensure the naming guidelines, i.e. that names include the university account."""


class AccountTokenInput(Modal, title="Enter Authentication Token"):
Expand Down Expand Up @@ -140,7 +174,7 @@ def account_view(): return (
# #channels ###################################################################

channel_request_accepted = (
lambda channel: f"Your channel request for {channel} was accepted."
lambda channel: f"Your channel request for `{channel}` was accepted on the university discord."
)


Expand All @@ -155,15 +189,15 @@ class ChannelRequestInput(Modal, title="Text Channel Request"):
placeholder="Lecture / Seminar / BOK / Lab / ..."
)
name_of_channel = TextInput(
label="Suggested Name of Channel",
label="Suggested Channel Name",
placeholder="eg. sat-solving",
required=False
)


class OffTopicChannelRequestInput(Modal, title="Offtopic Channel Request"):
name_of_channel = TextInput(
label="Name of Channel", placeholder="Volleyball")
label="Channel Name", placeholder="Volleyball")
description = TextInput(
label="Description",
placeholder="A place to find people for playing volleyball",
Expand Down

0 comments on commit 1803345

Please sign in to comment.