@@ -527,89 +527,61 @@ private void OnNewDevice(object? state) => Task.Run(async () =>
527527 }
528528 } ) ;
529529
530+ private static readonly Dictionary < ushort , Action < byte [ ] , BotContext > > WLoginSigDelegates = new ( )
531+ {
532+ { 0x103 , ( value , context ) => context . Keystore . WLoginSigs . StWeb = value } ,
533+ { 0x143 , ( value , context ) => context . Keystore . WLoginSigs . D2 = value } ,
534+ { 0x108 , ( value , context ) => context . Keystore . WLoginSigs . Ksid = value } ,
535+ { 0x10A , ( value , context ) => context . Keystore . WLoginSigs . A2 = value } ,
536+ { 0x10C , ( value , context ) => context . Keystore . WLoginSigs . A1Key = value } ,
537+ { 0x10D , ( value , context ) => context . Keystore . WLoginSigs . A2Key = value } ,
538+ { 0x10E , ( value , context ) => context . Keystore . WLoginSigs . StKey = value } ,
539+ { 0x114 , ( value , context ) => context . Keystore . WLoginSigs . St = value } ,
540+ { 0x11A , ( value , context ) => {
541+ var reader = new BinaryPacket ( value . AsSpan ( ) ) ;
542+ reader . Read < ushort > ( ) ; // FaceId
543+ byte age = reader . Read < byte > ( ) ;
544+ byte gender = reader . Read < byte > ( ) ;
545+ string nickname = reader . ReadString ( Prefix . Int8 | Prefix . LengthOnly ) ;
546+ context . Keystore . BotInfo = new BotInfo ( age , gender , nickname ) ;
547+ } } ,
548+ { 0x120 , ( value , context ) => context . Keystore . WLoginSigs . SKey = value } ,
549+ { 0x133 , ( value , context ) => context . Keystore . WLoginSigs . WtSessionTicket = value } ,
550+ { 0x134 , ( value , context ) => context . Keystore . WLoginSigs . WtSessionTicketKey = value } ,
551+ { 0x305 , ( value , context ) => context . Keystore . WLoginSigs . D2Key = value } ,
552+ { 0x106 , ( value , context ) => context . Keystore . WLoginSigs . A1 = value } ,
553+ { 0x16A , ( value , context ) => context . Keystore . WLoginSigs . NoPicSig = value } ,
554+ { 0x16D , ( value , context ) => context . Keystore . WLoginSigs . SuperKey = value } ,
555+ { 0x512 , ( value , context ) => {
556+ context . Keystore . WLoginSigs . PsKey . Clear ( ) ;
557+
558+ var reader = new BinaryPacket ( value . AsSpan ( ) ) ;
559+ short domainCount = reader . Read < short > ( ) ;
560+ for ( int i = 0 ; i < domainCount ; i ++ )
561+ {
562+ string domain = reader . ReadString ( Prefix . Int16 | Prefix . LengthOnly ) ;
563+ string key = reader . ReadString ( Prefix . Int16 | Prefix . LengthOnly ) ;
564+ string pt4Token = reader . ReadString ( Prefix . Int16 | Prefix . LengthOnly ) ;
565+ context . Keystore . WLoginSigs . PsKey [ domain ] = key ;
566+ }
567+ } } ,
568+ { 0x543 , ( value , context ) => {
569+ var resp = ProtoHelper . Deserialize < ThirdPartyLoginResponse > ( value ) ;
570+ context . Keystore . Uid = resp . CommonInfo . RspNT . Uid ;
571+ } }
572+ } ;
573+
530574 private void ReadWLoginSigs ( Dictionary < ushort , byte [ ] > tlvs )
531575 {
532576 foreach ( var ( tag , value ) in tlvs )
533577 {
534- switch ( tag )
578+ if ( WLoginSigDelegates . TryGetValue ( tag , out var handler ) )
535579 {
536- case 0x103 :
537- _context . Keystore . WLoginSigs . StWeb = value ;
538- break ;
539- case 0x143 :
540- _context . Keystore . WLoginSigs . D2 = value ;
541- break ;
542- case 0x108 :
543- _context . Keystore . WLoginSigs . Ksid = value ;
544- break ;
545- case 0x10A :
546- _context . Keystore . WLoginSigs . A2 = value ;
547- break ;
548- case 0x10C :
549- _context . Keystore . WLoginSigs . A1Key = value ;
550- break ;
551- case 0x10D :
552- _context . Keystore . WLoginSigs . A2Key = value ;
553- break ;
554- case 0x10E :
555- _context . Keystore . WLoginSigs . StKey = value ;
556- break ;
557- case 0x114 :
558- _context . Keystore . WLoginSigs . St = value ;
559- break ;
560- case 0x11A :
561- {
562- var reader = new BinaryPacket ( value . AsSpan ( ) ) ;
563- reader . Read < ushort > ( ) ; // FaceId
564- byte age = reader . Read < byte > ( ) ;
565- byte gender = reader . Read < byte > ( ) ;
566- string nickname = reader . ReadString ( Prefix . Int8 | Prefix . LengthOnly ) ;
567- _context . Keystore . BotInfo = new BotInfo ( age , gender , nickname ) ;
568- break ;
569- }
570- case 0x120 :
571- _context . Keystore . WLoginSigs . SKey = value ;
572- break ;
573- case 0x133 :
574- _context . Keystore . WLoginSigs . WtSessionTicket = value ;
575- break ;
576- case 0x134 :
577- _context . Keystore . WLoginSigs . WtSessionTicketKey = value ;
578- break ;
579- case 0x305 :
580- _context . Keystore . WLoginSigs . D2Key = value ;
581- break ;
582- case 0x106 :
583- _context . Keystore . WLoginSigs . A1 = value ;
584- break ;
585- case 0x16A :
586- _context . Keystore . WLoginSigs . NoPicSig = value ;
587- break ;
588- case 0x16D :
589- _context . Keystore . WLoginSigs . SuperKey = value ;
590- break ;
591- case 0x512 :
592- {
593- _context . Keystore . WLoginSigs . PsKey . Clear ( ) ;
594-
595- var reader = new BinaryPacket ( value . AsSpan ( ) ) ;
596- short domainCount = reader . Read < short > ( ) ;
597- for ( int i = 0 ; i < domainCount ; i ++ )
598- {
599- string domain = reader . ReadString ( Prefix . Int16 | Prefix . LengthOnly ) ;
600- string key = reader . ReadString ( Prefix . Int16 | Prefix . LengthOnly ) ;
601- string pt4Token = reader . ReadString ( Prefix . Int16 | Prefix . LengthOnly ) ;
602- _context . Keystore . WLoginSigs . PsKey [ domain ] = key ;
603- }
604- break ;
605- }
606- case 0x543 :
607- var resp = ProtoHelper . Deserialize < ThirdPartyLoginResponse > ( value ) ;
608- _context . Keystore . Uid = resp . CommonInfo . RspNT . Uid ;
609- break ;
610- default :
611- _context . LogTrace ( Tag , "Unknown TLV: {0:X}" , tag ) ;
612- break ;
580+ handler ( value , _context ) ;
581+ }
582+ else
583+ {
584+ _context . LogTrace ( Tag , "Unknown TLV: {0:X}" , tag ) ;
613585 }
614586 }
615587 }
0 commit comments