public void RegisterCommand(SlackBotCommand command, SlackBotV3 slackBot) { ICommandType commandType = CommandTypeRegistry.GetCommandType(command.Name); ICommandHandler commandHandler = commandType.MakeCommandHandler(slackBot); CommandContainer[GetCommandKey(command)] = commandHandler; }
private int GetCommandKey(SlackBotCommand command) { int commandId = CommandTypeRegistry.GetCommandId(command.Name); CommandScope scope = CommandTypeRegistry.GetCommandType(command.Name).GetCommandScope(); object preKey = null; switch (scope) { case CommandScope.Global: preKey = commandId; break; case CommandScope.Channel: preKey = new Tuple <int, string>(commandId, command.Channel.id); break; case CommandScope.User: preKey = new Tuple <int, string, string>(commandId, command.Channel.id, command.User.id); break; } return(preKey.GetHashCode()); }
public CommandHandlerRegistry(CommandTypeRegistry commandHandlerRegistry) { CommandTypeRegistry = commandHandlerRegistry; }