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