aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorGravatar jesopo2019-05-19 16:24:38 +0100
committerGravatar jesopo2019-05-19 16:24:38 +0100
commitc607a0e67ccb997a46b27c128a318865ba4c9734 (patch)
treed278ec49647775063d7fd2d63993c51c60e1ebef /src/utils
parentSwitch to using Capability.copy() for sasl (diff)
signature
Implement utils.irc.hostmask_match for glob-like hostmask matching
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/irc/__init__.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/utils/irc/__init__.py b/src/utils/irc/__init__.py
index 39ee0058..b9ebdf58 100644
--- a/src/utils/irc/__init__.py
+++ b/src/utils/irc/__init__.py
@@ -1,4 +1,4 @@
-import json, string, re, typing
+import fnmatch, json, string, re, typing
from src import IRCLine, utils
from . import protocol
@@ -303,3 +303,6 @@ class MessageTag(object):
def get_value(self, tags: typing.Dict[str, str]) -> typing.Optional[str]:
key = list(set(tags.keys())&self._names)
return tags[key[0]] if key else None
+
+def hostmask_match(hostmask: str, pattern: str) -> bool:
+ return fnmatch.fnmatch(hostmask, pattern)