From 71461b3163cfeb68028a94e18f3673a2aa983e8a Mon Sep 17 00:00:00 2001 From: spiral Date: Sat, 14 Nov 2020 10:42:51 -0500 Subject: [PATCH] Add looking up group by displayname; document this --- PluralKit.Bot/CommandSystem/ContextEntityArgumentsExt.cs | 2 ++ PluralKit.Core/Database/Repository/ModelRepository.Group.cs | 3 +++ docs/content/command-list.md | 4 ++-- docs/content/user-guide.md | 3 ++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/PluralKit.Bot/CommandSystem/ContextEntityArgumentsExt.cs b/PluralKit.Bot/CommandSystem/ContextEntityArgumentsExt.cs index 7c58fdd7..08190b60 100644 --- a/PluralKit.Bot/CommandSystem/ContextEntityArgumentsExt.cs +++ b/PluralKit.Bot/CommandSystem/ContextEntityArgumentsExt.cs @@ -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; } diff --git a/PluralKit.Core/Database/Repository/ModelRepository.Group.cs b/PluralKit.Core/Database/Repository/ModelRepository.Group.cs index 9cdb7385..fdcc1e5a 100644 --- a/PluralKit.Core/Database/Repository/ModelRepository.Group.cs +++ b/PluralKit.Core/Database/Repository/ModelRepository.Group.cs @@ -13,6 +13,9 @@ namespace PluralKit.Core public Task GetGroupByName(IPKConnection conn, SystemId system, string name) => conn.QueryFirstOrDefaultAsync("select * from groups where system = @System and lower(Name) = lower(@Name)", new {System = system, Name = name}); + public Task GetGroupByDisplayName(IPKConnection conn, SystemId system, string display_name) => + conn.QueryFirstOrDefaultAsync("select * from groups where system = @System and lower(display_name) = lower(@Name)", new {System = system, Name = display_name}); + public Task GetGroupByHid(IPKConnection conn, string hid) => conn.QueryFirstOrDefaultAsync("select * from groups where hid = @hid", new {hid = hid.ToLowerInvariant()}); diff --git a/docs/content/command-list.md b/docs/content/command-list.md index f07e2b0f..782af0dd 100644 --- a/docs/content/command-list.md +++ b/docs/content/command-list.md @@ -35,7 +35,7 @@ Words in **\** or **[square brackets]** mean fill-in-the-blank. - `pk;unlink [account]` - Unlinks an account from this system. ## Member commands -*Replace `` with a member's name or 5-character ID. For most commands, adding `-clear` will clear/delete the field.* +*Replace `` with a member's name, 5-character ID or display name. For most commands, adding `-clear` will clear/delete the field.* - `pk;member ` - Shows information about a member. - `pk;member new ` - Creates a new system member. - `pk;member rename ` - Changes the name of a member. @@ -57,7 +57,7 @@ Words in **\** 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 `` with a group's name or 5-character ID. For most commands, adding `-clear` will clear/delete the field.* +*Replace `` with a group's name, 5-character ID or display name. For most commands, adding `-clear` will clear/delete the field.* - `pk;group ` - Shows information about a group. - `pk;group new ` - Creates a new group. - `pk;group list` - Lists all groups in your system. diff --git a/docs/content/user-guide.md b/docs/content/user-guide.md index 425636c3..bc13a8fa 100644 --- a/docs/content/user-guide.md +++ b/docs/content/user-guide.md @@ -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.