From f4de604b7d591a03534ce992ccc116ac581dae63 Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 8 Jun 2018 18:21:37 -0700 Subject: [PATCH] classes: split match_host() into match_host() and match_text() --- classes.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/classes.py b/classes.py index a087a20..d05a3cf 100644 --- a/classes.py +++ b/classes.py @@ -1363,6 +1363,9 @@ class PyLinkNetworkCoreWithUtils(PyLinkNetworkCore): hosts.add(self.get_hostmask(target, realhost=True)) else: # We were given a host, use that. + if '@' not in text: + log.warning('(%s) Using match_host() on non-hostlike globs is deprecated as of 2.0-alpha4 - ' + 'use match_text() instead', self.name) hosts = [target] # Iterate over the hosts to match using ircmatch. @@ -1377,6 +1380,19 @@ class PyLinkNetworkCoreWithUtils(PyLinkNetworkCore): result = not result return result + def match_text(self, glob, text): + """ + Returns whether the given glob matches the given text under the network's + current case mapping. + """ + # Get the corresponding casemapping value used by ircmatch. + if self.casemapping == 'rfc1459': + casemapping = 0 + else: + casemapping = 1 + + return ircmatch.match(casemapping, glob, text) + def match_all(self, banmask, channel=None): """ Returns all users matching the target hostmask/exttarget. Users can also be filtered by channel.