Skip to content

Commit

Permalink
chore: merge upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
fy0 committed Jan 9, 2025
2 parents 21275e3 + 20c2b10 commit cc6c0b6
Show file tree
Hide file tree
Showing 32 changed files with 880 additions and 652 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/Lagrange.OneBot-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,24 @@ jobs:
- name: Install .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: Build Lagrange.OneBot .NET 7.0
run: dotnet publish Lagrange.OneBot/Lagrange.OneBot.csproj --no-self-contained -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:DebugType=none -p:RuntimeIdentifier=${{ matrix.runtimeIdentifier }} --framework net7.0

dotnet-version: '9.0.x'

- name: Build Lagrange.OneBot .NET 8.0
run: dotnet publish Lagrange.OneBot/Lagrange.OneBot.csproj --no-self-contained -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:DebugType=none -p:RuntimeIdentifier=${{ matrix.runtimeIdentifier }} --framework net8.0

- name: Upload binary files(${{ matrix.runtimeIdentifier }}) for .NET 7.0
uses: actions/upload-artifact@v4
if: github.event_name != 'pull_request'
with:
name: Lagrange.OneBot_${{ matrix.runtimeIdentifier }}_net7.0_NoSelfContained
path: Lagrange.OneBot/bin/Debug/net7.0/${{ matrix.runtimeIdentifier }}/publish
- name: Build Lagrange.OneBot .NET 9.0
run: dotnet publish Lagrange.OneBot/Lagrange.OneBot.csproj --no-self-contained -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:DebugType=none -p:RuntimeIdentifier=${{ matrix.runtimeIdentifier }} --framework net9.0

- name: Upload binary files(${{ matrix.runtimeIdentifier }}) for .NET 8.0
uses: actions/upload-artifact@v4
if: github.event_name != 'pull_request'
with:
name: Lagrange.OneBot_${{ matrix.runtimeIdentifier }}_net8.0_NoSelfContained
path: Lagrange.OneBot/bin/Release/net8.0/${{ matrix.runtimeIdentifier }}/publish

- name: Upload binary files(${{ matrix.runtimeIdentifier }}) for .NET 9.0
uses: actions/upload-artifact@v4
if: github.event_name != 'pull_request'
with:
name: Lagrange.OneBot_${{ matrix.runtimeIdentifier }}_net9.0_NoSelfContained
path: Lagrange.OneBot/bin/Release/net9.0/${{ matrix.runtimeIdentifier }}/publish
19 changes: 0 additions & 19 deletions .github/workflows/Lagrange.OneBot-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,6 @@ jobs:
mkdir upload
copy 'Lagrange.OneBot_${{ matrix.runtimeIdentifier }}_8.0.zip' 'upload/Lagrange.OneBot_${{ matrix.runtimeIdentifier }}_8.0.zip'
- name: Build Lagrange.OneBot .NET 7.0
run: dotnet publish Lagrange.OneBot/Lagrange.OneBot.csproj --self-contained -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:DebugType=none -p:RuntimeIdentifier=${{ matrix.runtimeIdentifier }} --framework net7.0

- name: Upload binary files(${{ matrix.runtimeIdentifier }}) for .NET 7.0
uses: actions/upload-artifact@v3
with:
name: Lagrange.OneBot_${{ matrix.runtimeIdentifier }}_8.0
path: Lagrange.OneBot/bin/Debug/net7.0/${{ matrix.runtimeIdentifier }}/publish

- name: Compress files .NET 7.0
run: Compress-Archive -Path 'Lagrange.OneBot\bin\Debug\net7.0\${{ matrix.runtimeIdentifier }}\publish\*' -DestinationPath 'Lagrange.OneBot_${{ matrix.runtimeIdentifier }}_7.0.zip'

- name: dir
run: dir 'Lagrange.OneBot\bin\Debug\net7.0\${{ matrix.runtimeIdentifier }}\publish\'

- name: Rename .NET 7.0
run: |
copy 'Lagrange.OneBot_${{ matrix.runtimeIdentifier }}_7.0.zip' 'upload/Lagrange.OneBot_${{ matrix.runtimeIdentifier }}_7.0.zip'
# - name: Rename
# if: matrix.runtimeIdentifier == 'win-x64' || matrix.runtimeIdentifier == 'win-x86'
# run: move 'Lagrange.OneBot\bin\Release\net8.0\${{ matrix.runtimeIdentifier }}\publish\Lagrange.OneBot.exe' 'Lagrange.OneBot\bin\Release\net8.0\${{ matrix.runtimeIdentifier }}\publish\Lagrange.OneBot_${{ matrix.runtimeIdentifier }}.exe'
Expand Down
14 changes: 7 additions & 7 deletions Lagrange.Core.Test/Tests/NTLoginTest.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Lagrange.Core.Common;
using Lagrange.Core.Common.Interface;
using Lagrange.Core.Common.Interface.Api;
using Lagrange.Core.Internal.Event.System;
using Lagrange.Core.Message;

namespace Lagrange.Core.Test.Tests;

Expand All @@ -13,41 +13,41 @@ public async Task LoginByPassword()
{
var deviceInfo = WtLoginTest.GetDeviceInfo();
var keyStore = WtLoginTest.LoadKeystore();

if (keyStore == null)
{
Console.WriteLine("Please login by QrCode first");
return;
}

var bot = BotFactory.Create(new BotConfig()
var bot = BotFactory.Create(new BotConfig()
{
UseIPv6Network = false,
GetOptimumServer = true,
AutoReconnect = true,
Protocol = Protocols.Linux
}, deviceInfo, keyStore);

bot.Invoker.OnBotLogEvent += (_, @event) =>
{
Utility.Console.ChangeColorByTitle(@event.Level);
Console.WriteLine(@event.ToString());
};

bot.Invoker.OnBotOnlineEvent += (_, @event) =>
{
Console.WriteLine(@event.ToString());
WtLoginTest.SaveKeystore(bot.UpdateKeystore());
};

bot.Invoker.OnBotCaptchaEvent += (_, @event) =>
{
Console.WriteLine(@event.ToString());
var captcha = Console.ReadLine();
var randStr = Console.ReadLine();
if (captcha != null && randStr != null) bot.SubmitCaptcha(captcha, randStr);
};

bot.Invoker.OnGroupInvitationReceived += (_, @event) =>
{
Console.WriteLine(@event.ToString());
Expand Down
2 changes: 1 addition & 1 deletion Lagrange.Core/Common/Interface/Api/GroupExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public static Task<bool> SetGroupRequest(this BotContext bot, BotGroupRequest re
public static Task<bool> SetGroupFilteredRequest(this BotContext bot, BotGroupRequest request, bool accept = true, string reason = "")
=> bot.ContextCollection.Business.OperationLogic.SetGroupFilteredRequest(request.GroupUin, request.Sequence, (uint)request.EventType, accept, reason);

public static Task<bool> SetFriendRequest(this BotContext bot, FriendRequestEvent request, bool accept = true)
public static Task<bool> SetFriendRequest(this BotContext bot, BotFriendRequest request, bool accept = true)
=> bot.ContextCollection.Business.OperationLogic.SetFriendRequest(request.SourceUid, accept);

public static Task<bool> GroupPoke(this BotContext bot, uint groupUin, uint friendUin)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ private async Task ResolveIncomingChain(MessageChain chain)
case ImageEntity image when !image.ImageUrl.Contains("&rkey=") && image.MsgInfo is not null:
{
var @event = image.IsGroup
? ImageGroupDownloadEvent.Create(image.GroupUin ?? 0, image.MsgInfo)
: ImageDownloadEvent.Create(image.FriendUid ?? string.Empty, image.MsgInfo);
? ImageGroupDownloadEvent.Create(chain.GroupUin ?? 0, image.MsgInfo)
: ImageDownloadEvent.Create(chain.Uid ?? string.Empty, image.MsgInfo);

var results = await Collection.Business.SendEvent(@event);
if (results.Count != 0)
Expand All @@ -425,6 +425,24 @@ private async Task ResolveOutgoingChain(MessageChain chain)
face.SysFaceEntry ??= await cache.GetCachedFaceEntity(face.FaceId);
break;
}
case BounceFaceEntity bounceFace:
{
var cache = Collection.Business.CachingLogic;

// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
if (bounceFace.Name != null)
break;

string name = (await cache.GetCachedFaceEntity(bounceFace.FaceId))?.QDes ?? string.Empty;

// Because the name is used as a preview text, it should not start with '/'
// But the QDes of the face may start with '/', so remove it
if (name.StartsWith('/'))
name = name[1..];

bounceFace.Name = name;
break;
}
case ForwardEntity forward when forward.TargetUin != 0:
{
var cache = Collection.Business.CachingLogic;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma warning disable CS8618

using ProtoBuf;

namespace Lagrange.Core.Internal.Packets.Message.Element.Implementation.Extra;

[ProtoContract]
internal class QBounceFaceExtra
{
[ProtoMember(1)] public int Field1 { get; set; } = 13;

[ProtoMember(2)] public uint Count { get; set; } = 1;

[ProtoMember(3)] public string Name { get; set; } = string.Empty;

[ProtoMember(6)] public QSmallFaceExtra Face { get; set; }

[ProtoContract]
public class FallbackPreviewTextPb
{
[ProtoMember(1)] public string Text { get; set; } = string.Empty;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,9 @@ internal class PicExtBizInfo

[ProtoMember(2)] public string TextSummary { get; set; }

[ProtoMember(11)] public byte[] BytesPbReserveC2c { get; set; }
[ProtoMember(11)] public byte[]? BytesPbReserveC2c { get; set; }

[ProtoMember(12)] public byte[] BytesPbReserveTroop { get; set; }
[ProtoMember(12)] public byte[]? BytesPbReserveTroop { get; set; }

[ProtoMember(1001)] public uint FromScene { get; set; }

Expand Down
6 changes: 3 additions & 3 deletions Lagrange.Core/Internal/Packets/SsoPacker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ public static BinaryPacket Build(SsoPacket packet, BotAppInfo appInfo, BotDevice
var writer = new BinaryPacket();

var sign = signProvider.Sign(packet.Command, packet.Sequence, packet.Payload.ToArray(), out var extra, out var token);
var signature = new NTDeviceSign
var signature = new SsoReserveFields
{
Sign = sign == null ? null : new SecInfo
SecInfo = sign == null ? null : new SsoSecureInfo
{
SecSign = sign,
SecToken = token,
SecExtra = extra
},
Trace = StringGen.GenerateTrace(),
TraceParent = StringGen.GenerateTrace(),
Uid = keystore.Uid
};
var stream = new MemoryStream();
Expand Down
16 changes: 0 additions & 16 deletions Lagrange.Core/Internal/Packets/System/NTDeviceSign.cs

This file was deleted.

49 changes: 49 additions & 0 deletions Lagrange.Core/Internal/Packets/System/SsoReserveFields.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using ProtoBuf;

namespace Lagrange.Core.Internal.Packets.System;

[ProtoContract]
internal class SsoReserveFields
{
[ProtoMember(4)] public byte[]? ClientIpcookie { get; set; }

[ProtoMember(9)] public uint? Flag { get; set; }

[ProtoMember(10)] public uint? EnvId { get; set; }

[ProtoMember(11)] public uint? LocaleId { get; set; }

[ProtoMember(12)] public string? Qimei { get; set; }

[ProtoMember(13)] public byte[]? Env { get; set; }

[ProtoMember(14)] public uint? NewconnFlag { get; set; }

[ProtoMember(15)] public string? TraceParent { get; set; }

[ProtoMember(16)] public string? Uid { get; set; }

[ProtoMember(18)] public uint? Imsi { get; set; }

[ProtoMember(19)] public uint? NetworkType { get; set; }

[ProtoMember(20)] public uint? IpStackType { get; set; }

[ProtoMember(21)] public uint? MsgType { get; set; }

[ProtoMember(22)] public string? TrpcRsp { get; set; }

[ProtoMember(23)] public Dictionary<string, string>? TransInfo { get; set; }

[ProtoMember(24)] public SsoSecureInfo? SecInfo { get; set; }

[ProtoMember(25)] public uint? SecSigFlag { get; set; }

[ProtoMember(26)] public uint? NtCoreVersion { get; set; }

[ProtoMember(27)] public uint? SsoRouteCost { get; set; }

[ProtoMember(28)] public uint? SsoIpOrigin { get; set; }

[ProtoMember(30)] public byte[]? PresureToken { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Lagrange.Core.Internal.Packets.System;
/// <para>没错 这个就是臭名昭著的0C03算法 每一个包都有这个几把</para>
/// </summary>
[ProtoContract]
internal class SecInfo
internal class SsoSecureInfo
{
[ProtoMember(1)] public byte[]? SecSign { get; set; }

Expand Down
Loading

0 comments on commit cc6c0b6

Please sign in to comment.