Skip to content
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

How to handle multiple uncompressed files(photos) upload? #2400

Closed
abaoai opened this issue Oct 6, 2024 · 1 comment
Closed

How to handle multiple uncompressed files(photos) upload? #2400

abaoai opened this issue Oct 6, 2024 · 1 comment

Comments

@abaoai
Copy link

abaoai commented Oct 6, 2024

Please answer these questions before submitting your issue. Thanks!

  1. What version of pyTelegramBotAPI are you using?
    4.22.1
  2. What OS are you using?
    linux (running bot), macos (running telegram)
  3. What version of python are you using?
    3.12

This is suggested by chatgpt. message.document is not a list when multiple files are uploaded.

    @bot.message_handler(func=lambda _: True, content_types=["document"])
    def handle_document(message: Message):
        if message.caption and bot_name in message.caption:
            username = message.from_user.username
            if isinstance(message.document, list): // this returns false
                for document in message.document:
                    print(document.mime_type)
                    file_id = document.file_id
                    file_url = bot.get_file_url(file_id=file_id)
                    print(file_url)
            else:
                print(message.document.mime_type)
                file_id = message.document.file_id
                file_url = bot.get_file_url(file_id=file_id)
                print(file_url)

It only handles the last photo uploaded.

@coder2020official
Copy link
Collaborator

same as #2391
also do not use chatgpt

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

No branches or pull requests

2 participants