From 42fb3ad6d148fbaadf0dcb4d5e133319eec0ff22 Mon Sep 17 00:00:00 2001 From: Matt C Date: Thu, 29 Sep 2022 23:56:16 +0000 Subject: [PATCH] add status messages --- bot.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/bot.py b/bot.py index a517615..f5ee9be 100644 --- a/bot.py +++ b/bot.py @@ -1,11 +1,20 @@ from github import Github +import sys g = Github(open(".access_token").read().strip()) +def post_update(text): + repo = g.get_repo("crystalrfc-bot/status") + thread = repo.get_issue(1) + thread.create_comment(text + "\n Beep Boop! (I'm a bot, and this action was performed automagically.)") + targets = ['crystal-linux/.github', 'crystal-linux-packages/.github'] +status_text = "" + for tgt in targets: repo = g.get_repo(tgt) + status_text += f"# Examining {repo.full_name}\n" core_team = g.get_organization('crystal-linux').get_team_by_slug('core-team') core_team_members = core_team.get_members() @@ -14,6 +23,7 @@ for tgt in targets: for member in core_team_members: core_team_logins.append(member.login) + rfcs_passed = 0 for issue in repo.get_issues(): if 'RFC' in issue.title: print(f"Working on: {issue.title}") @@ -32,7 +42,17 @@ for tgt in targets: print(f"Total votes against resolution: {str(total_votes_against)}") if (total_votes_for/len(core_team_logins)) > 0.5: print("This RFC should be passed. Adding comment.") - issue.create_comment("This resolution has enough votes from Core Team mebers to be considered passed. Please close the issue once appropriate actions have been taken. - Beep Boop (I'm a bot, and this action was performed automatically)") + issue.create_comment("This resolution has enough votes from Core Team mebers to be considered passed. Please close the issue once appropriate actions have been taken. - Beep Boop (I'm a bot, and this action was performed automagically)") issue.lock("resolved") + rfcs_passed += 1 + status_text += f"* Suggested that {issue.title} be acted upon, as it has passed.\n" else: print("Not enough votes to pass") + + if rfcs_passed == 0: + status_text += "No action taken in this repo.\n" + +if status_text == "": + status_text = "Something has gone wrong! No actions were taken at *all*!" + +post_update(status_text) \ No newline at end of file