From 2ff0007e56dab2e65060ec7d5c95a2a7c0fa2cd8 Mon Sep 17 00:00:00 2001 From: James Lu Date: Sun, 6 Aug 2017 21:41:44 -0700 Subject: [PATCH] exttargets: add $realname target --- coremods/exttargets.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/coremods/exttargets.py b/coremods/exttargets.py index 6f90914..1ad5fba 100644 --- a/coremods/exttargets.py +++ b/coremods/exttargets.py @@ -190,3 +190,15 @@ def exttarget_and(irc, host, uid): # Wrap every subtarget into irc.match_host and return True if all subtargets return True. return all(map(lambda sub_exttarget: irc.match_host(sub_exttarget, uid), targets)) world.exttarget_handlers['and'] = exttarget_and + +@bind +def realname(irc, host, uid): + """ + $realname exttarget handler. This takes one argument: a glob, which is compared case-insensitively to the user's real name. + + Examples: + $realname:*James*: matches anyone with "James" in their real name. + """ + groups = host.split(':') + if len(groups) >= 2: + return irc.match_host(groups[1], irc.users[uid].realname)