Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Tzaoh
Copy link

@Tzaoh Tzaoh commented Sep 15, 2016

I would like to attach several handlers.
In the future maybe this could be updated to use threads?

@Tzaoh
Copy link
Author

Tzaoh commented Sep 15, 2016

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.

@luckydonald
Copy link
Owner

maybe process_handlers and start could be merged some way to make it cleaner.
Yeah, that's a good idea then.

Can you update the documentation, too, when done? I'd be happy to merge then

@luckydonald
Copy link
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
@luckydonald
Copy link
Owner

Nice. Thank you.

How can we archive backwards compatibility?
Keep a deprecated def message around?

from luckydonaldUtils.functions import deprecated 

@deprecated
def message(self, function):
    self.add_handler(function)
    self.process_handler()

@mv-go
Copy link

mv-go commented May 21, 2017

Any updates on this merge? Would really love to use multiple handlers!

@luckydonald
Copy link
Owner

With compatibility code for the old message decorator, it would probably be mergeable.
I'll see if I find time this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants