Skip to content

get_message_content() returns None if content is audio #810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
THChen2002 opened this issue May 17, 2025 · 2 comments
Open

get_message_content() returns None if content is audio #810

THChen2002 opened this issue May 17, 2025 · 2 comments
Assignees

Comments

@THChen2002
Copy link

System Informations

  • Python version:3.9.12
  • SDK version:3.17.1
  • OS:macOS

Expected Behavior

Calling get_message_content() should return a bytearray.

Current Behavior

Instead of returning a bytearray, get_message_content() returns None.
This issue occurs when the content type is mp3.
As a temporary workaround, I'm currently using get_message_content_with_http_info() to retrieve the content.

@mokuzon
Copy link
Contributor

mokuzon commented May 23, 2025

@THChen2002 Thanks for the bug report!
Unfortunately, I retrieved the Audio data with

@validate_arguments
def get_message_content(self, message_id : Annotated[StrictStr, Field(..., description="Message ID of video or audio")], **kwargs) -> bytearray: # noqa: E501
"""get_message_content # noqa: E501
Download image, video, and audio data sent from users. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_message_content(message_id, async_req=True)
>>> result = thread.get()
:param message_id: Message ID of video or audio (required)
:type message_id: str
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:return: Returns the result object.
If the method is called asynchronously,
returns the request thread.
:rtype: bytearray
"""
kwargs['_return_http_data_only'] = True
if '_preload_content' in kwargs:
raise ValueError("Error! Please call the get_message_content_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data")
return self.get_message_content_with_http_info(message_id, **kwargs) # noqa: E501
in the same environment, and it worked fine, so I could not reproduce the bug.

Please provide a simple code to reproduce the bug.

@THChen2002
Copy link
Author

Sorry about the description. The result will return None if I call get_message_content() after I got the audio message content. If I run it later, it can works. The following screenshot I provided is the situation.

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants