2023-12-14 11:22:44 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
from pyln.client import Plugin
|
2024-05-03 18:27:17 +02:00
|
|
|
from typing import Any, Optional
|
2023-12-14 11:22:44 +01:00
|
|
|
|
|
|
|
plugin = Plugin()
|
|
|
|
|
2024-05-04 01:28:40 +09:30
|
|
|
|
|
|
|
@plugin.method('dynamic-option-report')
|
|
|
|
def record_lookup(plugin):
|
|
|
|
return {'test-dynamic-config': plugin.get_option('test-dynamic-config')}
|
|
|
|
|
|
|
|
|
2024-05-03 18:27:17 +02:00
|
|
|
def on_config_change(plugin, config: str, value: Optional[Any]) -> None:
|
|
|
|
"""Callback method called when a config value is changed.
|
|
|
|
"""
|
|
|
|
plugin.log(f"Setting config {config} to {value}")
|
|
|
|
|
|
|
|
|
|
|
|
plugin.add_option(
|
|
|
|
name="test-dynamic-config",
|
|
|
|
description="A config option which can be changed at run-time",
|
|
|
|
default="initial",
|
|
|
|
dynamic=True,
|
|
|
|
on_change=on_config_change,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2023-12-14 11:22:44 +01:00
|
|
|
plugin.run()
|