Update receiver.py to allow multiple msg handlers#98
Open
Tzaoh wants to merge 2 commits intoluckydonald:masterfrom
Open
Update receiver.py to allow multiple msg handlers#98Tzaoh wants to merge 2 commits intoluckydonald:masterfrom
Tzaoh wants to merge 2 commits intoluckydonald:masterfrom
Conversation
Author
|
Actual code to make this work is: def main():
tg = Telegram(
telegram="/usr/bin/telegram-cli",
pubkey_file="/etc/share/telegram-cli/server.pub"
)
receiver = tg.receiver
sender = tg.sender
receiver.start()
receiver.add_handler(text_handler(sender))
receiver.add_handler(media_handler(sender))
receiver.process_handlers()
receiver.stop()maybe process_handlers and start could be merged some way to make it cleaner. |
Owner
Can you update the documentation, too, when done? I'd be happy to merge then |
Owner
|
Just say that you can register multiple handers, and edit the example code. |
This will show how you could split logic processing into multiple_handlers. Sorry for the long delay i am a bit busy these days
Owner
|
Nice. Thank you. How can we archive backwards compatibility? from luckydonaldUtils.functions import deprecated
@deprecated
def message(self, function):
self.add_handler(function)
self.process_handler() |
|
Any updates on this merge? Would really love to use multiple handlers! |
Owner
|
With compatibility code for the old |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I would like to attach several handlers.
In the future maybe this could be updated to use threads?