Make "created a comment on" more readable with "commented on"

This commit is contained in:
jesopo 2018-11-06 17:05:40 +00:00
parent 367657901d
commit 2bdac13752

View file

@ -3,6 +3,12 @@ from src import ModuleManager, utils
COMMIT_URL = "https://github.com/%s/commit/%s" COMMIT_URL = "https://github.com/%s/commit/%s"
COMMENT_ACTION = {
"created": "commented",
"edited": "edited a comment",
"deleted": "deleted a comment"
}
@utils.export("channelset", {"setting": "github-hook", @utils.export("channelset", {"setting": "github-hook",
"help": ("Disable/Enable showing BitBot's github commits in the " "help": ("Disable/Enable showing BitBot's github commits in the "
"current channel"), "hidden": True}) "current channel"), "hidden": True})
@ -76,12 +82,13 @@ class Module(ModuleManager.BaseModule):
author, message, url)) author, message, url))
return outputs return outputs
def commit_comment(self, event, full_name, data): def commit_comment(self, event, full_name, data):
action = data["action"] action = data["action"]
commit = data["commit_id"][:8] commit = data["commit_id"][:8]
commenter = data["comment"]["user"]["login"] commenter = data["comment"]["user"]["login"]
url = data["comment"]["html_url"] url = data["comment"]["html_url"]
return ["(%s) [commit/%s] %s %s a comment" % return ["(%s) [commit/%s] %s commented" %
(full_name, commit, commenter, action)] (full_name, commit, commenter, action)]
def pull_request(self, event, full_name, data): def pull_request(self, event, full_name, data):
@ -108,8 +115,9 @@ class Module(ModuleManager.BaseModule):
pr_title = data["pull_request"]["title"] pr_title = data["pull_request"]["title"]
commenter = data["comment"]["user"]["login"] commenter = data["comment"]["user"]["login"]
url = data["comment"]["html_url"] url = data["comment"]["html_url"]
return ["(%s) [pr#%d] %s %s a review comment on: %s - %s" % return ["(%s) [pr#%d] %s %s on: %s - %s" %
(full_name, pr_number, commenter, action, pr_title, url)] (full_name, pr_number, commenter, COMMENT_ACTIONS[action], pr_title,
url)]
def issues(self, event, full_name, data): def issues(self, event, full_name, data):
action = data["action"] action = data["action"]
@ -126,6 +134,6 @@ class Module(ModuleManager.BaseModule):
type = "pr" if "pull_request" in data["issue"] else "issue" type = "pr" if "pull_request" in data["issue"] else "issue"
commenter = data["comment"]["user"]["login"] commenter = data["comment"]["user"]["login"]
url = data["comment"]["html_url"] url = data["comment"]["html_url"]
return ["(%s) [%s#%d] %s %s a comment on: %s - %s" % return ["(%s) [%s#%d] %s %s on: %s - %s" %
(full_name, type, issue_number, commenter, action, issue_title, (full_name, type, issue_number, commenter, COMMENT_ACTIONS[action],
url)] issue_title, url)]