`commands` in `@dp.message_handler` doesn't work with photos
See original GitHub issueDispatcher -> message_handler -> command with photo
My setup
- Operating System: Windows 10
- Python Version: Python 3.7.3
- aiogram version: aiogram==2.13
Expected Behavior
Bot should receive and process command with attached photo.
Current Behavior
I can’t send command and photo together.
Description of failure
@dp.message_handler(commands=['mycommand'], content_types=[types.ContentType.TEXT, types.ContentType.PHOTO])
async def command_watermark(message: types.Message):
# If you send a command, then the code is reproduced here
# If you send a command with a photo, then the code is ignored here.
Help please
Can I do what I want or is it not possible? Please tell me what is the error or another method of solution.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Dispatcher — aiogram 2.23.1 documentation
Decorator for message handler. Examples: Simple commands handler: @dp.message_handler(commands=['start', 'welcome', 'about']) async def cmd_handler(message: ...
Read more >How to send photos on telegram with python
I am trying to send a photo that I have on my computer to my telegram bot chat when I issue the command...
Read more >Message Handler - Not Working with Filter.Command & ...
The idea is to accept single or multiple images from the user and get a command i.e. /crop or /removebg and get the...
Read more >Dispatcher — aiogram 2.2 documentation
This handler works only if state is None (by default). ... PHOTO | ContentType. ... @dp.message_handler(commands=['command']) @dp.message_handler(lambda ...
Read more >Bring your Telegram Chatbot to the next level
Telegram Bot can work with a Pull or with a Push mechanism (see further Webhooks). ... dp = updater.dispatcher # define command handler...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@bpqq You tried only like below?
@dp.message_handler(commands=['mycommand'], content_types=[types.ContentType.PHOTO])And you can try log it to console and check what you got.
After that method
command_watermarkcreate new oneSomething like that, maybe you need change your logging to print ou pprint ou ppretty.
You should use
captionfield instead oftextfor all content types != ContentType.TEXT.