diff options
Diffstat (limited to 'main.py')
-rwxr-xr-x | main.py | 39 |
1 files changed, 20 insertions, 19 deletions
@@ -33,31 +33,32 @@ def register_signald(number): s.verify(code) -def handle_response(response): +def handle_replies(replies): answer = "" - replies = response.json()['reply'] for reply in replies: - # handle annotations - local_answer = reply['text'] + answer = reply['text'] for annotation in reply["annotations"]: - atype = annotation["type"] - aextra = annotation["extra"] - - if atype == "command": - local_answer = f"/{local_answer}: " - elif atype == "link": - local_answer = f"{aextra} ({local_answer})" - elif atype == "bold": - local_answer = f"*{local_answer}*" - elif atype == "italic": - local_answer = f"_{local_answer}_" - elif atype == "strikethrough": - local_answer = f"~{local_answer}~" - answer += local_answer - + a_type = annotation["type"] + a_extra = annotation["extra"] + + if a_type == "command": + answer = f"/{answer}: {handle_replies(a_extra)}\n" + elif a_type == "link": + answer = f"{a_extra} ({answer})" + elif a_type == "bold": + answer = f"*{answer}*" + elif a_type == "italic": + answer = f"_{answer}_" + elif a_type == "strikethrough": + answer = f"~{answer}~" return answer +def handle_response(response): + replies = response.json()['reply'] + return handle_replies(replies) + + def startup(number): s = Signal(number) |