From d3892a85bea537b57dd89d5ba45d4863047d3b51 Mon Sep 17 00:00:00 2001 From: James Lu Date: Tue, 5 Sep 2017 19:19:01 -0700 Subject: [PATCH] Add $service exttarget for matching service bots --- coremods/exttargets.py | 18 ++++++++++++++++++ docs/exttargets.md | 6 ++++++ 2 files changed, 24 insertions(+) diff --git a/coremods/exttargets.py b/coremods/exttargets.py index 18116dd..0db57d5 100644 --- a/coremods/exttargets.py +++ b/coremods/exttargets.py @@ -206,3 +206,21 @@ def realname(irc, host, uid): groups = host.split(':') if len(groups) >= 2: return irc.match_host(groups[1], irc.users[uid].realname) + +@bind +def service(irc, host, uid): + """ + $service exttarget handler. This takes one optional argument: a glob, which is compared case-insensitively to the target user's service name (if present). + + Examples: + $service -> Matches any PyLink service bot. + $service:automode -> Matches the Automode service bot. + """ + if not irc.users[uid].service: + return False + + groups = host.split(':') + + if len(groups) >= 2: + return irc.match_host(groups[1], irc.users[uid].service) + return True # It *is* a service bot because of the check at the top. diff --git a/docs/exttargets.md b/docs/exttargets.md index 0afc7c0..c05709e 100644 --- a/docs/exttargets.md +++ b/docs/exttargets.md @@ -64,3 +64,9 @@ Used to match users logged in to *PyLink* (i.e. via the `identify` command). Used to match users with certain realnames. - `$realname:*James*`: matches anyone with "James" in their real name (case insensitive). + +### The "$service" target (PyLink 2.0+) +Used to match service bots. This exttarget takes one optional argument: a glob, which is compared case-insensitively to the target user's service name if present. + +- `$service`: matches any PyLink service bot. +- `$service:automode`: matches the Automode service bot.