public ErrorCode CreateChannel(string name, string shortName, string colour, string modes, out Channel c) { bool ret = Database.CreateChannel(name, shortName, colour, modes); if (ret) { c = new Channel(name, shortName, colour, modes); Channels.Add(c); } else { c = null; } return ret ? ErrorCode.Success : ErrorCode.ChannelCreateFailed; }
public ErrorCode JoinUserToChannel(Channel channel, ChannelUser user, bool super = false) { //Bubbles down to JoinUserToChannel(string, string) if (!super && channel.HasMode(ChannelModes.PrivateMode) && !user.HasMode(UserModes.Invited)) { return ErrorCode.InsufficientAccess; } ErrorCode ret = JoinUserToChannel(channel.Name, user.Name); if (ret == ErrorCode.Success) { channel.Users.Add(user); user.Channels.Add(channel); } return ret; }
public ErrorCode SetUserModes(ChannelUser user, Channel channel) { return SetUserModes(user.Name, channel.Name, user.Modes.ToString()); }
public ErrorCode CreateChannel(string name, string colour, string modes, out Channel c) { return CreateChannel(name, null, colour, modes, out c); }
public ErrorCode SetChannelModes(Channel channel) { return SetChannelModes(channel.Name, channel.Modes.ToString()); }
public ErrorCode RemoveUserFromChannel(Channel channel, TSPlayer player) { //Bubbles down to RemoveUserFromChannel(Channel, ChannelUser) if (!player.IsLoggedIn) { return ErrorCode.InsufficientAccess; } if (!Database.CheckUserExistance(player.User.Name)) { return ErrorCode.UserNotFound; } ChannelUser user = GetUser(player.User.Name); return RemoveUserFromChannel(channel, user); }
public ErrorCode RemoveUserFromChannel(Channel channel, ChannelUser user) { //Bubbles down to RemoveUserFromChannel(string, string) ErrorCode ret = RemoveUserFromChannel(channel.Name, user.Name); if (ret == ErrorCode.Success) { channel.Users.Remove(user); user.Channels.Remove(channel); } return ret; }
public ErrorCode RemoveChannel(Channel channel) { ErrorCode ret = RemoveChannel(channel.Name); if (ret == ErrorCode.Success) { Channels.Remove(channel); foreach (ChannelUser user in channel.Users) { user.Channels.Remove(channel); if (user.ActiveChannel == channel) { user.SetActiveChannel(null); } } } return ret; }
public ErrorCode JoinUserToChannel(Channel channel, TSPlayer player) { //Bubbles down to JoinUserToChannel(Channel, ChannelUser) if (!player.IsLoggedIn) { return ErrorCode.InsufficientAccess; } ChannelUser user; if (Database.CheckUserExistance(player.User.Name)) { user = GetUser(player.User.Name); return JoinUserToChannel(channel, user); } if (Database.CreateChannelUser(player.User.Name)) { user = new ChannelUser(player.User.Name); } else { return ErrorCode.UserCreateFailed; } return JoinUserToChannel(channel, user); }