Skip to content

Commit

Permalink
feat: add Results and Numberconfig triggers to the help message
Browse files Browse the repository at this point in the history
  • Loading branch information
Evangelinexx committed Apr 1, 2020
1 parent cc5a9a8 commit da41b42
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 58 deletions.
17 changes: 17 additions & 0 deletions src/PockyBot.NET.Tests/Services/Triggers/HelpTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ public void ItShouldShowTheHelpMessageForNonAdminCommandsInADirectMessage(string
[InlineData(Commands.LocationWeight, Role.Config)]
[InlineData(Commands.RemoveUser, Role.Admin)]
[InlineData(Commands.RemoveUser, Role.RemoveUser)]
[InlineData(Commands.Results, Role.Admin)]
[InlineData(Commands.Results, Role.Results)]
[InlineData(Commands.NumberConfig, Role.Admin)]
[InlineData(Commands.NumberConfig, Role.Config)]
internal void ItShouldShowTheHelpMessageForAdminCommandsToAdminUsers(string command, Role userRole)
{
this.Given(x => GivenAHelpMessage(command))
Expand All @@ -154,6 +158,8 @@ internal void ItShouldShowTheHelpMessageForAdminCommandsToAdminUsers(string comm
[InlineData(Commands.RoleConfig)]
[InlineData(Commands.LocationWeight)]
[InlineData(Commands.RemoveUser)]
[InlineData(Commands.Results)]
[InlineData(Commands.NumberConfig)]
public void ItShouldShowTheDefaultHelpMessageForAdminCommandsToNonAdminUsers(string command)
{
this.Given(x => GivenAHelpMessage(command))
Expand Down Expand Up @@ -234,6 +240,15 @@ private void ThenItShouldShowAListOfNonAdminCommands()
_result.Text.ShouldContain($"* {Commands.UserLocation}");
_result.Text.ShouldContain($"For more information on a command type `@{BotName} help command-name` or direct message me with `help command-name`");
_result.Text.ShouldContain("I am still being worked on, so more features to come.");

_result.Text.ShouldNotContain($"* {Commands.Reset}");
_result.Text.ShouldNotContain($"* {Commands.Finish}");
_result.Text.ShouldNotContain($"* {Commands.StringConfig}");
_result.Text.ShouldNotContain($"* {Commands.RoleConfig}");
_result.Text.ShouldNotContain($"* {Commands.LocationWeight}");
_result.Text.ShouldNotContain($"* {Commands.RemoveUser}");
_result.Text.ShouldNotContain($"* {Commands.Results}");
_result.Text.ShouldNotContain($"* {Commands.NumberConfig}");
}

private void ThenItShouldShowAListOfAdminCommands()
Expand All @@ -253,6 +268,8 @@ private void ThenItShouldShowAListOfAdminCommands()
_result.Text.ShouldContain($"* {Commands.RoleConfig}");
_result.Text.ShouldContain($"* {Commands.LocationWeight}");
_result.Text.ShouldContain($"* {Commands.RemoveUser}");
_result.Text.ShouldContain($"* {Commands.Results}");
_result.Text.ShouldContain($"* {Commands.NumberConfig}");
_result.Text.ShouldContain($"For more information on a command type `@{BotName} help command-name` or direct message me with `help command-name`");
_result.Text.ShouldContain("I am still being worked on, so more features to come.");
}
Expand Down
84 changes: 26 additions & 58 deletions src/PockyBot.NET/Services/Triggers/Help.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,14 @@ private string CreateHelpResponseMessage(string command, PockyUser user)
return CreateWelcomeHelpMessage();
case Commands.Rotation:
return CreateRotationHelpMessage();
// case Commands.Winners:
// return CreateWinnersHelpMessage(user);
// case Commands.Results:
// return CreateResultsHelpMessage(user);
case Commands.Results:
return CreateResultsHelpMessage(user);
case Commands.Reset:
return CreateResetHelpMessage(user);
// case Commands.Update:
// return CreateUpdateHelpMessage(user);
case Commands.Finish:
return CreateFinishHelpMessage(user);
// case Commands.NumberConfig:
// return CreateNumberConfigHelpMessage(user);
case Commands.NumberConfig:
return CreateNumberConfigHelpMessage(user);
case Commands.StringConfig:
return CreateStringConfigHelpMessage(user);
case Commands.RoleConfig:
Expand Down Expand Up @@ -104,29 +100,21 @@ private string CreateCommandListMessage(PockyUser user)
$"* {Commands.LocationConfig}\n" +
$"* {Commands.UserLocation}\n";

// if (HasPermission(user, new []{Role.ADMIN, Role.WINNERS})) {
// newMessage += $"* {Commands.Winners}\n";
// }

// if (HasPermission(user, new []{Role.ADMIN, Role.RESULTS})) {
// newMessage += $"* {Commands.Results}\n";
// }
if (HasPermission(user, new []{Role.Admin, Role.Results})) {
newMessage += $"* {Commands.Results}\n";
}


if (HasPermission(user, new []{Role.Admin, Role.Reset})) {
newMessage += $"* {Commands.Reset}\n";
}

// if (HasPermission(user, new []{Role.ADMIN, Role.UPDATE})) {
// newMessage += $"* {Commands.Update}\n";
// }

if (HasPermission(user, new []{Role.Admin, Role.Finish})) {
newMessage += $"* {Commands.Finish}\n";
}

if (HasPermission(user, new []{Role.Admin, Role.Config})) {
// newMessage += $"* {Commands.NumberConfig}\n";
newMessage += $"* {Commands.NumberConfig}\n";
newMessage += $"* {Commands.StringConfig}\n";
newMessage += $"* {Commands.RoleConfig}\n";
newMessage += $"* {Commands.LocationWeight}\n";
Expand Down Expand Up @@ -188,25 +176,15 @@ private string CreateRotationHelpMessage()
"1. I will respond in the room you messaged me in.";
}

// private string CreateWinnersHelpMessage(PockyUser user)
// {
// if (HasPermission(user, new[] {Role.ADMIN, Role.WINNERS})){
// return "### How to display the winners πŸ†!\n" +
// $"1. To display winners, type `@{_pockyBotSettings.BotName} {Commands.Winners}`.\n" +
// "1. I will respond in the room you messaged me in.";
// }
// return CreateDefaultHelpMessage();
// }
//
// private string CreateResultsHelpMessage(PockyUser user)
// {
// if (HasPermission(user, new[] {Role.ADMIN, Role.RESULTS})) {
// return "### How to display the results πŸ“ƒ!\n" +
// $"1. To display results, type `@{_pockyBotSettings.BotName} {Commands.Results}`.\n" +
// "1. I will respond in the room you messaged me in.";
// }
// return CreateDefaultHelpMessage();
// }
private string CreateResultsHelpMessage(PockyUser user)
{
if (HasPermission(user, new[] {Role.Admin, Role.Results})) {
return "### How to display the results πŸ“ƒ!\n" +
$"1. To display results, type `@{_pockyBotSettings.BotName} {Commands.Results}`.\n" +
"1. I will respond in the room you messaged me in.";
}
return CreateDefaultHelpMessage();
}

private string CreateResetHelpMessage(PockyUser user)
{
Expand All @@ -218,16 +196,6 @@ private string CreateResetHelpMessage(PockyUser user)
return CreateDefaultHelpMessage();
}

// private string CreateUpdateHelpMessage(PockyUser user)
// {
// if (HasPermission(user, new[] {Role.ADMIN, Role.UPDATE})) {
// return "### How to update names πŸ“›!\n" +
// $"1. To update user names with users' current display names, type `@{_pockyBotSettings.BotName} {Commands.Update}`.\n" +
// "1. I will respond in the room you messaged me in.";
// }
// return CreateDefaultHelpMessage();
// }

private string CreateFinishHelpMessage(PockyUser user)
{
if (HasPermission(user, new[] {Role.Admin, Role.Finish})) {
Expand All @@ -238,15 +206,15 @@ private string CreateFinishHelpMessage(PockyUser user)
return CreateDefaultHelpMessage();
}

// private string CreateNumberConfigHelpMessage(PockyUser user)
// {
// if (HasPermission(user, new[] {Role.ADMIN, Role.CONFIG})) {
// return "### How to configure number config values πŸ”’!\n" +
// $"1. To get/edit/refresh/delete number config values, type `@{_pockyBotSettings.BotName} {Commands.NumberConfig} {Object.values(ConfigAction).join('|')} {{name}} {{number}}`\n" +
// "1. I will respond in the room you messaged me in.";
// }
// return CreateDefaultHelpMessage();
// }
private string CreateNumberConfigHelpMessage(PockyUser user)
{
if (HasPermission(user, new[] {Role.Admin, Role.Config})) {
return "### How to configure number config values πŸ”’!\n" +
$"1. To get/edit/refresh/delete number config values, type `@{_pockyBotSettings.BotName} {Commands.NumberConfig} {Actions.Get}|{Actions.Add}|{Actions.Delete} {{name}} {{number}}`\n" +
"1. I will respond in the room you messaged me in.";
}
return CreateDefaultHelpMessage();
}

private string CreateStringConfigHelpMessage(PockyUser user)
{
Expand Down

0 comments on commit da41b42

Please sign in to comment.