aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorniklas <niklas@niklashalle.net>2020-08-24 09:06:50 +0200
committerniklas <niklas@niklashalle.net>2020-08-24 09:06:50 +0200
commit03056b5664c8a7cf094ae92555fef4d67ab48524 (patch)
tree542b1ee5e64c8725a77c50ca67d202cee912af6e
parent0e7032a327410ea1a979a363fc231af0265c30ec (diff)
downloadn_frontend_signal-03056b5664c8a7cf094ae92555fef4d67ab48524.tar.gz
n_frontend_signal-03056b5664c8a7cf094ae92555fef4d67ab48524.zip
works
-rwxr-xr-xmain.py21
1 files changed, 20 insertions, 1 deletions
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']