Merge branch 'feature/RPC-config' into develop
* feature/RPC-config: Disable RPC by default Did some corrections because of sweetlib
This commit is contained in:
commit
3b8f440bb2
|
@ -261,25 +261,28 @@ namespace DML.Application.Classes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.Info("Initializing RPC client");
|
if (Settings.UseRPC)
|
||||||
Logger.Trace("Registering RPC handlers");
|
|
||||||
RpcHandlers.readyCallback += RpcReadyCallback;
|
|
||||||
RpcHandlers.disconnectedCallback += RpcDisconnectedCallback;
|
|
||||||
RpcHandlers.errorCallback += RpcErrorCallback;
|
|
||||||
RpcPresence.startTimestamp = DiscordRpcHelper.DateTimeToTimestamp(DateTime.UtcNow);
|
|
||||||
|
|
||||||
Logger.Debug("Calling RPC initialize");
|
|
||||||
DiscordRpc.Initialize("430025401851707393", ref RpcHandlers, true, null);
|
|
||||||
|
|
||||||
// Do not await ;)
|
|
||||||
Task.Run(async () =>
|
|
||||||
{
|
{
|
||||||
while (!ShuttingDown)
|
Logger.Info("Initializing RPC client");
|
||||||
|
Logger.Trace("Registering RPC handlers");
|
||||||
|
RpcHandlers.readyCallback += RpcReadyCallback;
|
||||||
|
RpcHandlers.disconnectedCallback += RpcDisconnectedCallback;
|
||||||
|
RpcHandlers.errorCallback += RpcErrorCallback;
|
||||||
|
RpcPresence.startTimestamp = DiscordRpcHelper.DateTimeToTimestamp(DateTime.UtcNow);
|
||||||
|
|
||||||
|
Logger.Debug("Calling RPC initialize");
|
||||||
|
DiscordRpc.Initialize("430025401851707393", ref RpcHandlers, true, null);
|
||||||
|
|
||||||
|
// Do not await ;)
|
||||||
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
Logger.Trace("Running RPC callbacks");
|
while (!ShuttingDown)
|
||||||
await Task.Delay(5000);
|
{
|
||||||
}
|
Logger.Trace("Running RPC callbacks");
|
||||||
});
|
await Task.Delay(5000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
splash.Close();
|
splash.Close();
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ using Discord.WebSocket;
|
||||||
using DML.Application.Classes;
|
using DML.Application.Classes;
|
||||||
using DML.Client;
|
using DML.Client;
|
||||||
using SweetLib.Utils;
|
using SweetLib.Utils;
|
||||||
|
using SweetLib.Utils.Extensions;
|
||||||
using static SweetLib.Utils.Logger.Logger;
|
using static SweetLib.Utils.Logger.Logger;
|
||||||
|
|
||||||
namespace DML.AppCore.Classes
|
namespace DML.AppCore.Classes
|
||||||
|
@ -135,8 +136,8 @@ namespace DML.AppCore.Classes
|
||||||
Trace($"Updating lastId ({lastId}) to {m.Id}");
|
Trace($"Updating lastId ({lastId}) to {m.Id}");
|
||||||
lastId = m.Id;
|
lastId = m.Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SweetUtils.DateTimeToUnixTimeStamp(m.CreatedAt.UtcDateTime) <= StopTimestamp)
|
if (m.CreatedAt.UtcDateTime.ToUnixTimeStamp() <= StopTimestamp)
|
||||||
{
|
{
|
||||||
Debug("Found a message with a known timestamp...Stopping scan.");
|
Debug("Found a message with a known timestamp...Stopping scan.");
|
||||||
finished = true;
|
finished = true;
|
||||||
|
@ -163,7 +164,7 @@ namespace DML.AppCore.Classes
|
||||||
if (result.Count > 0)
|
if (result.Count > 0)
|
||||||
{
|
{
|
||||||
Trace("Updating StopTimestamp for next scan...");
|
Trace("Updating StopTimestamp for next scan...");
|
||||||
StopTimestamp = SweetUtils.DateTimeToUnixTimeStamp(result[result.Count - 1].CreatedAt.UtcDateTime);
|
StopTimestamp = result[result.Count - 1].CreatedAt.UtcDateTime.ToUnixTimeStamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug($"Fisnished scan of guild {GuildId} channel {ChannelId}.");
|
Debug($"Fisnished scan of guild {GuildId} channel {ChannelId}.");
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
@ -8,6 +9,7 @@ using Discord;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using DML.Application.Classes;
|
using DML.Application.Classes;
|
||||||
using SweetLib.Utils;
|
using SweetLib.Utils;
|
||||||
|
using SweetLib.Utils.Extensions;
|
||||||
using SweetLib.Utils.Logger;
|
using SweetLib.Utils.Logger;
|
||||||
|
|
||||||
namespace DML.AppCore.Classes
|
namespace DML.AppCore.Classes
|
||||||
|
@ -244,7 +246,7 @@ namespace DML.AppCore.Classes
|
||||||
fileName =
|
fileName =
|
||||||
fileName.Replace("%guild%", serverName)
|
fileName.Replace("%guild%", serverName)
|
||||||
.Replace("%channel%", channelName)
|
.Replace("%channel%", channelName)
|
||||||
.Replace("%timestamp%", SweetUtils.DateTimeToUnixTimeStamp(message.CreatedAt.UtcDateTime).ToString())
|
.Replace("%timestamp%", message.CreatedAt.UtcDateTime.ToUnixTimeStamp().ToString(CultureInfo.InvariantCulture))
|
||||||
.Replace("%name%", a.Filename)
|
.Replace("%name%", a.Filename)
|
||||||
.Replace("%id%", a.Id.ToString());
|
.Replace("%id%", a.Id.ToString());
|
||||||
|
|
||||||
|
@ -277,7 +279,7 @@ namespace DML.AppCore.Classes
|
||||||
Logger.Debug($"Downloaded attachment {a.Id}.");
|
Logger.Debug($"Downloaded attachment {a.Id}.");
|
||||||
|
|
||||||
Logger.Trace("Updating known timestamp for job...");
|
Logger.Trace("Updating known timestamp for job...");
|
||||||
job.KnownTimestamp = SweetUtils.DateTimeToUnixTimeStamp(message.CreatedAt.UtcDateTime);
|
job.KnownTimestamp = message.CreatedAt.UtcDateTime.ToUnixTimeStamp();
|
||||||
job.Store();
|
job.Store();
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|
|
@ -15,6 +15,7 @@ namespace DML.Application.Classes
|
||||||
public string FileNameScheme { get; set; } = @"%guild%\%channel%\%id%";
|
public string FileNameScheme { get; set; } = @"%guild%\%channel%\%id%";
|
||||||
public bool SkipExistingFiles { get; set; } = true;
|
public bool SkipExistingFiles { get; set; } = true;
|
||||||
public int ThreadLimit { get; set; } = 50;
|
public int ThreadLimit { get; set; } = 50;
|
||||||
|
public bool UseRPC { get; set; } = false;
|
||||||
|
|
||||||
public void Store()
|
public void Store()
|
||||||
{
|
{
|
||||||
|
|
|
@ -252,14 +252,17 @@ namespace DML.Application
|
||||||
|
|
||||||
lbProgress.Text = $"Scanned: {scanned} Downloaded: {done} Open: {totalAttachments - done}";
|
lbProgress.Text = $"Scanned: {scanned} Downloaded: {done} Open: {totalAttachments - done}";
|
||||||
|
|
||||||
Core.RpcPresence.details = "Downloading media files";
|
if (Core.Settings.UseRPC)
|
||||||
Core.RpcPresence.state = $"{done} / {totalAttachments} ({pgbProgress.Value}%)";
|
{
|
||||||
Core.RpcPresence.largeImageKey = "main";
|
Core.RpcPresence.details = "Downloading media files";
|
||||||
Core.RpcPresence.largeImageText = "Visit discordmedialoader.net";
|
Core.RpcPresence.state = $"{done} / {totalAttachments} ({pgbProgress.Value}%)";
|
||||||
Core.RpcPresence.smallImageKey = "author";
|
Core.RpcPresence.largeImageKey = "main";
|
||||||
Core.RpcPresence.smallImageText = "Made by Serraniel";
|
Core.RpcPresence.largeImageText = "Visit discordmedialoader.net";
|
||||||
|
Core.RpcPresence.smallImageKey = "author";
|
||||||
|
Core.RpcPresence.smallImageText = "Made by Serraniel";
|
||||||
|
|
||||||
Core.RpcUpdatePresence();
|
Core.RpcUpdatePresence();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void aboutToolStripMenuItem_Click(object sender, System.EventArgs e)
|
private void aboutToolStripMenuItem_Click(object sender, System.EventArgs e)
|
||||||
|
|
Loading…
Reference in a new issue