aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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']