add cmask
command spec type (all users in channel matching mask)
This commit is contained in:
parent
d5f0cb5f3d
commit
331f966c01
1 changed files with 14 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
||||||
from src.utils.parse import SpecTypeError
|
from src.utils.parse import SpecTypeError
|
||||||
|
from src.utils.irc import hostmask_match, hostmask_parse
|
||||||
|
|
||||||
TYPES = {}
|
TYPES = {}
|
||||||
def _type(func):
|
def _type(func):
|
||||||
|
@ -70,6 +71,19 @@ def nuser(server, channel, user, args):
|
||||||
_assert_args(args, "user")
|
_assert_args(args, "user")
|
||||||
return server.get_user(args[0], create=True), 1
|
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
|
@_type
|
||||||
def lstring(server, channel, user, args):
|
def lstring(server, channel, user, args):
|
||||||
if args:
|
if args:
|
||||||
|
|
Loading…
Reference in a new issue