#105 Extended filename legalisation to usernames
This commit is contained in:
parent
dccbd4ab0b
commit
ed8039dfbc
|
@ -251,7 +251,13 @@ namespace DML.AppCore.Classes
|
||||||
socketTextChannel.GetUser(message.Author
|
socketTextChannel.GetUser(message.Author
|
||||||
.Id); // can be null if user left the server
|
.Id); // can be null if user left the server
|
||||||
if (serverUser != null)
|
if (serverUser != null)
|
||||||
|
{
|
||||||
nickname = serverUser.Nickname;
|
nickname = serverUser.Nickname;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(nickname))
|
||||||
|
nickname = Path.GetInvalidFileNameChars()
|
||||||
|
.Aggregate(nickname, (current, c) => current.Replace(c, ' '));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -261,6 +267,12 @@ namespace DML.AppCore.Classes
|
||||||
channelName = Path.GetInvalidFileNameChars()
|
channelName = Path.GetInvalidFileNameChars()
|
||||||
.Aggregate(channelName, (current, c) => current.Replace(c, ' '));
|
.Aggregate(channelName, (current, c) => current.Replace(c, ' '));
|
||||||
|
|
||||||
|
// fetch username
|
||||||
|
var username = message.Author.Username;
|
||||||
|
username = Path.GetInvalidFileNameChars()
|
||||||
|
.Aggregate(username, (current, c) => current.Replace(c, ' '));
|
||||||
|
|
||||||
|
|
||||||
fileName =
|
fileName =
|
||||||
fileName.Replace("%guild%", serverName)
|
fileName.Replace("%guild%", serverName)
|
||||||
.Replace("%channel%", channelName)
|
.Replace("%channel%", channelName)
|
||||||
|
@ -268,9 +280,9 @@ namespace DML.AppCore.Classes
|
||||||
.Replace("%name%", a.Filename)
|
.Replace("%name%", a.Filename)
|
||||||
.Replace("%id%", a.Id.ToString())
|
.Replace("%id%", a.Id.ToString())
|
||||||
.Replace("%userid%", message.Author.Id.ToString())
|
.Replace("%userid%", message.Author.Id.ToString())
|
||||||
.Replace("%username%", message.Author.Username)
|
.Replace("%username%", username)
|
||||||
.Replace("%nickname%",
|
.Replace("%nickname%",
|
||||||
!string.IsNullOrEmpty(nickname) ? nickname : message.Author.Username);
|
!string.IsNullOrEmpty(nickname) ? nickname : username);
|
||||||
|
|
||||||
if (extensionRequired)
|
if (extensionRequired)
|
||||||
fileName += Path.GetExtension(a.Filename);
|
fileName += Path.GetExtension(a.Filename);
|
||||||
|
|
Loading…
Reference in a new issue