from __future__ import annotations from typing import Any class WeChatMusicHandler: supported_formats: list[str] = ["mp3", "wav", "amr"] @staticmethod def build_music_message( title: str, description: str = "", music_url: str = "", hq_music_url: str = "", thumb_media_id: str = "" ) -> dict[str, Any]: return { "msgtype": "music", "music": { "title": title, "description": description, "musicurl": music_url, "hqmusicurl": hq_music_url, "thumb_media_id": thumb_media_id, }, } @staticmethod def is_supported_format(filename: str) -> bool: ext = filename.rsplit(".", 1)[-1].lower() if "." in filename else "" return ext in WeChatMusicHandler.supported_formats