diff options
| author | 2019-06-26 14:37:26 +0100 | |
|---|---|---|
| committer | 2019-06-26 14:37:41 +0100 | |
| commit | c5785a2d1484a98616b0fb8b5a7cb728eb094435 (patch) | |
| tree | 470ace2c509805fb9b723592df196b4e9e0edb46 /modules/github.py | |
| parent | Update IRCBot `except queue.Empty` comment (diff) | |
| signature | ||
implement @utils.kwarg() magic, use it for command.regex hooks
Diffstat (limited to 'modules/github.py')
| -rw-r--r-- | modules/github.py | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/modules/github.py b/modules/github.py index 9b245cc5..102f3ab2 100644 --- a/modules/github.py +++ b/modules/github.py @@ -15,6 +15,10 @@ COLOR_NEUTRAL = utils.consts.LIGHTGREY COLOR_NEGATIVE = utils.consts.RED COLOR_ID = utils.consts.PINK +REGEX_PR_OR_ISSUE = re.compile( + r"https?://github.com/([^/]+)/([^/]+)/(pull|issues)/(\d+)", re.I) +REGEX_REF = re.compile(r"(?:\S+(?:\/\S+)?)?#\d+") + API_ISSUE_URL = "https://api.github.com/repos/%s/%s/issues/%s" API_PULL_URL = "https://api.github.com/repos/%s/%s/pulls/%s" @@ -182,12 +186,11 @@ class Module(ModuleManager.BaseModule): else: return True - @utils.hook("command.regex", ignore_action=False) + @utils.hook("command.regex") + @utils.kwarg("ignore_action", False) + @utils.kwarg("command", "github") + @utils.kwarg("pattern", REGEX_PR_OR_ISSUE) def url_regex(self, event): - """ - :command: github - :pattern: https?://github.com/([^/]+)/([^/]+)/(pull|issues)/(\d+) - """ if event["target"].get_setting("auto-github", False): event.eat() ref = "%s/%s#%s" % (event["match"].group(1), @@ -202,12 +205,11 @@ class Module(ModuleManager.BaseModule): event["stdout"].hide_prefix() event["stdout"].write(result) - @utils.hook("command.regex", ignore_action=False) + @utils.hook("command.regex") + @utils.kwarg("ignore_action", False) + @utils.kwarg("command", "github") + @utils.kwarg("pattern", REGEX_REF) def ref_regex(self, event): - """ - :command: github - :pattern: (?:\S+(?:\/\S+)?)?#\d+ - """ if event["target"].get_setting("auto-github", False): event.eat() ref = event["match"].group(0) |
