|
24 | 24 | issue = repo.get_issue(number=issue_number) |
25 | 25 | comment_body = context_dict["event"]["comment"]["body"] |
26 | 26 | pr = context_dict["event"]["issue"].get("pull_request") |
| 27 | +commenter = context_dict["event"]["comment"]["user"]["login"] |
27 | 28 |
|
28 | | -# Assign tagged used to the issue if the comment includes the trigger phrase |
29 | 29 | body = comment_body.lower() |
30 | | -if "@aeon-actions-bot" in body and "assign" in body and not pr: |
31 | | - mentioned_users = re.findall(r"@[a-zA-Z0-9_-]+", comment_body) |
32 | | - mentioned_users = [user[1:] for user in mentioned_users] |
33 | | - mentioned_users.remove("aeon-actions-bot") |
| 30 | +if "@aeon-actions-bot" in body and not pr: |
| 31 | + # Assign commenter if comment includes "assign me" |
| 32 | + if "assign me" in body: |
| 33 | + issue.add_to_assignees(commenter) |
| 34 | + # Assign tagged used to the issue if the comment includes the trigger phrase |
| 35 | + elif "assign" in body: |
| 36 | + mentioned_users = re.findall(r"@[a-zA-Z0-9_-]+", comment_body) |
| 37 | + mentioned_users = [user[1:] for user in mentioned_users] |
| 38 | + mentioned_users.remove("aeon-actions-bot") |
34 | 39 |
|
35 | | - for user in mentioned_users: |
36 | | - user_obj = g.get_user(user) |
37 | | - permission = repo.get_collaborator_permission(user_obj) |
| 40 | + for user in mentioned_users: |
| 41 | + user_obj = g.get_user(user) |
| 42 | + permission = repo.get_collaborator_permission(user_obj) |
38 | 43 |
|
39 | | - if permission in ["admin", "write"]: |
40 | | - issue.add_to_assignees(user) |
41 | | - else: |
42 | | - # First check if the user is already assigned to this issue |
43 | | - if user in [assignee.login for assignee in issue.assignees]: |
44 | | - continue |
| 44 | + if permission in ["admin", "write"]: |
| 45 | + issue.add_to_assignees(user) |
| 46 | + else: |
| 47 | + # First check if the user is already assigned to this issue |
| 48 | + if user in [assignee.login for assignee in issue.assignees]: |
| 49 | + continue |
45 | 50 |
|
46 | | - # search for open issues only |
47 | | - query = f"repo:{repo.full_name} is:issue is:open assignee:{user}" |
48 | | - issues_assigned_to_user = g.search_issues(query) |
49 | | - assigned_count = issues_assigned_to_user.totalCount |
| 51 | + # search for open issues only |
| 52 | + query = f"repo:{repo.full_name} is:issue is:open assignee:{user}" |
| 53 | + issues_assigned_to_user = g.search_issues(query) |
| 54 | + assigned_count = issues_assigned_to_user.totalCount |
50 | 55 |
|
51 | | - if assigned_count >= 2: |
52 | | - # link to issue |
53 | | - assigned_issues_list = [ |
54 | | - f"[#{assigned_issue.number}]({assigned_issue.html_url})" |
55 | | - for assigned_issue in issues_assigned_to_user |
56 | | - ] |
| 56 | + if assigned_count >= 2: |
| 57 | + # link to issue |
| 58 | + assigned_issues_list = [ |
| 59 | + f"[#{assigned_issue.number}]({assigned_issue.html_url})" |
| 60 | + for assigned_issue in issues_assigned_to_user |
| 61 | + ] |
57 | 62 |
|
58 | | - comment_message = ( |
59 | | - f"@{user}, you already have {assigned_count} open issues assigned. " |
60 | | - "Users without write access are limited to self-assigning two" |
61 | | - "issues.\n\n" |
62 | | - "Here are the open issues assigned to you:\n" |
63 | | - + "\n".join( |
64 | | - f"- {issue_link}" for issue_link in assigned_issues_list |
| 63 | + comment_message = ( |
| 64 | + f"@{user}, you already have {assigned_count} " |
| 65 | + f"open issues assigned." |
| 66 | + "Users without write access are limited to self-assigning two" |
| 67 | + "issues.\n\n" |
| 68 | + "Here are the open issues assigned to you:\n" |
| 69 | + + "\n".join( |
| 70 | + f"- {issue_link}" for issue_link in assigned_issues_list |
| 71 | + ) |
65 | 72 | ) |
66 | | - ) |
67 | | - issue.create_comment(comment_message) |
68 | | - else: |
69 | | - issue.add_to_assignees(user) |
| 73 | + issue.create_comment(comment_message) |
| 74 | + else: |
| 75 | + issue.add_to_assignees(user) |
0 commit comments