Add inline button to update status messages #354
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Good evening!
I've made a few small changes to accommodate my own preferences when it comes to Telegram Bot UX. I'm using these changes for myself, but I'd like to offer them to be integrated upstream, if you like them.
In this change, I'm adding a configuration option that, when enabled, causes an "update" button to appear under the status message. Pressing this button triggers a manual update of the status, just as if the
/status
command had been used.Personally, I like inline buttons as a way to interact with bots, and I was missing this feature.
The default is for this button to not show up (like before), but users who want it can now enable it in their config.
To accomplish this change, I refactored the way message data is passed around in the
notifications.py
module (and also, to a lesser extent, in themain.py
module). I've added a new class that represents a Telegram message to send, with all its parameters. This class is useful when a message is constructed before it is known how exactly that message gets sent (whether it's sent as a reply, or as an update to an existing message...) - the message-specific metadata can get passed around in a bundle, and the method that handles the actual sending doesn't need to know all of the specifics of how this message is supposed to be set up.Messages can still easily be sent directly. Rather than refactoring every single occurrence of message sending, I am using my new class only where it's most useful. In the future, it can be used in more places if it's beneficial.
Let me know what you think.