python-telegram-bot icon indicating copy to clipboard operation
python-telegram-bot copied to clipboard

How to use per_message=True?

Open remokon opened this issue 2 years ago • 3 comments

Issue I am facing

Imagine there is some user input based on a specific search command, called within ConversationHandler with standard per_chat and per_user as True. Let's say this user was to type /search x, which yields a finite number of results featuring a reply markup that allows the user to cycle through these results. If the same user were to initiate a new search, /search y, and wanted to go back to the first search to still go through the results, they'd find that it is actually cycling through y-based results, not the x-based it once was on that message. Therefore, one would naturally incline towards per_message=True. However, having to use only CallbackQueryHandler objects, it is hard to understand how to trigger the conversation (like in CommandHandler's command argument).

Would it be possible to showcase an example?

Traceback to the issue

No response

Related part of your code

No response

Operating System

Ubuntu

Version of Python, python-telegram-bot & dependencies

python-telegram-bot 21.0.1
Bot API 7.1
Python 3.12.1 (main, Feb  4 2024, 19:38:15) [GCC 11.4.0]

remokon avatar Mar 18 '24 22:03 remokon

You could just trigger the conv by the first button press of the generated menu?

Poolitzer avatar Mar 19 '24 13:03 Poolitzer

You could just trigger the conv by the first button press of the generated menu?

Yes, that's an option! Although:

  1. I feel like it's overcomplicating something as simple as an input like /search x, since user input is required for the use case I was referring to
  2. that would still mean that I need to handle query data after that first command (I believe?) while in fact all I need is that initial input and then navigate through results, all in the same message
  3. will that solve the problem of previous messages being updated according to the latest message data?

Finally, I am actually struggling to make a working example of that, hence why I'd love to see an example of how per_message=True can be used effectively.

remokon avatar Mar 19 '24 18:03 remokon

This issue has been automatically closed due to inactivity. Feel free to comment in order to reopen or ask again in our Telegram support group at https://t.me/pythontelegrambotgroup.

github-actions[bot] avatar Mar 26 '24 02:03 github-actions[bot]