2021-04-27 15:15:09 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
from pyln.client import Plugin
|
|
|
|
|
|
|
|
|
|
|
|
plugin = Plugin()
|
|
|
|
|
|
|
|
|
|
|
|
@plugin.subscribe("custom")
|
2021-04-28 16:40:35 +02:00
|
|
|
def on_custom_notification(origin, payload, **kwargs):
|
|
|
|
plugin.log("Got a custom notification {} from plugin {}".format(payload, origin))
|
2021-04-27 15:15:09 +02:00
|
|
|
|
|
|
|
|
|
|
|
@plugin.method("emit")
|
|
|
|
def emit(plugin):
|
|
|
|
"""Emit a simple string notification to topic "custom"
|
|
|
|
"""
|
|
|
|
plugin.notify("custom", "Hello world")
|
|
|
|
|
|
|
|
|
2021-04-29 11:18:19 +02:00
|
|
|
@plugin.method("faulty-emit")
|
|
|
|
def faulty_emit(plugin):
|
|
|
|
"""Emit a simple string notification to topic "custom"
|
|
|
|
"""
|
|
|
|
plugin.notify("ididntannouncethis", "Hello world")
|
|
|
|
|
|
|
|
|
|
|
|
@plugin.subscribe("ididntannouncethis")
|
|
|
|
def on_faulty_emit(origin, payload, **kwargs):
|
|
|
|
"""We should never receive this as it gets dropped.
|
|
|
|
"""
|
|
|
|
plugin.log("Got the ididntannouncethis event")
|
|
|
|
|
|
|
|
|
2021-04-27 15:15:09 +02:00
|
|
|
plugin.add_notification_topic("custom")
|
|
|
|
plugin.run()
|