Skip to content

How to save audio message #237

Answered by HeySreelal
busslina asked this question in Q&A
Discussion options

You must be logged in to vote

Hey again 👋

Yesss you can do this. Here's the code snippet you're looking for:

  teledart.onMessage().listen((msg) async {
    if (msg.audio == null) return;
    final aud = msg.audio!;
    final file = await teledart.getFile(aud.fileId);
    String url =
        "https://api.telegram.org/file/bot${envVars['BOT_TOKEN']}/${file.filePath}";

    final res = await http.get(Uri.parse(url));
    final bytes = res.bodyBytes; // Uint8List - byte data of the audio file.
  });

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@busslina
Comment options

Answer selected by busslina
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants