--- a/plugin.py Thu Nov 22 15:27:58 2018 +0800
+++ b/plugin.py Thu Nov 22 15:30:13 2018 +0800
out, err = p.communicate()
return (out.decode('utf-8'), err.decode('utf-8'))
-class Mercurial(callbacks.Plugin):
+class Mercurial(callbacks.PluginRegexp):
"""Goodies for #mercurial."""
+ callBefore = ['URL', 'Web']
+ regexps = ['snarfDifferential', 'snarfDifferentialURL']
super(Mercurial, self).__init__(irc)
differential = wrap(differential, ['phabrev'])
+ def snarfDifferential(self, irc, msg, match):
+ r'\bD(?P<phabrev>\d+)\b'
+ if not irc.isChannel(channel):
+ phabrev = match.group('phabrev')
+ self.differential(self, irc, msg, msg.args, phabrev)
+ def snarfDifferentialURL(self, irc, msg, match):
+ r'\b(?P<url>https?://\S+/)D(?P<phabrev>\d+)\b'
+ if not irc.isChannel(channel):
+ url = match.group('url')
+ if url.rstrip('/') != self.registryValue('phaburl').rstrip('/'):
+ phabrev = match.group('phabrev')
+ self.differential(self, irc, msg, msg.args, phabrev, gotURL=True)