bot: fix handling of tag supersets (see #84 comments)
This commit is contained in:
parent
0590dd058f
commit
5590cfc90f
@ -192,9 +192,8 @@ class System(namedtuple("System", ["id", "hid", "name", "description", "tag", "a
|
|||||||
"""Tries to find a member with proxy tags matching the given message. Returns the member and the inner contents."""
|
"""Tries to find a member with proxy tags matching the given message. Returns the member and the inner contents."""
|
||||||
members = await db.get_all_members(conn, self.id)
|
members = await db.get_all_members(conn, self.id)
|
||||||
|
|
||||||
# Sort by specificity (members with both prefix and suffix defined go higher)
|
# Sort by match specificity (longer prefix/suffix = smaller match = more specific)
|
||||||
# This will make sure more "precise" proxy tags get tried first and match properly
|
members = sorted(members, key=lambda x: len(x.prefix or "") + len(x.suffix or ""), reverse=True)
|
||||||
members = sorted(members, key=lambda x: int(bool(x.prefix)) + int(bool(x.suffix)), reverse=True)
|
|
||||||
|
|
||||||
for member in members:
|
for member in members:
|
||||||
proxy_prefix = member.prefix or ""
|
proxy_prefix = member.prefix or ""
|
||||||
|
Loading…
Reference in New Issue
Block a user