From 2bdac1375250302eaa66f5684887d65092b9761c Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 6 Nov 2018 17:05:40 +0000 Subject: [PATCH] Make "created a comment on" more readable with "commented on" --- modules/github.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/modules/github.py b/modules/github.py index 6b8c51a3..48c95488 100644 --- a/modules/github.py +++ b/modules/github.py @@ -3,6 +3,12 @@ from src import ModuleManager, utils 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", "help": ("Disable/Enable showing BitBot's github commits in the " "current channel"), "hidden": True}) @@ -76,12 +82,13 @@ class Module(ModuleManager.BaseModule): author, message, url)) return outputs + def commit_comment(self, event, full_name, data): action = data["action"] commit = data["commit_id"][:8] commenter = data["comment"]["user"]["login"] url = data["comment"]["html_url"] - return ["(%s) [commit/%s] %s %s a comment" % + return ["(%s) [commit/%s] %s commented" % (full_name, commit, commenter, action)] def pull_request(self, event, full_name, data): @@ -108,8 +115,9 @@ class Module(ModuleManager.BaseModule): pr_title = data["pull_request"]["title"] commenter = data["comment"]["user"]["login"] url = data["comment"]["html_url"] - return ["(%s) [pr#%d] %s %s a review comment on: %s - %s" % - (full_name, pr_number, commenter, action, pr_title, url)] + return ["(%s) [pr#%d] %s %s on: %s - %s" % + (full_name, pr_number, commenter, COMMENT_ACTIONS[action], pr_title, + url)] def issues(self, event, full_name, data): action = data["action"] @@ -126,6 +134,6 @@ class Module(ModuleManager.BaseModule): type = "pr" if "pull_request" in data["issue"] else "issue" commenter = data["comment"]["user"]["login"] url = data["comment"]["html_url"] - return ["(%s) [%s#%d] %s %s a comment on: %s - %s" % - (full_name, type, issue_number, commenter, action, issue_title, - url)] + return ["(%s) [%s#%d] %s %s on: %s - %s" % + (full_name, type, issue_number, commenter, COMMENT_ACTIONS[action], + issue_title, url)]