public MatchType Match(Message message) { if (message.Body.StartsWith(token, StringComparison.CurrentCultureIgnoreCase)) return MatchType.Strong; return MatchType.None; }
public void Process(Message message) { var commands = kernel.GetAll<ICommand>().ToList(); var command = commands.FirstOrDefault(x => x.Trigger.Match(message) == MatchType.Strong) ?? commands.FirstOrDefault(x => x.Trigger.Match(message) == MatchType.Weak); if (command == null) { writer.Write("> I don't know that command sorry."); return; } try { command.Process(message); } catch (Exception ex) { writer.Write("> Something went horribly wrong: " + ex.Message); } }