2021-04-27 15:15:09 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
from pyln.client import Plugin
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plugin = Plugin()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@plugin.subscribe("custom")
|
2025-08-17 09:39:12 +09:30
|
|
|
def on_custom_notification(origin, message, **kwargs):
|
|
|
|
|
plugin.log("Got a custom notification {} from plugin {}".format(message, origin))
|
2021-04-27 15:15:09 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@plugin.method("emit")
|
|
|
|
|
def emit(plugin):
|
|
|
|
|
"""Emit a simple string notification to topic "custom"
|
|
|
|
|
"""
|
2025-08-17 09:38:52 +09:30
|
|
|
plugin.notify("custom", {'message': "Hello world"})
|
2021-04-27 15:15:09 +02:00
|
|
|
|
|
|
|
|
|
2021-04-29 11:18:19 +02:00
|
|
|
@plugin.method("faulty-emit")
|
|
|
|
|
def faulty_emit(plugin):
|
|
|
|
|
"""Emit a simple string notification to topic "custom"
|
|
|
|
|
"""
|
2025-08-17 09:38:52 +09:30
|
|
|
plugin.notify("ididntannouncethis", {'message': "Hello world"})
|
2021-04-29 11:18:19 +02:00
|
|
|
|
|
|
|
|
|
2021-04-28 18:36:56 +02:00
|
|
|
@plugin.subscribe("pay_success")
|
2025-08-17 09:39:31 +09:30
|
|
|
def on_pay_success(origin, pay_success, **kwargs):
|
2021-04-28 18:36:56 +02:00
|
|
|
plugin.log(
|
|
|
|
|
"Got a pay_success notification from plugin {} for payment_hash {}".format(
|
|
|
|
|
origin,
|
2025-08-17 09:39:31 +09:30
|
|
|
pay_success['payment_hash']
|
2021-04-28 18:36:56 +02:00
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2025-08-14 11:48:05 +09:30
|
|
|
@plugin.subscribe("pay_part_start")
|
2025-08-17 09:39:12 +09:30
|
|
|
def on_pay_part_start(origin, **kwargs):
|
|
|
|
|
plugin.log("Got pay_part_start: {}".format(kwargs))
|
2025-08-14 11:48:05 +09:30
|
|
|
|
|
|
|
|
|
|
|
|
|
@plugin.subscribe("pay_part_end")
|
2025-08-17 09:39:12 +09:30
|
|
|
def on_pay_part_end(origin, **kwargs):
|
|
|
|
|
plugin.log("Got pay_part_end: {}".format(kwargs))
|
2025-08-14 11:48:05 +09:30
|
|
|
|
|
|
|
|
|
2021-04-29 11:18:19 +02:00
|
|
|
@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()
|