Skip to content

Commit

Permalink
Better zulip messages for github rss feeds (includes commit author)
Browse files Browse the repository at this point in the history
  • Loading branch information
kmill committed Feb 10, 2022
1 parent 113f9cb commit 05bac85
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions zulip/integrations/rss/rss-bot
Expand Up @@ -170,12 +170,29 @@ def send_zulip(entry: Any, feed_name: str) -> Dict[str, Any]:
if opts.unwrap:
body = unwrap_text(body)

content = "**[{}]({})**\n{}\n{}".format(
entry.title,
entry.link,
strip_tags(body),
entry.link,
) # type: str
body = strip_tags(body)

if m := re.match("Recent Commits to (\w+):", feed_name):
repo = m.group(1) # type: str
body = re.sub(r"\((#\d+)\)", lambda m: "(" + repo + m.group(1) + ")", body, 1)

author_detail = entry.author # type: str
if 'author_detail' in entry and 'href' in entry.author_detail:
author_detail = "[{}]({})".format(author_detail, entry.author_detail.href)

content = "{}\n\nAuthored-by: {}\n[Commit]({})".format(
body,
author_detail,
entry.link,
) # type: str

else:
content = "**[{}]({})**\n{}\n{}".format(
entry.title,
entry.link,
body,
entry.link,
) # type: str

if opts.math:
content = content.replace("$", "$$")
Expand Down

0 comments on commit 05bac85

Please sign in to comment.