#10 Fixed handling of outdated / wrong logintokens
This commit is contained in:
parent
d773f7036d
commit
c9a2fc1140
|
@ -22,4 +22,4 @@ namespace DML.Client
|
||||||
return Client.LoginState == LoginState.LoggedIn && Client.ConnectionState == ConnectionState.Connected;
|
return Client.LoginState == LoginState.LoggedIn && Client.ConnectionState == ConnectionState.Connected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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,7 +176,6 @@ 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;
|
||||||
|
|
||||||
|
@ -183,10 +183,19 @@ namespace DML.Application.Classes
|
||||||
|
|
||||||
while (!loggedIn)
|
while (!loggedIn)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(Settings.LoginToken))
|
var token = "abc";
|
||||||
|
try
|
||||||
{
|
{
|
||||||
Logger.Debug("Trying to login with last known token...");
|
if (!string.IsNullOrEmpty(Settings.LoginToken))
|
||||||
loggedIn = await DMLClient.Login(Settings.LoginToken);
|
{
|
||||||
|
Logger.Debug("Trying to login with last known token...");
|
||||||
|
loggedIn = await DMLClient.Login(token);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (HttpException e)
|
||||||
|
{
|
||||||
|
Logger.Warn("HTTPException occured during login. Probably from login token.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loggedIn)
|
if (!loggedIn)
|
||||||
|
@ -248,12 +257,16 @@ 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,9 +293,11 @@ 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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue