Add a users.complete_match function, taking and returning Users
This commit is contained in:
parent
081f909260
commit
53cd5dc616
15
src/users.py
15
src/users.py
@ -157,6 +157,21 @@ class users: # backwards-compatible API
|
||||
def items():
|
||||
yield from var.USERS.items()
|
||||
|
||||
def complete_match(string, users):
|
||||
matches = []
|
||||
string = lower(string)
|
||||
for user in users:
|
||||
nick = lower(user.nick)
|
||||
if nick == string:
|
||||
return user, 1
|
||||
elif nick.startswith(string) or nick.lstrip("[{\\^_`|}]").startswith(string):
|
||||
matches.append(user)
|
||||
|
||||
if len(matches) != 1:
|
||||
return None, len(matches)
|
||||
|
||||
return matches[0], 1
|
||||
|
||||
_raw_nick_pattern = re.compile(r"^(?P<nick>.+?)(?:!(?P<ident>.+?)@(?P<host>.+))?$")
|
||||
|
||||
def parse_rawnick(rawnick, *, default=None):
|
||||
|
Loading…
x
Reference in New Issue
Block a user