Introduced i18n to CogEvent
This commit is contained in:
@@ -24,7 +24,6 @@ from modules.utils import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# noinspection Mypy
|
|
||||||
class CogEvent(Cog):
|
class CogEvent(Cog):
|
||||||
"""Cog with event management commands."""
|
"""Cog with event management commands."""
|
||||||
|
|
||||||
@@ -98,10 +97,7 @@ class CogEvent(Cog):
|
|||||||
start_date: datetime = datetime.strptime(start, "%d.%m.%Y %H:%M").replace(tzinfo=guild_timezone)
|
start_date: datetime = datetime.strptime(start, "%d.%m.%Y %H:%M").replace(tzinfo=guild_timezone)
|
||||||
end_date: datetime = datetime.strptime(end, "%d.%m.%Y %H:%M").replace(tzinfo=guild_timezone)
|
end_date: datetime = datetime.strptime(end, "%d.%m.%Y %H:%M").replace(tzinfo=guild_timezone)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# TODO Introduce i18n
|
await ctx.respond(self.bot._("event_dates_parsing_failed", "messages", locale=ctx.locale))
|
||||||
await ctx.respond(
|
|
||||||
"Could not parse start and end dates. Please, make sure these are provided in `DD.MM.YYYY HH:MM` format."
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if not await validate_event_validity(ctx, name, start_date, end_date, to_utc=True):
|
if not await validate_event_validity(ctx, name, start_date, end_date, to_utc=True):
|
||||||
@@ -120,9 +116,10 @@ class CogEvent(Cog):
|
|||||||
thumbnail=processed_media[0] if thumbnail else None,
|
thumbnail=processed_media[0] if thumbnail else None,
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO Introduce i18n
|
|
||||||
await ctx.respond(
|
await ctx.respond(
|
||||||
f"Event **{event.name}** has been created and will take place <t:{get_unix_timestamp(event.starts, to_utc=True)}:R>."
|
self.bot._("event_created", "messages", locale=ctx.locale).format(
|
||||||
|
event_name=event.name, start_time=get_unix_timestamp(event.starts, to_utc=True)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@command_group.command(
|
@command_group.command(
|
||||||
@@ -205,10 +202,7 @@ class CogEvent(Cog):
|
|||||||
else datetime.strptime(start, "%d.%m.%Y %H:%M").replace(tzinfo=guild_timezone)
|
else datetime.strptime(start, "%d.%m.%Y %H:%M").replace(tzinfo=guild_timezone)
|
||||||
)
|
)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# TODO Make a nice message
|
await ctx.respond(self.bot._("event_start_date_parsing_failed", "messages", locale=ctx.locale))
|
||||||
await ctx.respond(
|
|
||||||
"Could not parse the start date. Please, make sure it is provided in `DD.MM.YYYY HH:MM` format."
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -218,10 +212,7 @@ class CogEvent(Cog):
|
|||||||
else datetime.strptime(end, "%d.%m.%Y %H:%M").replace(tzinfo=guild_timezone)
|
else datetime.strptime(end, "%d.%m.%Y %H:%M").replace(tzinfo=guild_timezone)
|
||||||
)
|
)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# TODO Make a nice message
|
await ctx.respond(self.bot._("event_end_date_parsing_failed", "messages", locale=ctx.locale))
|
||||||
await ctx.respond(
|
|
||||||
"Could not parse the end date. Please, make sure it is provided in `DD.MM.YYYY HH:MM` format."
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if not await validate_event_validity(
|
if not await validate_event_validity(
|
||||||
@@ -248,9 +239,11 @@ class CogEvent(Cog):
|
|||||||
|
|
||||||
# TODO Notify participants about time changes
|
# TODO Notify participants about time changes
|
||||||
|
|
||||||
# TODO Make a nice message
|
|
||||||
await ctx.respond(
|
await ctx.respond(
|
||||||
f"Event **{pycord_event.name}** has been updated and will take place <t:{get_unix_timestamp(pycord_event.starts, to_utc=True)}:R>."
|
self.bot._("event_updated", "messages", locale=ctx.locale).format(
|
||||||
|
event_name=pycord_event.name,
|
||||||
|
start_time=get_unix_timestamp(pycord_event.starts, to_utc=True),
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@command_group.command(
|
@command_group.command(
|
||||||
@@ -309,16 +302,22 @@ class CogEvent(Cog):
|
|||||||
or end_date <= datetime.now(tz=ZoneInfo("UTC"))
|
or end_date <= datetime.now(tz=ZoneInfo("UTC"))
|
||||||
or start_date <= datetime.now(tz=ZoneInfo("UTC"))
|
or start_date <= datetime.now(tz=ZoneInfo("UTC"))
|
||||||
):
|
):
|
||||||
# TODO Make a nice message
|
await ctx.respond(
|
||||||
await ctx.respond("Finished or ongoing events cannot be cancelled.")
|
self.bot._("event_not_editable", "messages", locale=ctx.locale).format(
|
||||||
|
event_name=pycord_event.name
|
||||||
|
)
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
await pycord_event.cancel()
|
await pycord_event.cancel()
|
||||||
|
|
||||||
# TODO Notify participants about cancellation
|
# TODO Notify participants about cancellation
|
||||||
|
|
||||||
# TODO Make a nice message
|
await ctx.respond(
|
||||||
await ctx.respond(f"Event **{pycord_event.name}** was cancelled.")
|
self.bot._("event_cancelled", "messages", locale=ctx.locale).format(
|
||||||
|
event_name=pycord_event.name
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
@command_group.command(
|
@command_group.command(
|
||||||
name="show",
|
name="show",
|
||||||
@@ -346,16 +345,20 @@ class CogEvent(Cog):
|
|||||||
|
|
||||||
stages: List[PycordEventStage] = await self.bot.get_event_stages(pycord_event)
|
stages: List[PycordEventStage] = await self.bot.get_event_stages(pycord_event)
|
||||||
|
|
||||||
# TODO Make a nice message
|
|
||||||
stages_string: str = "\n\n".join(
|
stages_string: str = "\n\n".join(
|
||||||
f"**Stage {stage.sequence+1}**\nAnswer: ||{stage.answer}||" for stage in stages
|
self.bot._("stage_entry", "messages", locale=ctx.locale).format(
|
||||||
|
sequence=stage.sequence + 1, answer=stage.answer
|
||||||
|
)
|
||||||
|
for stage in stages
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO Show users registered for the event
|
# TODO Show users registered for the event
|
||||||
|
|
||||||
# TODO Introduce i18n
|
event_info_string: str = self.bot._("event_details", "messages", locale=ctx.locale).format(
|
||||||
event_info_string: str = (
|
event_name=pycord_event.name,
|
||||||
f"**Event details**\n\nName: {pycord_event.name}\nStarts: <t:{get_unix_timestamp(starts_date)}>\nEnds: <t:{get_unix_timestamp(ends_date)}>\n\nStages:\n{stages_string}"
|
start_time=get_unix_timestamp(starts_date),
|
||||||
|
end_time=get_unix_timestamp(ends_date),
|
||||||
|
stages=stages_string,
|
||||||
)
|
)
|
||||||
|
|
||||||
chunk_size: int = 2000
|
chunk_size: int = 2000
|
||||||
|
@@ -1,13 +1,21 @@
|
|||||||
{
|
{
|
||||||
"messages": {
|
"messages": {
|
||||||
"admin_user_channel_creation_failed": "Event channel could not be created for user **{display_name}** ({mention}) and event **{event_name}**.",
|
"admin_user_channel_creation_failed": "Event channel could not be created for user **{display_name}** ({mention}) and event **{event_name}**.",
|
||||||
|
"admin_user_channel_fixed": "Fixed event channel of user **{display_name}** ({mention}) for the event **{event_name}**.",
|
||||||
"admin_user_completed_event": "User **{display_name}** ({mention}) has completed the event **{event_name}**",
|
"admin_user_completed_event": "User **{display_name}** ({mention}) has completed the event **{event_name}**",
|
||||||
"admin_user_completed_stage": "User **{display_name}** ({mention}) has completed the stage {stage_sequence} of the event **{event_name}**.",
|
"admin_user_completed_stage": "User **{display_name}** ({mention}) has completed the stage {stage_sequence} of the event **{event_name}**.",
|
||||||
"admin_user_channel_fixed": "Fixed event channel of user **{display_name}** ({mention}) for the event **{event_name}**.",
|
|
||||||
"config_reset": "Configuration has been reset. You can update it using `/config set`, otherwise no events can be held.",
|
"config_reset": "Configuration has been reset. You can update it using `/config set`, otherwise no events can be held.",
|
||||||
"config_set": "Configuration has been updated. You can review it anytime using `/config show`.",
|
"config_set": "Configuration has been updated. You can review it anytime using `/config show`.",
|
||||||
"config_show": "**Guild config**\n\nChannel: <#{channel_id}>\nCategory: <#{category_id}>\nTimezone: `{timezone}`",
|
"config_show": "**Guild config**\n\nChannel: <#{channel_id}>\nCategory: <#{category_id}>\nTimezone: `{timezone}`",
|
||||||
|
"event_cancelled": "Event **{event_name}** was cancelled.",
|
||||||
|
"event_created": "Event **{event_name}** has been created and will take place <t:{start_time}:R>.",
|
||||||
|
"event_dates_parsing_failed": "Could not parse start and end dates. Please, make sure these are provided in `DD.MM.YYYY HH:MM` format.",
|
||||||
|
"event_details": "**Event details**\n\nName: {event_name}\nStarts: <t:{start_time}>\nEnds: <t:{end_time}>\n\nStages:\n{stages}",
|
||||||
|
"event_end_date_parsing_failed": "Could not parse the end date. Please, make sure it is provided in `DD.MM.YYYY HH:MM` format.",
|
||||||
|
"event_not_editable": "Finished or ongoing events cannot be cancelled.",
|
||||||
"event_not_found": "Event was not found.",
|
"event_not_found": "Event was not found.",
|
||||||
|
"event_start_date_parsing_failed": "Could not parse the start date. Please, make sure it is provided in `DD.MM.YYYY HH:MM` format.",
|
||||||
|
"event_updated": "Event **{event_name}** has been updated and will take place <t:{start_time}:R>.",
|
||||||
"guess_completed_event": "Congratulations! You have completed the event!",
|
"guess_completed_event": "Congratulations! You have completed the event!",
|
||||||
"guess_incorrect_channel": "Usage outside own event channel is not allowed.",
|
"guess_incorrect_channel": "Usage outside own event channel is not allowed.",
|
||||||
"guess_incorrect_event": "Your event could not be found. Please, contact the administrator.",
|
"guess_incorrect_event": "Your event could not be found. Please, contact the administrator.",
|
||||||
@@ -20,17 +28,18 @@
|
|||||||
"register_already_registered": "You are already registered for this event.",
|
"register_already_registered": "You are already registered for this event.",
|
||||||
"register_success_ongoing": "You are now registered for the event **{event_name}**.\n\nNew channel has been created for you and further instructions will are provided in it. Good luck!",
|
"register_success_ongoing": "You are now registered for the event **{event_name}**.\n\nNew channel has been created for you and further instructions will are provided in it. Good luck!",
|
||||||
"register_success_scheduled": "You are now registered for the event **{event_name}**.\n\nNew channel will be created for you and further instructions will be provided as soon as the event starts <t:{event_starts}:R>. Good luck!",
|
"register_success_scheduled": "You are now registered for the event **{event_name}**.\n\nNew channel will be created for you and further instructions will be provided as soon as the event starts <t:{event_starts}:R>. Good luck!",
|
||||||
|
"stage_entry": "**Stage {sequence}**\nAnswer: ||{answer}||",
|
||||||
"status": "**QuizBot** v{version}\n\nUptime: since <t:{start_time}>",
|
"status": "**QuizBot** v{version}\n\nUptime: since <t:{start_time}>",
|
||||||
"status_git": "**QuizBot** v{version} (`{commit}`)\n\nUptime: up since <t:{start_time}>",
|
"status_git": "**QuizBot** v{version} (`{commit}`)\n\nUptime: up since <t:{start_time}>",
|
||||||
"timezone_invalid": "Timezone **{timezone}** was not found. Please, select one of the timezones provided by the autocompletion.",
|
"timezone_invalid": "Timezone **{timezone}** was not found. Please, select one of the timezones provided by the autocompletion.",
|
||||||
"unexpected_error": "An unexpected error has occurred. Please, contact the administrator.",
|
"unexpected_error": "An unexpected error has occurred. Please, contact the administrator.",
|
||||||
"unregister_not_registered": "You are not registered for this event.",
|
"unregister_not_registered": "You are not registered for this event.",
|
||||||
"unregister_unregistered": "You are no longer registered for this event.",
|
"unregister_unregistered": "You are no longer registered for this event.",
|
||||||
|
"user_channels_updated": "Event channels of the user **{display_name}** were updated.",
|
||||||
"user_jail_already_jailed": "User **{display_name}** is already jailed.",
|
"user_jail_already_jailed": "User **{display_name}** is already jailed.",
|
||||||
"user_jail_successful": "User **{display_name}** has been jailed and cannot interact with events anymore.",
|
"user_jail_successful": "User **{display_name}** has been jailed and cannot interact with events anymore.",
|
||||||
"user_unjail_not_jailed": "User **{display_name}** is not jailed.",
|
"user_unjail_not_jailed": "User **{display_name}** is not jailed.",
|
||||||
"user_unjail_successful": "User **{display_name}** has been unjailed and can interact with events again.",
|
"user_unjail_successful": "User **{display_name}** has been unjailed and can interact with events again."
|
||||||
"user_channels_updated": "Event channels of the user **{display_name}** were updated."
|
|
||||||
},
|
},
|
||||||
"commands": {
|
"commands": {
|
||||||
"config": {
|
"config": {
|
||||||
|
Reference in New Issue
Block a user