Expose qrcode url to user
This commit is contained in:
parent
9967ee18f7
commit
9062298220
|
@ -36,7 +36,7 @@ public class WtLoginTest
|
||||||
var qrCode = await bot.FetchQrCode();
|
var qrCode = await bot.FetchQrCode();
|
||||||
if (qrCode != null)
|
if (qrCode != null)
|
||||||
{
|
{
|
||||||
await File.WriteAllBytesAsync("qr.png", qrCode);
|
await File.WriteAllBytesAsync("qr.png", qrCode.Value.QrCode);
|
||||||
await bot.LoginByQrCode();
|
await bot.LoginByQrCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,9 @@ public static class BotExt
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fetch the qrcode for QRCode Login
|
/// Fetch the qrcode for QRCode Login
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>the byte of QRCode, usually in the form of PNG</returns>
|
/// <returns>return url and qrcode image in PNG format</returns>
|
||||||
public static async Task<byte[]?> FetchQrCode(this BotContext bot)
|
public static Task<(string Url, byte[] QrCode)?> FetchQrCode(this BotContext bot)
|
||||||
=> await bot.ContextCollection.Business.WtExchangeLogic.FetchQrCode();
|
=> bot.ContextCollection.Business.WtExchangeLogic.FetchQrCode();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Use this method to login by QrCode, you should call <see cref="FetchQrCode"/> first
|
/// Use this method to login by QrCode, you should call <see cref="FetchQrCode"/> first
|
||||||
|
@ -20,8 +20,8 @@ public static class BotExt
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Use this method to login by password, EasyLogin may be preformed if there is sig in <see cref="BotKeystore"/>
|
/// Use this method to login by password, EasyLogin may be preformed if there is sig in <see cref="BotKeystore"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static async Task<bool> LoginByPassword(this BotContext bot)
|
public static Task<bool> LoginByPassword(this BotContext bot)
|
||||||
=> await bot.ContextCollection.Business.WtExchangeLogic.LoginByPassword();
|
=> bot.ContextCollection.Business.WtExchangeLogic.LoginByPassword();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Submit the captcha of the url given by the <see cref="EventInvoker.OnBotCaptchaEvent"/>
|
/// Submit the captcha of the url given by the <see cref="EventInvoker.OnBotCaptchaEvent"/>
|
||||||
|
|
|
@ -56,7 +56,7 @@ internal class WtExchangeLogic : LogicBase
|
||||||
/// <para>1. resolve wtlogin.trans_emp CMD0x31 packet</para>
|
/// <para>1. resolve wtlogin.trans_emp CMD0x31 packet</para>
|
||||||
/// <para>2. Schedule wtlogin.trans_emp CMD0x12 Task</para>
|
/// <para>2. Schedule wtlogin.trans_emp CMD0x12 Task</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<byte[]?> FetchQrCode()
|
public async Task<(string, byte[])?> FetchQrCode()
|
||||||
{
|
{
|
||||||
Collection.Log.LogInfo(Tag, "Connecting Servers...");
|
Collection.Log.LogInfo(Tag, "Connecting Servers...");
|
||||||
if (!await Collection.Socket.Connect()) return null;
|
if (!await Collection.Socket.Connect()) return null;
|
||||||
|
@ -73,7 +73,7 @@ internal class WtExchangeLogic : LogicBase
|
||||||
Collection.Keystore.Session.QrUrl = @event.Url;
|
Collection.Keystore.Session.QrUrl = @event.Url;
|
||||||
|
|
||||||
Collection.Log.LogInfo(Tag, $"QrCode Fetched, Expiration: {@event.Expiration} seconds");
|
Collection.Log.LogInfo(Tag, $"QrCode Fetched, Expiration: {@event.Expiration} seconds");
|
||||||
return @event.QrCode;
|
return (@event.Url, @event.QrCode);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class LagrangeApp : IHost
|
||||||
var qrCode = await Instance.FetchQrCode();
|
var qrCode = await Instance.FetchQrCode();
|
||||||
if (qrCode != null)
|
if (qrCode != null)
|
||||||
{
|
{
|
||||||
QrCodeHelper.Output(Instance.ContextCollection.Keystore.Session.QrUrl ?? "");
|
QrCodeHelper.Output(qrCode.Value.Url ?? "");
|
||||||
await Instance.LoginByQrCode();
|
await Instance.LoginByQrCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue