public AuthenticationManager(IStorageManager storageManager) { _storageManager = storageManager; Guest = new BotGroup(GroupNames.Guest, 0); Registered = new BotGroup(GroupNames.Registered, 10); Administrator = new BotGroup(GroupNames.Administrator, 20); Owner = new BotGroup(GroupNames.Owner, 30); _groups.Add(Guest.Name, Guest); _groups.Add(Registered.Name, Registered); _groups.Add(Administrator.Name, Administrator); _groups.Add(Owner.Name, Owner); _userData = _storageManager.Global().GetOrCreate<Dictionary<String, UserData>>("Users"); foreach(UserData data in _userData.Values) { if(!_groups.ContainsKey(data.GroupName)) { _logger.Error("User with username " + data.Username + " has invalid group name " + data.GroupName + ". User was not added."); } else { IBotUser user = new BotUser(data.Username, data.Password, _groups[data.GroupName], false); _users.Add(data.Username, user); _masks[user] = data.Masks; } } _allMasks = new HashSet<IdentityMask>(_masks.Values); }
public Bot(IClient client, IStorageManager storage, ICommandManager command, IPluginManager plugin, IAuthenticationManager authentication, IPermissionManager permission) { _client = client; _storage = storage; _command = command; _plugin = plugin; _authentication = authentication; _permission = permission; _data = storage.Global().GetOrCreate<BotData>(_storageIdentifier); _replyHandler = new ReplyHandler(this, _data); _messsageHandler = new MessageHandler(this, _replyHandler, _data); }