From cbb3c88e117e079a5ba939eba63ee80e4f85cbc7 Mon Sep 17 00:00:00 2001 From: James Lu Date: Sun, 6 Aug 2017 17:55:43 -0700 Subject: [PATCH] NetworkCoreWithUtils: add new match_all() method --- classes.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/classes.py b/classes.py index 0eaba15..b3d6ef2 100644 --- a/classes.py +++ b/classes.py @@ -1054,6 +1054,17 @@ class PyLinkNetworkCoreWithUtils(PyLinkNetworkCore): result = not result return result + def match_all(self, banmask, channel=None): + """ + Returns all users matching the target hostmask/exttarget. Users can also be filtered by channel. + """ + if channel: + banmask = "$and:(%s+$channel:%s)" % (banmask, channel) + + for uid, userobj in self.users.copy().items(): + if self.match_host(banmask, uid) and uid in self.users: + yield uid + def updateTS(self, sender, channel, their_ts, modes=None): """ Merges modes of a channel given the remote TS and a list of modes.