Update bot.py

Signed-off-by: Matt C <matthew.compton@mymail.champlain.edu>
pull/1/head
Matt C 2 years ago committed by GitHub
parent 85c5f46f2d
commit c37055509a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2,34 +2,37 @@ from github import Github
g = Github(open(".access_token").read().strip())
repo = g.get_repo('crystal-linux/.github')
targets = ['crystal-linux/.github', 'crystal-linux-packages/.github']
core_team = g.get_organization('crystal-linux').get_team_by_slug('core-team')
core_team_members = core_team.get_members()
core_team_logins = []
for tgt in targets:
repo = g.get_repo(tgt)
for member in core_team_members:
core_team_logins.append(member.login)
core_team = g.get_organization('crystal-linux').get_team_by_slug('core-team')
core_team_members = core_team.get_members()
core_team_logins = []
for issue in repo.get_issues():
if 'RFC' in issue.title:
print(f"Working on: {issue.title}")
all_reactions = issue.get_reactions()
if all_reactions.totalCount != 0:
total_votes_for = 0
total_votes_against = 0
for reaction in all_reactions:
if reaction.user.login in core_team_logins:
#print(f"- {reaction.content}: by {reaction.user.login}")
if reaction.content == "+1":
total_votes_for += 1
elif reaction.content == "-1":
total_votes_against += 1
print(f"Total votes for resolution: {str(total_votes_for)}")
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.lock("resolved")
else:
print("Not enough votes to pass")
for member in core_team_members:
core_team_logins.append(member.login)
for issue in repo.get_issues():
if 'RFC' in issue.title:
print(f"Working on: {issue.title}")
all_reactions = issue.get_reactions()
if all_reactions.totalCount != 0:
total_votes_for = 0
total_votes_against = 0
for reaction in all_reactions:
if reaction.user.login in core_team_logins:
#print(f"- {reaction.content}: by {reaction.user.login}")
if reaction.content == "+1":
total_votes_for += 1
elif reaction.content == "-1":
total_votes_against += 1
print(f"Total votes for resolution: {str(total_votes_for)}")
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.lock("resolved")
else:
print("Not enough votes to pass")

Loading…
Cancel
Save