aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorniklas <niklas@niklashalle.net>2020-08-26 12:26:37 +0200
committerniklas <niklas@niklashalle.net>2020-08-26 12:26:37 +0200
commitaf5a7898aa230d0f32c511c083dedc031c1b4334 (patch)
treece5d924b685b454ea16e8a9eb3da56e940677046
parent6a82d692200606a25054857739c71f54db812be9 (diff)
downloadn_frontend_signal-af5a7898aa230d0f32c511c083dedc031c1b4334.tar.gz
n_frontend_signal-af5a7898aa230d0f32c511c083dedc031c1b4334.zip
fixed nested annotations
-rwxr-xr-xmain.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/main.py b/main.py
index ebb03aa..33dda13 100755
--- a/main.py
+++ b/main.py
@@ -35,22 +35,25 @@ def register_signald(number):
def handle_replies(replies):
answer = ""
+ if type(replies) is not list:
+ replies = [replies]
for reply in replies:
- answer = reply['text']
+ l_answer = reply['text']
for annotation in reply["annotations"]:
a_type = annotation["type"]
a_extra = handle_replies(annotation["extra"])
if a_type == "command":
- answer = f"/{answer}: {a_extra}\n"
+ l_answer = f"/{l_answer}: {a_extra}\n"
elif a_type == "link":
- answer = f"{a_extra} ({answer})"
+ l_answer = f"{a_extra} ({l_answer})"
elif a_type == "bold":
- answer = f"*{answer}*"
+ l_answer = f"*{l_answer}*"
elif a_type == "italic":
- answer = f"_{answer}_"
+ l_answer = f"_{l_answer}_"
elif a_type == "strikethrough":
- answer = f"~{answer}~"
+ l_answer = f"~{l_answer}~"
+ answer += l_answer
return answer