22"""Update the latest Weekly Check-in Discussion body with participation summary."""
33
44import os
5+ import re
56from pathlib import Path
67
78import requests
1617}
1718
1819_CONFIG_PATH = Path (__file__ ).resolve ().parent .parent / "standup-contributors.yml"
19- with open (_CONFIG_PATH ) as _f :
20- CONTRIBUTORS = [c ["username" ] for c in yaml .safe_load (_f )["contributors" ]]
20+
21+
22+ def load_contributors ():
23+ """Return configured proactive check-in prompts, if any."""
24+ if not _CONFIG_PATH .exists ():
25+ return []
26+ with open (_CONFIG_PATH ) as f :
27+ data = yaml .safe_load (f ) or {}
28+ return [c ["username" ] for c in data .get ("contributors" , [])]
29+
30+
31+ CONTRIBUTORS = load_contributors ()
32+ BOT_LOGIN = "payjoin-bot"
33+ SUCCESS_MARKER = "### Shipped"
34+ TRIGGER_RE = re .compile (r"(?im)(^|\s)/check-in\b" )
2135
2236
2337def graphql (query , variables = None ):
@@ -70,8 +84,10 @@ def get_discussion_comments(discussion_id):
7084 comments(first: 50) {
7185 nodes {
7286 body
87+ author { login }
7388 replies(first: 50) {
7489 nodes {
90+ body
7591 author { login }
7692 }
7793 }
@@ -87,8 +103,9 @@ def get_discussion_comments(discussion_id):
87103
88104
89105def check_participation (comments ):
90- """Return list of contributors who replied to their thread ."""
106+ """Return list of contributors who participated in this check-in ."""
91107 participated = []
108+ seen = set ()
92109 for comment in comments :
93110 body = comment ["body" ]
94111 for user in CONTRIBUTORS :
@@ -97,8 +114,19 @@ def check_participation(comments):
97114 reply_authors = {
98115 r ["author" ]["login" ] for r in comment ["replies" ]["nodes" ] if r ["author" ]
99116 }
100- if user in reply_authors :
117+ if user in reply_authors and user not in seen :
101118 participated .append (user )
119+ seen .add (user )
120+ author = (comment .get ("author" ) or {}).get ("login" )
121+ if not author or author in seen or not TRIGGER_RE .search (body ):
122+ continue
123+ for reply in comment ["replies" ]["nodes" ]:
124+ reply_author = (reply .get ("author" ) or {}).get ("login" )
125+ reply_body = reply .get ("body" ) or ""
126+ if reply_author == BOT_LOGIN and reply_body .startswith (SUCCESS_MARKER ):
127+ participated .append (author )
128+ seen .add (author )
129+ break
102130 return participated
103131
104132
0 commit comments