aboutsummaryrefslogtreecommitdiff
path: root/modules/hostmask_tracking.py
diff options
context:
space:
mode:
Diffstat (limited to 'modules/hostmask_tracking.py')
-rw-r--r--modules/hostmask_tracking.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/modules/hostmask_tracking.py b/modules/hostmask_tracking.py
index 73b95349..05981e5b 100644
--- a/modules/hostmask_tracking.py
+++ b/modules/hostmask_tracking.py
@@ -1,6 +1,8 @@
from src import ModuleManager, utils
class Module(ModuleManager.BaseModule):
+ _name = "Hostmasks"
+
@utils.hook("new.user")
def new_user(self, event):
userhost = event["user"].userhost()
@@ -9,3 +11,26 @@ class Module(ModuleManager.BaseModule):
if not userhost in known_hostmasks:
known_hostmasks.append(userhost)
event["user"].set_setting("known-hostmasks", known_hostmasks)
+
+ @utils.hook("received.command.maskfind")
+ @utils.kwarg("min_args", 1)
+ @utils.kwarg("private_only", True)
+ @utils.kwarg("help", "Find all nicknames that used a given hostmask")
+ @utils.kwarg("usage", "<hostmask>")
+ @utils.kwarg("permission", "maskfind")
+ def maskfind(self, event):
+ all_userhosts = event["server"].get_all_user_settings("known-hostmasks")
+ nicknames = set([])
+ hostmask_str = event["args_split"][0]
+ hostmask = utils.irc.hostmask_parse(hostmask_str)
+
+ for nickname, userhosts in all_userhosts:
+ for userhost in userhosts:
+ if hostmask.match(userhost):
+ nicknames.add(nickname)
+
+ if nicknames:
+ event["stdout"].write("%s: %s" %
+ (hostmask_str, ", ".join(sorted(nicknames))))
+ else:
+ event["stderr"].write("Hostmask not found")