-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: implement help command and refac commands creation * fix: tweak command descriptions, formatting, and hide internal ones * feat: print help intro command on start
- Loading branch information
1 parent
cf3e6d5
commit 3b35332
Showing
16 changed files
with
90 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
Explorer/Assets/Scripts/Global/Dynamic/ChatCommands/HelpChatCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Cysharp.Threading.Tasks; | ||
using DCL.Chat.Commands; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Text.RegularExpressions; | ||
using System.Threading; | ||
|
||
namespace Global.Dynamic.ChatCommands | ||
{ | ||
public class HelpChatCommand : IChatCommand | ||
{ | ||
public Regex Regex { get; } = new ("^/(help).*", RegexOptions.Compiled); | ||
public string Description => "<b>/help</b> - Shows this help message"; | ||
|
||
private readonly List<IChatCommand> commands; | ||
|
||
public HelpChatCommand(List<IChatCommand> commands) | ||
{ | ||
this.commands = commands; | ||
} | ||
|
||
public UniTask<string> ExecuteAsync(Match match, CancellationToken ct) | ||
{ | ||
var sb = new StringBuilder(); | ||
|
||
sb.AppendLine("Available commands:\n"); | ||
|
||
foreach (IChatCommand cmd in commands) | ||
{ | ||
if (string.IsNullOrEmpty(cmd.Description)) continue; | ||
|
||
sb.AppendLine(cmd.Description); | ||
} | ||
|
||
return UniTask.FromResult(sb.ToString()); | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
Explorer/Assets/Scripts/Global/Dynamic/ChatCommands/HelpChatCommand.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters