mirror of
https://github.com/Jetsparrow/antiantiswearingbot.git
synced 2026-01-20 23:16:08 +03:00
29 lines
858 B
C#
29 lines
858 B
C#
using Jetsparrow.Aasb.Services;
|
|
|
|
namespace Jetsparrow.Aasb.Commands;
|
|
public class LearnCommand : IChatCommand
|
|
{
|
|
public bool Authorize => true;
|
|
SearchDictionary Dict { get; }
|
|
public LearnCommand(SearchDictionary dict)
|
|
{
|
|
Dict = dict;
|
|
}
|
|
|
|
public string Execute(CommandContext cmd)
|
|
{
|
|
var word = cmd.Parameters.FirstOrDefault();
|
|
if (string.IsNullOrWhiteSpace(word))
|
|
return null;
|
|
|
|
var learnRes = Dict.Learn(word);
|
|
return learnRes switch
|
|
{
|
|
SearchDictionary.LearnResult.Known => $"Я знаю что такое \"{word}\"",
|
|
SearchDictionary.LearnResult.Added => $"Понял принял, \"{word}\"",
|
|
SearchDictionary.LearnResult.Illegal => "Я такое запоминать не буду",
|
|
_ => "ась?"
|
|
};
|
|
}
|
|
}
|