Merge pull request #247 from dev-kittens/tweak/group-dn

Add looking up group by display name
This commit is contained in:
Astrid 2020-11-15 13:15:29 +01:00 committed by GitHub
commit 90b2fcfdd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 3 deletions

View File

@ -110,6 +110,8 @@ namespace PluralKit.Bot
return byName;
if (await ctx.Repository.GetGroupByHid(conn, input) is {} byHid)
return byHid;
if (await ctx.Repository.GetGroupByDisplayName(conn, ctx.System.Id, input) is {} byDisplayName)
return byDisplayName;
return null;
}

View File

@ -13,6 +13,9 @@ namespace PluralKit.Core
public Task<PKGroup?> GetGroupByName(IPKConnection conn, SystemId system, string name) =>
conn.QueryFirstOrDefaultAsync<PKGroup?>("select * from groups where system = @System and lower(Name) = lower(@Name)", new {System = system, Name = name});
public Task<PKGroup?> GetGroupByDisplayName(IPKConnection conn, SystemId system, string display_name) =>
conn.QueryFirstOrDefaultAsync<PKGroup?>("select * from groups where system = @System and lower(display_name) = lower(@Name)", new {System = system, Name = display_name});
public Task<PKGroup?> GetGroupByHid(IPKConnection conn, string hid) =>
conn.QueryFirstOrDefaultAsync<PKGroup?>("select * from groups where hid = @hid", new {hid = hid.ToLowerInvariant()});

View File

@ -35,7 +35,7 @@ Words in **\<angle brackets>** or **[square brackets]** mean fill-in-the-blank.
- `pk;unlink [account]` - Unlinks an account from this system.
## Member commands
*Replace `<name>` with a member's name or 5-character ID. For most commands, adding `-clear` will clear/delete the field.*
*Replace `<name>` with a member's name, 5-character ID or display name. For most commands, adding `-clear` will clear/delete the field.*
- `pk;member <name>` - Shows information about a member.
- `pk;member new <name>` - Creates a new system member.
- `pk;member <name> rename <new name>` - Changes the name of a member.
@ -57,7 +57,7 @@ Words in **\<angle brackets>** or **[square brackets]** mean fill-in-the-blank.
- `pk;random` - Shows the member card of a randomly selected member in your system.
## Group commands
*Replace `<name>` with a group's name or 5-character ID. For most commands, adding `-clear` will clear/delete the field.*
*Replace `<name>` with a group's name, 5-character ID or display name. For most commands, adding `-clear` will clear/delete the field.*
- `pk;group <name>` - Shows information about a group.
- `pk;group new <name>` - Creates a new group.
- `pk;group list` - Lists all groups in your system.

View File

@ -129,10 +129,11 @@ You can't do much with PluralKit without having registered members with your sys
As the one exception to the rule above, if the name consists of multiple words you must *not* enclose it in double quotes.
### Looking up member info
To view information about a member, there are a couple ways to do it. Either you can address a member by their name (if they're in your own system), or by their 5-character *member ID*, like so:
To view information about a member, there are a couple ways to do it. Either you can address a member by their name (if they're in your own system), by their 5-character *member ID*, or by their *display name*, like so:
pk;member John
pk;member qazws
pk;member J
Member IDs are the only way to address a member in another system, and you can find it in various places - for example the system's member list, or on a message info card gotten by reacting to messages with a question mark.