Skip to content

Commit 05cc2dd

Browse files
authored
Merge pull request #12 from openziti/dev
Add more detail about user who starred the repo
2 parents fa02770 + b0480ef commit 05cc2dd

File tree

1 file changed

+56
-1
lines changed

1 file changed

+56
-1
lines changed

zhook.py

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,64 @@ def addWatchDetails(self):
279279
self.body["text"] = f"{self.createTitle()} #stargazer"
280280
login = self.senderJson["login"]
281281
loginUrl = self.senderJson["html_url"]
282+
userUrl = self.senderJson["url"]
282283
starCount = self.repoJson["stargazers_count"]
283284

284-
bodyText = f"[{login}]({loginUrl}) is stargazer number {starCount}"
285+
bodyText = f"[{login}]({loginUrl}) is stargazer number {starCount}\n\n"
286+
287+
try:
288+
r = requests.get(userUrl)
289+
print(f"Get User Info Response Status: {r.status_code}")
290+
# print(r.headers)
291+
# print(r.content)
292+
293+
userDetailsJson = json.loads(r.content)
294+
295+
name = userDetailsJson['name']
296+
company = userDetailsJson['company']
297+
location = userDetailsJson['location']
298+
email = userDetailsJson['email']
299+
twitter = userDetailsJson['twitter_username']
300+
blog = userDetailsJson['blog']
301+
bio = userDetailsJson['bio']
302+
303+
if name is not None and name:
304+
bodyText += f"\nName: {name} "
305+
306+
if company is not None and company:
307+
bodyText += f"\nCompany: {company} "
308+
309+
if location is not None and location:
310+
bodyText += f"\nLocation: {location} "
311+
312+
if email is not None and email:
313+
bodyText += f"\nEmail: {email} "
314+
315+
if twitter is not None and twitter:
316+
bodyText += f"\nTwitter: {twitter} "
317+
318+
if blog is not None and blog:
319+
bodyText += f"\nBlog: {blog} "
320+
321+
if bio is not None and bio:
322+
bodyText += f"\nBio: {bio} "
323+
324+
except Exception as e:
325+
print(f"Exception retrieving user info: {e}")
326+
327+
try:
328+
# HTML not supported in Mattermost markdown...
329+
# bodyText += "\n\n<details><summary>GitHub Stats</summary>"
330+
bodyText += f"\n\n![Github Stats](https://github-readme-stats.vercel.app/api?username={login}&hide=stars)"
331+
# bodyText += "\n</details>"
332+
333+
# These stats only cover the repos in the user's home (not all languages used in commits in any repo...)
334+
# bodyText += "\n\n<details><summary>Top Langs</summary>"
335+
# bodyText += f"\n\n![Top Langs](https://github-readme-stats.vercel.app/api/top-langs/?username={login}&layout=compact)"
336+
# bodyText += "\n</details>"
337+
except Exception as e:
338+
print(f"Exception retrieving stats image: {e}")
339+
285340
self.attachment["thumb_url"] = self.watchThumbnail
286341
self.attachment["color"] = self.watchColor
287342
self.attachment["text"] = bodyText

0 commit comments

Comments
 (0)