Skip to content

Commit d25735f

Browse files
committed
BUGFIX:
- Download of FARPs and CVNs did not work. - Wrong filename on warehouse uploads.
1 parent 318f2e6 commit d25735f

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

plugins/mission/commands.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2524,7 +2524,7 @@ async def handle_warehouse_uploads(self, message: discord.Message):
25242524

25252525
att = message.attachments[0]
25262526
filename = att.filename.lower()
2527-
match = re.match(r'^warehouse_([^.]*)\.xlsx?$', filename)
2527+
match = re.match(r'^warehouse-([^.]*)\.xlsx?$', filename)
25282528
if not match:
25292529
coalition = await utils.selection(
25302530
ctx,
@@ -2540,13 +2540,21 @@ async def handle_warehouse_uploads(self, message: discord.Message):
25402540
elif match.group(1).upper() in ['RED', 'BLUE']:
25412541
data = await server.send_to_dcs_sync({"command": "getMissionSituation"})
25422542
airports = data.get('coalitions', {}).get(match.group(1).upper(), {}).get('airbases')
2543-
else:
2543+
elif len(match.group(1)) == 4:
25442544
icao = match.group(1).upper()
2545-
airport = next((x for x in server.current_mission.airbases if x.get('code', x.get('type')) == icao), None)
2545+
airport = next((x for x in server.current_mission.airbases if x.get('code', '') == icao), None)
25462546
if not airport:
25472547
await message.channel.send(_("Airport with ICAO {} not found.").format(icao))
25482548
return
25492549
airports = [airport['name']]
2550+
else:
2551+
name = utils.slugify(match.group(1)).casefold()
2552+
airport = next((x for x in server.current_mission.airbases
2553+
if utils.slugify(x.get('name')).casefold() == name), None)
2554+
if not airport:
2555+
await message.channel.send(_("Airport with name {} not found.").format(name))
2556+
return
2557+
airports = [airport['name']]
25502558

25512559
if not await utils.yn_question(
25522560
ctx,

plugins/mission/views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,9 +586,10 @@ def dict_to_df(mapping: dict) -> pd.DataFrame:
586586

587587
buffer.seek(0)
588588
try:
589+
code = utils.slugify(self.airbase.get('code', self.airbase.get('name', 'XXXX')))
589590
# noinspection PyUnresolvedReferences
590591
await interaction.followup.send(
591-
file=discord.File(fp=buffer, filename=f"warehouse-{self.airbase['code'].lower()}.xlsx"), ephemeral=True
592+
file=discord.File(fp=buffer, filename=f"warehouse-{code.lower()}.xlsx"), ephemeral=True
592593
)
593594
self.stop()
594595
finally:

0 commit comments

Comments
 (0)