1- using System . Net . Http . Json ;
21using System . Text ;
32using System . Text . Json . Nodes ;
43using System . Text . Json . Serialization ;
@@ -14,8 +13,10 @@ public interface IBotSignProvider
1413 Task < SsoSecureInfo ? > GetSecSign ( long uin , string cmd , int seq , ReadOnlyMemory < byte > body ) ;
1514}
1615
17- internal class DefaultBotSignProvider ( Protocols protocol , BotAppInfo appInfo ) : IBotSignProvider , IDisposable
16+ internal class DefaultBotSignProvider ( BotContext context ) : IBotSignProvider , IDisposable
1817{
18+ private const string Tag = nameof ( DefaultBotSignProvider ) ;
19+
1920 private static readonly HashSet < string > WhiteListCommand =
2021 [
2122 "trpc.o3.ecdh_access.EcdhAccess.SsoEstablishShareKey" ,
@@ -61,14 +62,14 @@ internal class DefaultBotSignProvider(Protocols protocol, BotAppInfo appInfo) :
6162
6263 private readonly HttpClient _client = new ( ) ;
6364
64- private readonly string _url = protocol switch
65+ private readonly string _url = context . Config . Protocol switch
6566 {
6667 Protocols . Windows => throw new NotSupportedException ( "Windows is not supported" ) ,
6768 Protocols . MacOs => throw new NotSupportedException ( "MacOs is not supported" ) ,
68- Protocols . Linux => $ "https://sign.lagrangecore.org/api/sign/{ appInfo . AppClientVersion } ",
69+ Protocols . Linux => $ "https://sign.lagrangecore.org/api/sign/{ context . AppInfo . AppClientVersion } ",
6970 Protocols . AndroidPhone => throw new NotSupportedException ( "AndroidPhone is not supported" ) ,
7071 Protocols . AndroidPad => throw new NotSupportedException ( "AndroidPad is not supported" ) ,
71- _ => throw new ArgumentOutOfRangeException ( nameof ( protocol ) )
72+ _ => throw new ArgumentOutOfRangeException ( )
7273 } ;
7374
7475 public bool IsWhiteListCommand ( string cmd ) => WhiteListCommand . Contains ( cmd ) ;
@@ -99,7 +100,7 @@ internal class DefaultBotSignProvider(Protocols protocol, BotAppInfo appInfo) :
99100 }
100101 catch ( Exception e )
101102 {
102- // TODO: Log the exception
103+ context . LogWarning ( Tag , $ "Failed to get sign: { e . Message } " ) ;
103104 return null ;
104105 }
105106 }
0 commit comments