diff options
| author | 2020-02-17 10:16:22 +0000 | |
|---|---|---|
| committer | 2020-02-17 10:16:22 +0000 | |
| commit | 331f966c017f2bc063e30d706b7c295b24a8c1ed (patch) | |
| tree | 993676253a8381303ad54c001384808680ae4f73 /src/core_modules/command_spec | |
| parent | remove debug print (diff) | |
| signature | ||
add `cmask` command spec type (all users in channel matching mask)
Diffstat (limited to 'src/core_modules/command_spec')
| -rw-r--r-- | src/core_modules/command_spec/types.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/core_modules/command_spec/types.py b/src/core_modules/command_spec/types.py index c39128dd..0baa13e8 100644 --- a/src/core_modules/command_spec/types.py +++ b/src/core_modules/command_spec/types.py @@ -1,4 +1,5 @@ from src.utils.parse import SpecTypeError +from src.utils.irc import hostmask_match, hostmask_parse TYPES = {} def _type(func): @@ -71,6 +72,19 @@ def nuser(server, channel, user, args): return server.get_user(args[0], create=True), 1 @_type +def cmask(server, channel, user, args): + _assert_args(args, "mask") + hostmask_obj = hostmask_parse(args[0]) + users = [] + for user in channel.users: + if hostmask_match(user.hostmask(), hostmask_obj): + users.append(user) + if users: + return users, 1 + else: + raise SpecTypeError("No users found") + +@_type def lstring(server, channel, user, args): if args: return " ".join(args), len(args) |
