Skip to content

Commit

Permalink
fix multimessage
Browse files Browse the repository at this point in the history
  • Loading branch information
jacklowrie committed Oct 15, 2022
1 parent 6fb293b commit f94fe0b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
39 changes: 17 additions & 22 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,25 @@
# https://regex101.com/r/eMmguY/1
@app.message(re.compile(r"@(\d+\b)"))
def post_link(say, context, event):
# build message contents
text = ""
for match in context['matches']:
url = posts_url + match

blocks = [{
"type": "section",
"text": {
"type": "mrkdwn",
"text": f"<{url}|View post {match} on Piazza>"
}

}]

thread_ts = event.get("thread_ts", None)
if thread_ts == None:
say(
blocks = blocks,
thread_ts = event.get("ts"),
reply_broadcast = True
)
else:
say(
blocks = blocks,
thread_ts = thread_ts
)
text += f"<{url}|View post {match} on Piazza>\n"

# send the message
thread_ts = event.get("thread_ts", None)
if thread_ts == None:
say(
text = text.strip("\n"),
thread_ts = event.get("ts"),
reply_broadcast = True
)
else:
say(
blocks = text.strip("\n"),
thread_ts = thread_ts
)


# Run the app
Expand Down
Empty file added test.py
Empty file.

0 comments on commit f94fe0b

Please sign in to comment.