Download:
child 32:6f02219bf75b
parent 30:8db5c52046c7
31:c3c5a64068a5 draft
Anton Shestakov <av6@dwimlabs.net>, Thu, 22 Nov 2018 15:30:13 +0800
plugin: snarf differential revisions and URLs

1 файлов изменено, 26 вставок(+), 1 удалений(-) [+]
plugin.py file | annotate | diff | comparison | revisions
--- a/plugin.py Thu Nov 22 15:27:58 2018 +0800
+++ b/plugin.py Thu Nov 22 15:30:13 2018 +0800
@@ -59,9 +59,11 @@
out, err = p.communicate()
return (out.decode('utf-8'), err.decode('utf-8'))
-class Mercurial(callbacks.Plugin):
+class Mercurial(callbacks.PluginRegexp):
"""Goodies for #mercurial."""
threaded = True
+ callBefore = ['URL', 'Web']
+ regexps = ['snarfDifferential', 'snarfDifferentialURL']
def __init__(self, irc):
super(Mercurial, self).__init__(irc)
@@ -180,4 +182,27 @@
irc.reply(item)
differential = wrap(differential, ['phabrev'])
+ def snarfDifferential(self, irc, msg, match):
+ r'\bD(?P<phabrev>\d+)\b'
+ channel = msg.args[0]
+ if not irc.isChannel(channel):
+ return
+
+ phabrev = match.group('phabrev')
+ self.differential(self, irc, msg, msg.args, phabrev)
+
+ @urlSnarfer
+ def snarfDifferentialURL(self, irc, msg, match):
+ r'\b(?P<url>https?://\S+/)D(?P<phabrev>\d+)\b'
+ channel = msg.args[0]
+ if not irc.isChannel(channel):
+ return
+
+ url = match.group('url')
+ if url.rstrip('/') != self.registryValue('phaburl').rstrip('/'):
+ return
+
+ phabrev = match.group('phabrev')
+ self.differential(self, irc, msg, msg.args, phabrev, gotURL=True)
+
Class = Mercurial