def dragEnterEvent(self, event: QtGui.QDragEnterEvent): from randovania.layout.preset_migration 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.user: return if message.guild.id != self.configuration["guild"]: 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) channel: discord.TextChannel = message.channel if self.configuration["channel_name_filter"] in channel.name: await look_for_permalinks(message.content, channel)
def _file_name_for_preset(self, preset: VersionedPreset) -> Path: return self._data_dir.joinpath("{}.{}".format(preset.slug_name, preset.file_extension()))