From 2b3059be0ca7bd64335af88e4bf63781aced3624 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Mon, 5 Nov 2018 16:58:19 +0100 Subject: [PATCH] plugin: Have the helloworld plugin accept a configure message Just customizes the greeting, the actual sending is in the next commit. Signed-off-by: Christian Decker <@cdecker> --- contrib/helloworld-plugin/main.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/contrib/helloworld-plugin/main.py b/contrib/helloworld-plugin/main.py index 290b6981a..3ee7ee2f1 100755 --- a/contrib/helloworld-plugin/main.py +++ b/contrib/helloworld-plugin/main.py @@ -11,17 +11,21 @@ import json import sys +greeting = "World" + + def json_hello(request): greeting = "Hello {}".format(request['params']['name']) return greeting def json_init(request): + global greeting return { "options": [ {"name": "greeting", "type": "string", - "default": "World", + "default": greeting, "description": "What name should I call you?"}, ], "rpcmethods": [ @@ -36,7 +40,10 @@ def json_init(request): def json_configure(request): """The main daemon is telling us the relevant cli options """ - return None + global greeting + + greeting = request['params']['options']['greeting'] + return "ok" def json_ping(request): @@ -47,6 +54,7 @@ methods = { 'hello': json_hello, 'init': json_init, 'ping': json_ping, + 'configure': json_configure, } partial = ""