示例#1
0
        public ChangeLog(BaseUser oldUser, BaseUser newUser, BaseServer server)
        {
            var logChannel = server.FindChannelByName("theguin-log");

            if (logChannel == null)
            {
                return;
            }

            if (oldUser.GetNickname() != newUser.GetNickname() || oldUser.GetUsername() != newUser.GetUsername())
            {
                logChannel.SendMessage(oldUser.GetDataString() + " became: ``" + newUser.GetDataString());
            }

            var oldRoles = oldUser.GetRoles();
            var newRoles = newUser.GetRoles();

            var oldRoleNames = new List <string>();
            var newRoleNames = new List <string>();

            foreach (var role in oldRoles)
            {
                oldRoleNames.Add(role.GetName());
            }

            foreach (var role in newRoles)
            {
                newRoleNames.Add(role.GetName());
            }

            var differenceOldNew = oldRoleNames.Except(newRoleNames).ToList();
            var differenceNewOld = newRoleNames.Except(oldRoleNames).ToList();

            foreach (var role in differenceNewOld)
            {
                logChannel.SendMessage(newUser.GetDataString() + " gained the role: ``" + role + "``");
            }

            foreach (var role in differenceOldNew)
            {
                logChannel.SendMessage(newUser.GetDataString() + " lost the role: ``" + role + "``");
            }
        }