Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/v2020.38.0' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay Turner committed Sep 19, 2020
2 parents d60aa5e + 7c16ca4 commit dbe09e4
Show file tree
Hide file tree
Showing 17 changed files with 172 additions and 65 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

## [2020.38.0] - 2020-09-19
### Added
- Capture Total, PokéStops Visited and Travel KM added to Leaderboards

## [2020.37.1] - 2020-09-13
### Fixed
- Fixed message deletions
Expand Down Expand Up @@ -134,7 +138,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- `[p]progress (mention)`
- Settings commands

[Unreleased]: https://github.com/olivierlacan/keep-a-changelog/compare/v2020.37.1...HEAD
[Unreleased]: https://github.com/olivierlacan/keep-a-changelog/compare/v2020.38.0...HEAD
[2020.37.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v2020.37.1...v2020.38.0
[2020.37.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v2020.37.0...v2020.37.1
[2020.37.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v2020.36.1...v2020.37.0
[2020.36.1]: https://github.com/olivierlacan/keep-a-changelog/compare/v2020.36.0...v2020.36.1
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ humanize
PogoOCR==0.3.2.post2
python-dateutil
git+https://github.com/Kowlin/Red-DiscordBot@pr/guild-i18n#egg=Red-DiscordBot
trainerdex==3.5.0
trainerdex==3.6.1
2 changes: 1 addition & 1 deletion tdx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
__author__ = "TurnrDev"
__licence__ = "GNU-GPL"
__copyright__ = "Copyright 2020 TrainerDex/TurnrDev"
__version__ = "2020.37.1"
__version__ = "2020.38.0"
__red_end_user_data_statement__ = """We use several terms in this document which could be considered ambiguous so I would like to clear these up:
* the Website - any website hosted on the trainerdex.co.uk domain or any subdomains thereof
* the Discord Bot - Our official bot instance, TrainerDex#8522, on Discord, or any third party instances that may or may not launch in the future.
Expand Down
64 changes: 41 additions & 23 deletions tdx/embeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,6 @@ async def __init__(
else:
self.description = trainer_code_text

self.add_field(
name=append_icon(icon=self.emoji.get("gym"), text=_("Team")),
value=self.trainer.team.verbose_name,
)

if self.latest_update.travel_km:
self.add_field(
name=append_icon(icon=self.emoji.get("travel_km"), text=_("Distance Walked")),
Expand Down Expand Up @@ -160,26 +155,54 @@ async def __init__(
)

async def add_guild_leaderboard(self, guild: discord.Guild) -> None:
leaderboard = await self.client.get_leaderboard(guild=guild)
entry = await leaderboard.find(lambda x: x._trainer_id == self.trainer.old_id)
if entry:
entries = []
stats = [
"badge_travel_km",
"badge_capture_total",
"badge_pokestops_visited",
"total_xp",
]
for stat in stats:
leaderboard = await self.client.get_leaderboard(stat=stat, guild=guild)
entry = await leaderboard.find(lambda x: x._trainer_id == self.trainer.old_id)
if entry:
entries.append(
append_icon(
self.emoji.get(stat),
"{:,} / {:,}".format(entry.position, len(leaderboard)),
)
)
del leaderboard
del entry

if entries:
self.insert_field_at(
index=0,
name=append_icon(icon=self.emoji.get("total_xp"), text=_("Leaderboard")),
value="{:,}/{:,}".format(entry.position, len(leaderboard)),
name=_("{guild.name} Leaderboard (All)").format(guild=guild),
value="\n".join(entries),
)

async def add_leaderboard(self) -> None:
leaderboard = await self.client.get_leaderboard()
entry = await leaderboard.find(lambda x: x._trainer_id == self.trainer.old_id)
if entry:
entries = []
stats = [
"badge_travel_km",
"badge_capture_total",
"badge_pokestops_visited",
"total_xp",
]
for stat in stats:
leaderboard = await self.client.get_leaderboard(stat=stat)
entry = await leaderboard.find(lambda x: x._trainer_id == self.trainer.old_id)
if entry:
entries.append(append_icon(self.emoji.get(stat), f"{entry.position:,}"))
del leaderboard
del entry

if entries:
self.insert_field_at(
index=0,
name=append_icon(
icon=self.emoji.get("global"),
text=append_icon(icon=self.emoji.get("total_xp"), text=_("Leaderboard")),
),
value="{:,}/{:,}+".format(entry.position, 9000),
name=append_icon(self.emoji.get("global"), _("Leaderboard (Top 1000)")),
value="\n".join(entries),
)

async def show_progress(self) -> None:
Expand Down Expand Up @@ -242,11 +265,6 @@ async def show_progress(self) -> None:

self.clear_fields()

self.add_field(
name=append_icon(icon=self.emoji.get("gym"), text=_("Team")),
value=self.trainer.team.verbose_name,
)

self.add_field(
name=append_icon(icon=self.emoji.get("date"), text=_("Interval")),
value="{then} ⇒ {now} (+{delta})".format(
Expand Down
2 changes: 1 addition & 1 deletion tdx/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"humanize",
"PogoOCR==0.3.2.post2",
"python-dateutil",
"trainerdex==3.5.0"
"trainerdex==3.6.1"
]
}
51 changes: 41 additions & 10 deletions tdx/leaderboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ async def format_page(self, menu, page):
faction=self.emoji.get(entry.faction.verbose_name.lower()),
),
value="{value} • TL{level} • {dt}".format(
value=append_icon(
self.emoji.get(self.stat[0]), cf.humanize_number(entry.total_xp)
),
value=append_icon(self.emoji.get(self.stat), cf.humanize_number(entry.value)),
level=entry.level,
dt=humanize.naturaldate(entry.last_updated),
),
Expand All @@ -55,7 +53,7 @@ async def format_page(self, menu, page):
),
icon_url=emb.footer.icon_url,
)
return {"embed": emb, "content": None}
return {"embed": emb}


class Leaderboard(MixinMeta):
Expand All @@ -76,13 +74,18 @@ async def leaderboard(
self,
ctx: commands.Context,
leaderboard: Optional[Literal["global", "guild", "server"]] = "guild",
stat: Optional[
Literal["travel_km", "capture_total", "pokestops_visited", "total_xp"]
] = "total_xp",
*filters: Union[converters.TeamConverter, converters.LevelConverter],
) -> None:
"""Leaderboards
Parameters:
`leaderboard`: str
`leaderboard`: text
options are `guild` (or `server`) and `global`
`stat`: text
options are `travel_km`, `capture_total`, `pokestops_visited`, `total_xp`
`filters`: Union[Team, Level]
If you mention any team, it'll filter to that. You can mention more than one team.
If you mention one level, it'll show that level and all below.
Expand All @@ -93,7 +96,7 @@ async def leaderboard(
Shows the server leaderboard, unless you're in DMs.
`[p]leaderboard global`
Shows the global leaderboard
Shows the global leaderboard, limited to the top 1000
`[p]leaderboard valor mystic 24`
Shows the server leaderboard, post-filtered to only show valor and mystic players under or equal to level 24
Expand All @@ -103,7 +106,23 @@ async def leaderboard(
"""

leaderboard = leaderboard if ctx.guild else "global"
stat = ("total_xp", _("Total XP"))
is_guild = True if leaderboard == "guild" else False

# Convert stat_name for API
stat = {
"travel_km": "badge_travel_km",
"capture_total": "badge_capture_total",
"pokestops_visited": "badge_pokestops_visited",
"total_xp": "total_xp",
}[stat]

stat_name = {
"badge_travel_km": _("Distance Walked"),
"badge_capture_total": _("Pokémon Caught"),
"badge_pokestops_visited": _("PokéStops Visited"),
"total_xp": _("Total XP"),
}

factions = (
{x for x in filters if isinstance(x, client.Faction)}
if [x for x in filters if isinstance(x, client.Faction)]
Expand All @@ -123,8 +142,8 @@ async def leaderboard(
levels = {client.update.get_level(level=i) for i in levels}

leaderboard_title = append_icon(
icon=self.emoji.get(stat[0], ""),
text=_("{stat} Leaderboard").format(stat=stat[1]),
icon=self.emoji.get(stat, ""),
text=_("{stat} Leaderboard").format(stat=stat_name.get(stat, stat)),
)

emb = await BaseCard(ctx, title=leaderboard_title)
Expand All @@ -139,8 +158,19 @@ async def leaderboard(
)
)
leaderboard = await self.client.get_leaderboard(
guild=ctx.guild if leaderboard in ("guild", "server") else None
stat=stat, guild=ctx.guild if leaderboard in ("guild", "server") else None
)
if is_guild:
emb.description = _(
"""Average {stat_name}: {stat_avg}
Trainers: {stat_count}
Sum of all Trainers: {stat_sum}"""
).format(
stat_name=stat_name.get(stat, stat),
stat_avg=cf.humanize_number(leaderboard.avg),
stat_count=cf.humanize_number(leaderboard.count),
stat_sum=cf.humanize_number(leaderboard.sum),
)

await message.edit(
content=loading(_("{tag} Filtering {leaderboard}…")).format(
Expand All @@ -158,5 +188,6 @@ async def leaderboard(
menu = menus.MenuPages(
source=embeds, timeout=300.0, message=message, clear_reactions_after=True
)
await message.edit(content=ctx.author.mention)
await menu.show_page(0)
await menu.start(ctx)
2 changes: 1 addition & 1 deletion tdx/locales/de-DE.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: trainerdex\n"
"POT-Creation-Date: 2020-09-11 23:40+0000\n"
"PO-Revision-Date: 2020-09-11 23:40\n"
"PO-Revision-Date: 2020-09-17 10:49\n"
"Last-Translator: \n"
"Language-Team: German\n"
"MIME-Version: 1.0\n"
Expand Down
42 changes: 34 additions & 8 deletions tdx/locales/es-ES.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: trainerdex\n"
"POT-Creation-Date: 2020-09-11 23:40+0000\n"
"PO-Revision-Date: 2020-09-11 23:40\n"
"PO-Revision-Date: 2020-09-18 08:14\n"
"Last-Translator: \n"
"Language-Team: Spanish\n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -106,7 +106,24 @@ msgid "Leaderboards\n\n"
" `[p]leaderboard 15 24`\n"
" Shows the server leaderboard, post-filtered to only show players between level 15 and 24 (inclusive)\n"
" "
msgstr ""
msgstr "Tabla de Clasificación\n\n"
" Parámetros:\n"
" `leaderboard`: str\n"
" opciones son `guild` (or `server`) y `global`\n"
" `filters`: Union[Team, Level]\n"
" Si mencionas algún equipo, filtraré eso. Puedes mencionar más de un equipo.\n"
" Si mencionas un nivel, mostraré ese nivel y todos los siguientes.\n"
" Si mencionas más de un nivel, mostraré todos entre el nivel más bajo y el más alto.\n\n"
" Ejemplo:\n"
" `[p]leaderboard`\n"
" Muestra la tabla de clasificación del servidor, a menos que estés en Mensaje Directo.\n\n"
" `[p]leaderboard global`\n"
" Muestra la tabla mundial.\n\n"
" `[p]leaderboard valor mystic 24`\n"
" Muestra la tabla de clasificación del servidor, filtrada para jugadores del equipo Sabiduría menores o iguales al nivel 24\n"
" `[p]leaderboard 15 24`\n"
" Muestra la tabla de clasificación del servidor, filtrada para mostrar solo a los jugadores entre el nivel 15 y 24 (inclusive)\n"
" "

#: tdx/leaderboard.py:127
msgid "{stat} Leaderboard"
Expand Down Expand Up @@ -253,12 +270,12 @@ msgstr "Cargando perfil…"
#: tdx/mod.py:361
#, docstring
msgid "⬎ TrainerDex-specific Moderation Commands"
msgstr ""
msgstr "⬎ TrainerDex-específico Comandos de Moderación"

#: tdx/mod.py:367
#, docstring
msgid "Returns a reason why OCR would have failed"
msgstr ""
msgstr "Devuelve una razón por la que OCR habría fallado"

#: tdx/mod.py:372
msgid "Message {message.id} failed because the cog is disabled in the guild"
Expand Down Expand Up @@ -287,15 +304,18 @@ msgstr "El mensaje {message.id} falló por una razón desconocida"
#: tdx/mod.py:463
#, docstring
msgid "⬎ View, Edit, or Create Trainer Profiles"
msgstr ""
msgstr "Ver, editar o crear perfiles de entrenador"

#: tdx/mod.py:469
#, docstring
msgid "EXPERIMENTAL: Checks for existing users that don't have the right roles, and applies them\n\n"
" Warning: This command is slow and experimental. I wouldn't recommend running it without checking by your roles_to_assign_on_approval setting first.\n"
" It can really mess with roles on a mass scale.\n"
" "
msgstr ""
msgstr "EXPERIMENTAL: Comprueba los usuarios existentes que no tienen los roles correctos, y los aplica\n\n"
" Advertencia: Este comando es lento y experimental. No se recomienda ejecutarlo sin comprobar primero su configuración en roles_to_assign_on_approvation.\n"
" Realmente puede alterar los roles a gran escala.\n"
" "

#: tdx/profile.py:36
#, docstring
Expand Down Expand Up @@ -345,7 +365,9 @@ msgstr "Editar varios aspectos de tu perfil"
msgid "Set the Start Date on your profile\n\n"
" This is the date you started playing Pokémon Go and is just under Total XP\n"
" "
msgstr ""
msgstr "Establece la fecha de inicio de tu perfil\n\n"
" Esta es la fecha en la que comenzaste a jugar Pokemon Go y está por debajo del Total de Experiencia\n"
" "

#: tdx/profile.py:170 tdx/profile.py:211 tdx/settings.py:48 tdx/settings.py:61
#: tdx/settings.py:74 tdx/settings.py:94 tdx/settings.py:130
Expand Down Expand Up @@ -503,7 +525,11 @@ msgid "**You're getting this message because you have been added to the TrainerD
"<{privacy_policy_url}>\n\n"
"{is_visible_note}\n\n"
"If you have any questions, please contact us on Twitter (<{twitter_handle}>), ask the mod who approved you ({mod.mention}), or visit the TrainerDex Support Discord (<{invite_url}>)\n"
msgstr ""
msgstr "**Estás recibiendo este mensaje porque has sido añadido a la base de datos de TrainerDex. *\n\n"
"Esto sería en respuesta a que te unas a `{server.name}` y publicas tus capturas de pantalla para que un mod te pueda aprobar.\n\n"
"TrainerDex es una base de datos de entrenadores y tablero de Pokemon Go. Vea nuestra política de privacidad aquí: <{privacy_policy_url}>\n\n"
"{is_visible_note}\n\n"
"Si tienes alguna pregunta, por favor contáctenos en Twitter (<{twitter_handle}>), pregunta al mod que te aprobó ({mod.mention}), o visita el soporte de TrainerDex Discord (<{invite_url}>)\n"

#: tdx/utils.py:78
msgid "Your profile is currently visible. To hide your data from other users, please run the following command in this chat:\n"
Expand Down
4 changes: 2 additions & 2 deletions tdx/locales/fr-FR.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: trainerdex\n"
"POT-Creation-Date: 2020-09-11 23:40+0000\n"
"PO-Revision-Date: 2020-09-11 23:40\n"
"PO-Revision-Date: 2020-09-17 10:49\n"
"Last-Translator: \n"
"Language-Team: French\n"
"MIME-Version: 1.0\n"
Expand All @@ -19,7 +19,7 @@ msgstr ""

#: tdx/converters.py:57
msgid "{} is not a valid Pokémon Go username. A Pokémon Go username is 3-15 letters or numbers long."
msgstr ""
msgstr "{} n'est pas un nom d'utilisateur valide dans Pokemon Go. Un nom d'utilisateur Pokemon Go contient de 3 à 15 lettres ou nombres."

#: tdx/converters.py:103
msgid "Trainer `{}` not found"
Expand Down
4 changes: 2 additions & 2 deletions tdx/locales/it-IT.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: trainerdex\n"
"POT-Creation-Date: 2020-09-11 23:40+0000\n"
"PO-Revision-Date: 2020-09-11 23:40\n"
"PO-Revision-Date: 2020-09-17 10:49\n"
"Last-Translator: \n"
"Language-Team: Italian\n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -68,7 +68,7 @@ msgstr "Totale PE"

#: tdx/embeds.py:168 tdx/embeds.py:180
msgid "Leaderboard"
msgstr "Classifica"
msgstr ""

#: tdx/embeds.py:234
msgid "No data old enough found, using start date."
Expand Down
Loading

0 comments on commit dbe09e4

Please sign in to comment.