Open david1602 opened 7 years ago
But the TelegramBot#onText() implies we are listening on text messages, not images. A unified solution would require that the user checks, in their listener, whether they have received a text message or an image, etc. I believe that would create too much friction. I would prefer going with a separate method.
I think it would be possible to use a middleware (#313) to trigger onText for an image if the user wants...
Possibly. But middlewares are not yet implemented.
@GochoMugo couldn't we pass another optional options parameter or so that would also listen to images?
I have:
Introduction
I personally think the
onText
of the bot API should also listen to image captions. I think the issue here is that if you check pictures via theonMessage
function, the text is within thecaption
property rather than thetext
property of the message.Currently if you register a
bot.onText(/test/, callback)
,test
will match in messages, but won't match in image captions.Example
The example would be 1:1 the same, or optionally there could be an
onCaption
event. I'd prefer a unified response to captions and messages, but that's just me.My bot dynamically adds listeners, so it looks sort of like this:
Wouldn't it work to update this? The question is if that's a desired behavior by the community anyway.