Skip to content

Commit f94fe0b

Browse files
committed
fix multimessage
1 parent 6fb293b commit f94fe0b

File tree

2 files changed

+17
-22
lines changed

2 files changed

+17
-22
lines changed

app.py

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,25 @@
1919
# https://regex101.com/r/eMmguY/1
2020
@app.message(re.compile(r"@(\d+\b)"))
2121
def post_link(say, context, event):
22+
# build message contents
23+
text = ""
2224
for match in context['matches']:
2325
url = posts_url + match
24-
25-
blocks = [{
26-
"type": "section",
27-
"text": {
28-
"type": "mrkdwn",
29-
"text": f"<{url}|View post {match} on Piazza>"
30-
}
31-
32-
}]
33-
34-
thread_ts = event.get("thread_ts", None)
35-
if thread_ts == None:
36-
say(
37-
blocks = blocks,
38-
thread_ts = event.get("ts"),
39-
reply_broadcast = True
40-
)
41-
else:
42-
say(
43-
blocks = blocks,
44-
thread_ts = thread_ts
45-
)
26+
text += f"<{url}|View post {match} on Piazza>\n"
27+
28+
# send the message
29+
thread_ts = event.get("thread_ts", None)
30+
if thread_ts == None:
31+
say(
32+
text = text.strip("\n"),
33+
thread_ts = event.get("ts"),
34+
reply_broadcast = True
35+
)
36+
else:
37+
say(
38+
blocks = text.strip("\n"),
39+
thread_ts = thread_ts
40+
)
4641

4742

4843
# Run the app

test.py

Whitespace-only changes.

0 commit comments

Comments
 (0)