diff options
| author | 2019-01-26 10:49:31 +0000 | |
|---|---|---|
| committer | 2019-01-26 10:49:31 +0000 | |
| commit | 2d113011ede449c36148a8622c82f912758a8870 (patch) | |
| tree | cd9121ca733209426cda9be8edee84b3be25ad78 | |
| parent | Don't give `event` object to webhook functions - they don't need them (diff) | |
| signature | ||
Add a setting to insert zero width characters in to highlights (github)
| -rw-r--r-- | modules/github/module.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/modules/github/module.py b/modules/github/module.py index 4b80a152..9de3b144 100644 --- a/modules/github/module.py +++ b/modules/github/module.py @@ -69,6 +69,9 @@ COMMENT_ACTIONS = { "validate": utils.bool_or_none}) @utils.export("channelset", {"setting": "github-default-repo", "help": "Set the default github repo for the current channel"}) +@utils.export("channelset", {"setting": "github-prevent-highlight", + "help": "Enable/disable preventing highlights", + "validate": utils.bool_or_none}) class Module(ModuleManager.BaseModule): def _parse_ref(self, channel, ref): repo, _, number = ref.rpartition("#") @@ -327,6 +330,9 @@ class Module(ModuleManager.BaseModule): for output in outputs: source = full_name or organisation output = "(%s) %s" % (source, output) + if channel.get_setting("github-prevent-highlight", False): + self._prevent_highlight(channel, output) + self.events.on("send.stdout").call(target=channel, module_name="Github", server=server, message=output, hide_prefix=channel.get_setting( @@ -334,6 +340,18 @@ class Module(ModuleManager.BaseModule): return "" + def _prevent_highlight(self, channel, s): + for user in channel.users: + while user.nickname_lower in s.lower(): + index = s.lower().index(user.nickname_lower) + length = len(user.nickname_lower) + + original = s[index:index+length] + original = utils.prevent_highlight(original) + + s = s[:index] + original + s[index+length:] + return s + def _short_url(self, url): try: page = utils.http.request("https://git.io", method="POST", |
