Merge branch 'master' into feature/update-libs

# Conflicts:
#	Discord Media Loader.Application/Classes/JobScheduler.cs
This commit is contained in:
Serraniel 2021-12-05 22:22:22 +01:00
commit 08921bd22a
Signed by: Serraniel
GPG key ID: 3690B4E7364525D3
3 changed files with 9 additions and 3 deletions

View file

@ -232,6 +232,7 @@ namespace DML.AppCore.Classes
var extensionRequired = !fileName.EndsWith("%name%"); var extensionRequired = !fileName.EndsWith("%name%");
var serverName = "unknown"; var serverName = "unknown";
string nickname = null;
var socketTextChannel = message.Channel as SocketTextChannel; var socketTextChannel = message.Channel as SocketTextChannel;
if (socketTextChannel != null) if (socketTextChannel != null)
@ -239,6 +240,7 @@ namespace DML.AppCore.Classes
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;
} }
var channelName = message.Channel.Name; var channelName = message.Channel.Name;
@ -252,7 +254,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%", message.Author.Username)
.Replace("%nickname%",
!string.IsNullOrEmpty(nickname) ? nickname : message.Author.Username);
if (extensionRequired) if (extensionRequired)
fileName += Path.GetExtension(a.Filename); fileName += Path.GetExtension(a.Filename);

View file

@ -86,7 +86,8 @@ namespace DML.Application.Properties {
///%channel% -> channel name ///%channel% -> channel name
///%timestamp% -> message timestamp (Unix timestamp) ///%timestamp% -> message timestamp (Unix timestamp)
///%name% -> attachment filename ///%name% -> attachment filename
///%username% -> author name ///%username% -> author username
///%nickname% -> author nickname (if unassigned, username will be used)
///%id% -> attachment id (given by Discord) ///%id% -> attachment id (given by Discord)
///%userid% -> author id (given by discord) ähnelt. ///%userid% -> author id (given by discord) ähnelt.
/// </summary> /// </summary>

View file

@ -139,7 +139,8 @@ Flaticons (Roundicons Circle Flat) - Flaticon Basic License</value>
%channel% -&gt; channel name %channel% -&gt; channel name
%timestamp% -&gt; message timestamp (Unix timestamp) %timestamp% -&gt; message timestamp (Unix timestamp)
%name% -&gt; attachment filename %name% -&gt; attachment filename
%username% -&gt; author name %username% -&gt; author username
%nickname% -&gt; author nickname (if unassigned, username will be used)
%id% -&gt; attachment id (given by Discord) %id% -&gt; attachment id (given by Discord)
%userid% -&gt; author id (given by discord)</value> %userid% -&gt; author id (given by discord)</value>
</data> </data>