Skip to content

Commit

Permalink
Add approve command (#819)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtOfCode- committed Jun 9, 2017
1 parent d866f79 commit be18612
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions chatcommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,24 @@ def single_random_user(ev_room):
# don't accept any parameters but still use the `command_dict` mappings


@check_permissions
def command_approve(message_parts, content_lower, ev_room, ev_user_id, wrap2, *args, **kwargs):
if ev_user_id in GlobalVars.code_privileged_users:
if len(message_parts) >= 2:
pr_num = message_parts[1]
resp = requests.post('{}/github/pr_approve/{}'.format(GlobalVars.metasmoke_host, pr_num))
if resp.status_code == 200:
return Response(command_status=True, message='Posted approval comment. PR will be merged automatically '
'if it\'s a blacklist PR.')
else:
return Response(command_status=False, message='Forwarding request to metasmoke returned HTTP ' +
resp.status_code + '. Check status manually.')
else:
return Response(command_status=False, message='Missing PR ID. Usage: !!/approve <id>')
else:
return Response(command_status=False, message='You don\'t have permission to do that.')


# --- Blacklist Functions --- #
# noinspection PyIncorrectDocstring,PyUnusedLocal
@check_permissions
Expand Down Expand Up @@ -1609,6 +1627,7 @@ def subcommand_autoflagged(msg_content, post_url, *args, **kwargs):
"!!/amicodeprivileged": command_code_privileged,
"!!/amicodepriviledged": command_code_privileged, # TODO: add typo warning?
"!!/apiquota": command_quota,
"!!/approve": command_approve,
"!!/blame": command_blame,
"!!/block": command_block,
"!!/brownie": command_brownie,
Expand Down

0 comments on commit be18612

Please sign in to comment.