3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-23 19:19:31 +01:00

NetworkCoreWithUtils: add new match_all() method

This commit is contained in:
James Lu 2017-08-06 17:55:43 -07:00
parent 32249ace3e
commit cbb3c88e11

View File

@ -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.