Merge pull request #106 from Serraniel/bugfix/#105-after-autoupdate-to-last-version-is-cant-download-anything-and-keep-scanning-for-no-reason
Bugfix/#105 after autoupdate to last version is cant download anything and keep scanning for no reason
This commit is contained in:
commit
691057d5f7
|
@ -234,19 +234,45 @@ namespace DML.AppCore.Classes
|
||||||
var serverName = "unknown";
|
var serverName = "unknown";
|
||||||
string nickname = null;
|
string nickname = null;
|
||||||
|
|
||||||
|
if (fileName.Contains("%guildid%") || fileName.Contains("%nickname%"))
|
||||||
|
{
|
||||||
var socketTextChannel = message.Channel as SocketTextChannel;
|
var socketTextChannel = message.Channel as SocketTextChannel;
|
||||||
if (socketTextChannel != null)
|
if (socketTextChannel != null)
|
||||||
{
|
{
|
||||||
|
// fetch servername
|
||||||
serverName = socketTextChannel.Guild.Name;
|
serverName = socketTextChannel.Guild.Name;
|
||||||
serverName = Path.GetInvalidFileNameChars()
|
serverName = Path.GetInvalidFileNameChars()
|
||||||
.Aggregate(serverName, (current, c) => current.Replace(c, ' '));
|
.Aggregate(serverName, (current, c) => current.Replace(c, ' '));
|
||||||
nickname = socketTextChannel.GetUser(message.Author.Id).Nickname;
|
|
||||||
|
// fetch nickname
|
||||||
|
if (fileName.Contains("%nickname%"))
|
||||||
|
{
|
||||||
|
var serverUser =
|
||||||
|
socketTextChannel.GetUser(message.Author
|
||||||
|
.Id); // can be null if user left the server
|
||||||
|
if (serverUser != null)
|
||||||
|
{
|
||||||
|
nickname = serverUser.Nickname;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(nickname))
|
||||||
|
nickname = Path.GetInvalidFileNameChars()
|
||||||
|
.Aggregate(nickname, (current, c) => current.Replace(c, ' '));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fetch channelname
|
||||||
var channelName = message.Channel.Name;
|
var channelName = message.Channel.Name;
|
||||||
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)
|
||||||
|
@ -254,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