Skip to content

Commit a7bc2a7

Browse files
committed
Debug added
mission name formatting fixed
1 parent 0e6c61b commit a7bc2a7

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

core/utils/helper.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,10 +797,16 @@ def read_file(self):
797797
self.mtime = os.path.getmtime(self.path)
798798
data = None
799799
if self.path.lower().endswith('.lua'):
800+
content = None
800801
try:
801-
data = luadata.read(self.path, encoding='utf-8')
802+
#data = luadata.read(self.path, encoding='utf-8')
803+
with open(self.path, mode='r', encoding='utf-8') as infile:
804+
content = infile.read()
805+
data = luadata.unserialize(content, encoding='utf-8')
802806
except Exception as ex:
803807
self.log.debug(f"Exception while reading {self.path}:\n{ex}")
808+
if content:
809+
self.log.debug("Content:\n{}".format(content))
804810
data = alternate_parse_settings(self.path)
805811
if not data:
806812
self.log.error("- Error while parsing {}:\n{}".format(os.path.basename(self.path), ex))

plugins/mission/commands.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -550,8 +550,8 @@ async def add(self, interaction: discord.Interaction,
550550

551551
path = os.path.normpath(os.path.join(await server.get_missions_dir(), path))
552552
new_mission_list = await server.addMission(path, autostart=autostart)
553-
name = os.path.basename(path)
554-
await interaction.followup.send(_('Mission "{}" added.').format(utils.escape_string(name)), ephemeral=ephemeral)
553+
mission_name = utils.escape_string(os.path.basename(path))
554+
await interaction.followup.send(_('Mission "{}" added.').format(mission_name), ephemeral=ephemeral)
555555
mission_id = new_mission_list.index(path)
556556
if server.status not in [Status.RUNNING, Status.PAUSED, Status.STOPPED] or \
557557
not await utils.yn_question(interaction, _('Do you want to load this mission?'),
@@ -579,17 +579,17 @@ async def delete(self, interaction: discord.Interaction,
579579
filename == server.current_mission.filename:
580580
await interaction.followup.send(_("You can't delete the running mission."), ephemeral=True)
581581
return
582-
name = filename[:-4]
582+
mission_name = utils.escape_string(os.path.basename(filename[:-4]))
583583

584584
if await utils.yn_question(interaction,
585-
_('Delete mission "{}" from the mission list?').format(os.path.basename(name)),
585+
_('Delete mission "{}" from the mission list?').format(mission_name),
586586
ephemeral=ephemeral):
587587
try:
588588
await server.deleteMission(mission_id + 1)
589-
await interaction.followup.send(_('Mission "{}" removed from list.').format(os.path.basename(name)),
589+
await interaction.followup.send(_('Mission "{}" removed from list.').format(mission_name),
590590
ephemeral=ephemeral)
591591
if await utils.yn_question(interaction,
592-
_('Delete "{}" also from disk?').format(os.path.basename(filename)),
592+
_('Delete "{}" also from disk?').format(mission_name),
593593
ephemeral=ephemeral):
594594
try:
595595
await server.node.remove_file(filename)
@@ -601,13 +601,14 @@ async def delete(self, interaction: discord.Interaction,
601601
secondary = os.path.join(os.path.dirname(filename), '.dcssb', os.path.basename(filename))
602602
await server.node.remove_file(secondary)
603603
await server.node.remove_file(secondary + '.orig')
604-
await interaction.followup.send(_('Mission "{}" deleted.').format(os.path.basename(filename)),
604+
await interaction.followup.send(_('Mission "{}" deleted.').format(mission_name),
605605
ephemeral=ephemeral)
606606
except FileNotFoundError:
607607
await interaction.followup.send(
608-
_('Mission "{}" was already deleted.').format(os.path.basename(filename)),
608+
_('Mission "{}" was already deleted.').format(mission_name),
609609
ephemeral=ephemeral)
610-
await self.bot.audit(_("deleted mission {}").format(name), user=interaction.user)
610+
await self.bot.audit(_("deleted mission {}").format(os.path.basename(filename[:-4])),
611+
user=interaction.user)
611612
except (TimeoutError, asyncio.TimeoutError):
612613
await interaction.followup.send(_("Timeout while deleting mission.\n"
613614
"Please reconfirm that the deletion was successful."),

0 commit comments

Comments
 (0)