Merge branch 'support/1.2'
This commit is contained in:
commit
fec2339e21
|
@ -1,11 +1,5 @@
|
||||||
using System;
|
using Discord;
|
||||||
using System.Globalization;
|
using Discord.Net;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using Discord;
|
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using DML.AppCore.Classes;
|
using DML.AppCore.Classes;
|
||||||
using DML.Application.Dialogs;
|
using DML.Application.Dialogs;
|
||||||
|
@ -16,6 +10,13 @@ using SharpRaven.Data;
|
||||||
using SweetLib.Utils;
|
using SweetLib.Utils;
|
||||||
using SweetLib.Utils.Logger;
|
using SweetLib.Utils.Logger;
|
||||||
using SweetLib.Utils.Logger.Memory;
|
using SweetLib.Utils.Logger.Memory;
|
||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
using Logger = SweetLib.Utils.Logger.Logger;
|
using Logger = SweetLib.Utils.Logger.Logger;
|
||||||
|
|
||||||
namespace DML.Application.Classes
|
namespace DML.Application.Classes
|
||||||
|
@ -175,13 +176,14 @@ namespace DML.Application.Classes
|
||||||
|
|
||||||
|
|
||||||
Logger.Info("Trying to log into discord...");
|
Logger.Info("Trying to log into discord...");
|
||||||
var abort = false;
|
|
||||||
|
|
||||||
DMLClient.Client.Connected += Client_Connected;
|
DMLClient.Client.Connected += Client_Connected;
|
||||||
|
|
||||||
var loggedIn = false;
|
var loggedIn = false;
|
||||||
|
|
||||||
while (!loggedIn)
|
while (!loggedIn)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(Settings.LoginToken))
|
if (!string.IsNullOrEmpty(Settings.LoginToken))
|
||||||
{
|
{
|
||||||
|
@ -189,50 +191,23 @@ namespace DML.Application.Classes
|
||||||
loggedIn = await DMLClient.Login(Settings.LoginToken);
|
loggedIn = await DMLClient.Login(Settings.LoginToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (HttpException)
|
||||||
|
{
|
||||||
|
Logger.Warn("HTTPException occured during login. Probably from login token.");
|
||||||
|
}
|
||||||
|
|
||||||
if (!loggedIn)
|
if (!loggedIn)
|
||||||
{
|
{
|
||||||
Logger.Debug("Showing dialog for username and password...");
|
Logger.Debug("Showing dialog for username and password...");
|
||||||
var loginDlg = new LoginDialog();
|
var loginDlg = new LoginDialog();
|
||||||
loginDlg.ShowDialog();
|
if (loginDlg.ShowDialog() != DialogResult.OK)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*while ((Client.LoginState != LoginState.LoggedIn || Client.ConnectionState!=ConnectionState.Connected) && !abort)
|
|
||||||
{
|
{
|
||||||
Logger.Debug(Client.ConnectionState.ToString());
|
return;
|
||||||
Logger.Debug(Client.LoginState.ToString());
|
|
||||||
|
|
||||||
Logger.Trace("Entering login loop.");
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (Client.ConnectionState == ConnectionState.Connecting)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Settings.LoginToken))
|
|
||||||
{
|
|
||||||
Logger.Debug("Trying to login with last known token...");
|
|
||||||
await Client.LoginAsync(TokenType.User, Settings.LoginToken);
|
|
||||||
await Client.StartAsync();
|
|
||||||
await Task.Delay(1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (HttpException ex)
|
|
||||||
{
|
|
||||||
Logger.Warn($"Login seems to have failed or gone wrong: {ex.GetType().Name} - {ex.Message}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Client.LoginState == LoginState.LoggedOut)
|
|
||||||
{
|
|
||||||
Settings.Password = string.Empty;
|
|
||||||
Logger.Debug("Showing dialog for username and password...");
|
|
||||||
var loginDlg = new LoginDialog();
|
|
||||||
loginDlg.ShowDialog();
|
|
||||||
Logger.Trace("Dialog closed.");
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
Logger.Debug("Start checking for invalid jobs...");
|
Logger.Debug("Start checking for invalid jobs...");
|
||||||
|
|
||||||
//Client
|
//Client
|
||||||
|
@ -248,13 +223,17 @@ namespace DML.Application.Classes
|
||||||
var isError = false;
|
var isError = false;
|
||||||
var guild = FindServerById(job.GuildId);
|
var guild = FindServerById(job.GuildId);
|
||||||
if (guild == null)
|
if (guild == null)
|
||||||
|
{
|
||||||
isError = true;
|
isError = true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var channel = FindChannelById(guild, job.ChannelId);
|
var channel = FindChannelById(guild, job.ChannelId);
|
||||||
if (channel == null)
|
if (channel == null)
|
||||||
|
{
|
||||||
isError = true;
|
isError = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isError)
|
if (isError)
|
||||||
{
|
{
|
||||||
|
@ -280,11 +259,13 @@ namespace DML.Application.Classes
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.Error($"{ex.Message} occured at: {ex.StackTrace}");
|
Logger.Error($"{ex.Message} [{ex.GetType().Name}] occured at: {ex.StackTrace}");
|
||||||
if (MessageBox.Show($"An error occured while running Discord Media Loader:\n{ex.GetType().Name}: {ex.Message}\n\nDo you aggree to sending the error report to the creator of the tool?", "Discord Media Loader", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
if (MessageBox.Show($"An error occured while running Discord Media Loader:\n{ex.GetType().Name}: {ex.Message}\n\nDo you aggree to sending the error report to the creator of the tool?", "Discord Media Loader", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||||
|
{
|
||||||
Raven.Capture(new SentryEvent(ex));
|
Raven.Capture(new SentryEvent(ex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Task Client_Connected()
|
private static Task Client_Connected()
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("Serraniel")]
|
[assembly: AssemblyCompany("Serraniel")]
|
||||||
[assembly: AssemblyProduct("Discord Media Loader.Application")]
|
[assembly: AssemblyProduct("Discord Media Loader.Application")]
|
||||||
[assembly: AssemblyCopyright("Copyright © 2017 - 2018 by Serraniel")]
|
[assembly: AssemblyCopyright("Copyright © 2017 - 2019 by Serraniel")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||||
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||||
// übernehmen, indem Sie "*" eingeben:
|
// übernehmen, indem Sie "*" eingeben:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.2.0.0")]
|
[assembly: AssemblyVersion("1.2.1.0")]
|
||||||
[assembly: AssemblyFileVersion("1.2.0.0")]
|
[assembly: AssemblyFileVersion("1.2.1.0")]
|
||||||
|
|
|
@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("Serraniel")]
|
[assembly: AssemblyCompany("Serraniel")]
|
||||||
[assembly: AssemblyProduct("Discord Media Loader")]
|
[assembly: AssemblyProduct("Discord Media Loader")]
|
||||||
[assembly: AssemblyCopyright("Copyright © 2017 - 2018 by Serraniel")]
|
[assembly: AssemblyCopyright("Copyright © 2017 - 2019 by Serraniel")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue