From 03056b5664c8a7cf094ae92555fef4d67ab48524 Mon Sep 17 00:00:00 2001 From: niklas Date: Mon, 24 Aug 2020 09:06:50 +0200 Subject: works --- main.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 6adf802..d883eff 100755 --- a/main.py +++ b/main.py @@ -37,6 +37,7 @@ def register_signald(number): def startup(number): s = Signal(number) + # with args @s.chat_handler("/([^\\s]+)\\s+(.*)", order=10) # This is case-insensitive. def klinger(message, match): # Returning `False` as the first argument will cause matching to continue @@ -45,7 +46,25 @@ def startup(number): # TODO: try catch response = requests.post('http://localhost:18080', - json={"command": match.group(1), "arguments": match.group(2)}) + json={"command": match.group(1), "arguments": strip(match.group(2))}) + + answer = "" + replies = response.json()['reply'] + for reply in replies: + answer += reply['text'] + + return stop, answer + + # no args + @s.chat_handler("/(.+)", order=20) # This is case-insensitive. + def klinger(message, match): + # Returning `False` as the first argument will cause matching to continue + # after this handler runs. + stop = True + + # TODO: try catch + response = requests.post('http://localhost:18080', + json={"command": match.group(1), "arguments": ""}) answer = "" replies = response.json()['reply'] -- cgit v1.2.3-54-g00ecf