Search code examples
pythonpython-3.xnotify

How do I get the currently registered channel in notify_run, Python


I am using notify_run module to create a new channel, followed by using it to push notifications. I am successful in crating channel from within the code and using it as well. But, I would like to get the details of the channel registered/currently in use. I have tried to store the output from command prompt, and use that later.

notify = Notify()
k = str(notify.register())
l = str(k.split('\n')[0])
channel_link = l.split(': ')[1]

I would like to know is there is any other method to do so. The documentation does not specify much.


Solution

  • It looks like you're parsing the response for the endpoint URL, if that's the case you can do the following to get it..

    notify = Notify()
    channel = notify.register()
    endpoint = channel.endpoint
    print(endpoint) # https://notify.run/<channel_code>
    

    You can also get the channel_page, which is a page that has the channel info, QR code, and link to subscribe.

    channel_page = channel.channel_page
    print(channel_page) # https://notify.run/c/<channel_page_code>