def dragEnterEvent(self, event: QtGui.QDragEnterEvent): from randovania.layout.versioned_preset import VersionedPreset valid_extensions = [ LayoutDescription.file_extension(), VersionedPreset.file_extension(), ] valid_extensions_with_dot = { f".{extension}" for extension in valid_extensions } for url in event.mimeData().urls(): ext = os.path.splitext(url.toLocalFile())[1] if ext in valid_extensions_with_dot: event.acceptProposedAction() return
async def on_message(self, message: discord.Message): if message.author == self.bot.user: return for attachment in message.attachments: filename: str = attachment.filename if filename.endswith(VersionedPreset.file_extension()): data = await attachment.read() versioned_preset = VersionedPreset(json.loads(data.decode("utf-8"))) await reply_for_preset(message, versioned_preset) elif filename.endswith(LayoutDescription.file_extension()): data = await attachment.read() description = LayoutDescription.from_json_dict(json.loads(data.decode("utf-8"))) await reply_for_layout_description(message, description) await look_for_permalinks(message)
def _file_name_for_preset(self, preset: VersionedPreset) -> Path: return self._data_dir.joinpath("{}.{}".format(preset.uuid, preset.file_extension()))