Skip to content

Commit 64cccc3

Browse files
committed
rebase
1 parent 75252b7 commit 64cccc3

18 files changed

Lines changed: 330 additions & 27 deletions

File tree

.github/workflows/milky-build.yaml

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,32 @@ on:
2626
jobs:
2727
build:
2828
runs-on: ${{ matrix.os }}
29+
permissions:
30+
contents: write
2931
strategy:
3032
matrix:
3133
include:
3234
- os: windows-latest
3335
rid: win-x64
36+
artifact-rid: win-x64
3437
binary-extension: '.exe'
3538
- os: macos-latest
3639
rid: osx-arm64
40+
artifact-rid: osx-arm64
3741
binary-extension: ''
3842
- os: ubuntu-latest
39-
rid: linux-x64
43+
rid: linux-musl-x64
44+
artifact-rid: linux-x64
45+
binary-extension: ''
46+
- os: ubuntu-24.04-arm
47+
rid: linux-musl-arm64
48+
artifact-rid: linux-arm64
4049
binary-extension: ''
4150

4251
env:
4352
RUNTIME_IDENTIFIER: ${{ matrix.rid }}
4453

4554
steps:
46-
- name: Install Linux Dependencies
47-
if: matrix.os == 'ubuntu-latest'
48-
run: sudo apt-get update && sudo apt-get install -y clang zlib1g-dev
49-
5055
- name: Setup .NET SDK
5156
uses: actions/setup-dotnet@v4
5257
with:
@@ -55,18 +60,36 @@ jobs:
5560
- name: Checkout code
5661
uses: actions/checkout@v4
5762

58-
- name: Publish
63+
- name: Publish on non-Linux
64+
if: runner.os != 'Linux'
5965
run: dotnet publish Lagrange.Milky -c Release -r ${{ matrix.rid }}
6066

61-
- if: github.event_name != 'pull_request'
62-
uses: actions/upload-artifact@v4
63-
with:
64-
name: Lagrange.Milky-${{ matrix.rid }}
65-
path: Lagrange.Milky/bin/Release/net10.0/${{ matrix.rid }}/publish/Lagrange.Milky${{ matrix.binary-extension }}
66-
- if: github.event_name != 'pull_request'
67-
uses: actions/upload-artifact@v4
67+
- name: Publish on Linux
68+
if: runner.os == 'Linux'
69+
run: |
70+
docker run --rm \
71+
-e HOME=/tmp \
72+
-e DOTNET_CLI_HOME=/tmp/dotnet \
73+
-e NUGET_PACKAGES=/tmp/nuget/packages \
74+
-e DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 \
75+
-v "$PWD:/src" \
76+
-w /src \
77+
mcr.microsoft.com/dotnet/sdk:10.0-alpine-aot \
78+
sh -lc "apk add --no-cache ca-certificates cmake make pkgconf openssl-dev openssl-libs-static zlib-static && mkdir -p /tmp/dotnet /tmp/nuget/packages && dotnet publish Lagrange.Milky -c Release -r ${{ matrix.rid }} && chmod -R a+rwX /src/Lagrange.Milky/bin"
79+
80+
- name: Rename Binary
81+
if: github.event_name != 'pull_request'
82+
shell: bash
83+
run: |
84+
mv "Lagrange.Milky/bin/Release/net10.0/${{ matrix.rid }}/publish/Lagrange.Milky${{ matrix.binary-extension }}" \
85+
"Lagrange.Milky/bin/Release/net10.0/${{ matrix.rid }}/publish/Lagrange.Milky-${{ matrix.artifact-rid }}${{ matrix.binary-extension }}"
86+
87+
- name: Upload to Pre-Release
88+
if: github.event_name != 'pull_request'
89+
uses: softprops/action-gh-release@v2
6890
with:
69-
name: Lagrange.Milky-${{ matrix.rid }}-symbol-files
70-
path: |
71-
Lagrange.Milky/bin/Release/net10.0/${{ matrix.rid }}/publish/*
72-
!Lagrange.Milky/bin/Release/net10.0/${{ matrix.rid }}/publish/Lagrange.Milky${{ matrix.binary-extension }}
91+
tag_name: nightly
92+
name: Nightly Build
93+
prerelease: true
94+
make_latest: false
95+
files: Lagrange.Milky/bin/Release/net10.0/${{ matrix.rid }}/publish/Lagrange.Milky-${{ matrix.artifact-rid }}${{ matrix.binary-extension }}

Lagrange.Core/Common/Entity/BotGroupNotificationType.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ namespace Lagrange.Core.Common.Entity;
33
public enum BotGroupNotificationType
44
{
55
Join = 1,
6+
InviteSelf = 2,
67
SetAdmin = 3,
78
KickOther = 6,
89
KickSelf = 7,

Lagrange.Core/Common/Interface/MessageExt.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,7 @@ public static Task GroupRename(this BotContext context, long groupUin, string na
6161

6262
public static Task GroupQuit(this BotContext context, long groupUin)
6363
=> context.EventContext.GetLogic<OperationLogic>().GroupQuit(groupUin);
64+
65+
public static Task SetFriendRequestAccept(this BotContext context, string targetUid)
66+
=> context.EventContext.GetLogic<OperationLogic>().SetFriendRequestAccept(targetUid);
6467
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace Lagrange.Core.Internal.Events.System;
2+
3+
internal class SetFriendRequestAcceptEventReq(string targetUid) : ProtocolEvent
4+
{
5+
public string TargetUid { get; } = targetUid;
6+
}
7+
8+
internal class SetFriendRequestAcceptEventResp : ProtocolEvent
9+
{
10+
public static readonly SetFriendRequestAcceptEventResp Default = new();
11+
}

Lagrange.Core/Internal/Logic/OperationLogic.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,13 @@ public async Task GroupMemberRename(long groupUin, long targetUin, string name)
6666
}
6767
await context.EventContext.SendEvent<GroupMemberRenameEventResp>(new GroupMemberRenameEventReq(groupUin, uid, name));
6868
}
69-
69+
70+
public async Task SetFriendRequestAccept(string targetUid)
71+
{
72+
await context.EventContext.SendEvent<SetFriendRequestAcceptEventResp>(new SetFriendRequestAcceptEventReq(targetUid));
73+
await context.CacheContext.GetFriendList(true);
74+
}
75+
7076
public async Task GroupQuit(long groupUin)
7177
{
7278
await context.EventContext.SendEvent<GroupQuitEventResp>(new GroupQuitEventReq(groupUin));

Lagrange.Core/Internal/Logic/Processors/GroupMemberIncreaseProcessor.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ internal override async ValueTask<bool> Handle(BotContext context, MsgType msgTy
3737

3838
if (@event != null)
3939
{
40+
if (@event.MemberUin == context.BotUin) // Bot itself joined the group, resolve group info first
41+
{
42+
_ = await context.CacheContext.GetGroupList(true);
43+
}
44+
4045
context.EventInvoker.PostEvent(@event);
4146
_ = await context.CacheContext.GetMemberList(increase.GroupUin, true);
4247
return true;

Lagrange.Core/Internal/Logic/Processors/RichTextMsgProcessor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ internal override async ValueTask<bool> Handle(BotContext context, MsgType msgTy
2525

2626
private bool TryHandleLightApp(BotContext context, BotMessage message, LightAppEntity app)
2727
{
28-
if ((app.AppName == "com.tencent.qun.invite" || app.AppName == "com.tencent.qun.invite") && TryHandleQunInvite(context, message, app)) return true;
28+
if ((app.AppName == "com.tencent.qun.invite" || app.AppName == "com.tencent.qun.invite" || app.AppName == "com.tencent.tuwen.lua") && TryHandleQunInvite(context, message, app)) return true;
2929

3030
return false;
3131
}
@@ -40,8 +40,8 @@ private bool TryHandleQunInvite(BotContext context, BotMessage message, LightApp
4040

4141
string? url = root.GetProperty("meta").GetProperty("news").GetProperty("jumpUrl").GetString();
4242
if (url == null) throw new Exception($"TryHandleQunInvite failed! LightApp: {app.Payload}");
43-
44-
var query = HttpUtility.ParseQueryString(new Uri(url).Query);
43+
int queryStart = url.IndexOf('?');
44+
var query = HttpUtility.ParseQueryString(queryStart >= 0 ? url[(queryStart + 1)..] : string.Empty);
4545
long uin = uint.Parse(query["groupcode"] ?? throw new Exception($"TryHandleQunInvite failed! LightApp: {app.Payload}"));
4646
ulong sequence = ulong.Parse(query["msgseq"] ?? throw new Exception($"TryHandleQunInvite failed! LightApp: {app.Payload}"));
4747

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using Lagrange.Proto;
2+
3+
namespace Lagrange.Core.Internal.Packets.Service;
4+
5+
[ProtoPackable]
6+
internal partial class DB5DReqBody
7+
{
8+
[ProtoMember(1)] public uint Accept { get; set; } // 3 for accept, 5 for reject
9+
10+
[ProtoMember(2)] public string TargetUid { get; set; }
11+
}
12+
13+
[ProtoPackable]
14+
internal partial class DB5DRspBody;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using Lagrange.Core.Common;
2+
using Lagrange.Core.Internal.Events;
3+
using Lagrange.Core.Internal.Events.System;
4+
using Lagrange.Core.Internal.Packets.Service;
5+
6+
namespace Lagrange.Core.Internal.Services.System;
7+
8+
[EventSubscribe<SetFriendRequestAcceptEventReq>(Protocols.All)]
9+
[Service("OidbSvcTrpcTcp.0xb5d_44")]
10+
internal class SetFriendRequestAcceptService: OidbService<SetFriendRequestAcceptEventReq, SetFriendRequestAcceptEventResp, DB5DReqBody, DB5DRspBody>
11+
{
12+
private protected override uint Command => 0xb5d;
13+
14+
private protected override uint Service => 44;
15+
16+
private protected override Task<DB5DReqBody> ProcessRequest(SetFriendRequestAcceptEventReq inviteAccept, BotContext context)
17+
{
18+
return Task.FromResult(new DB5DReqBody
19+
{
20+
Accept = 3,
21+
TargetUid = inviteAccept.TargetUid
22+
});
23+
}
24+
25+
private protected override Task<SetFriendRequestAcceptEventResp> ProcessResponse(DB5DRspBody response, BotContext context)
26+
{
27+
return Task.FromResult(SetFriendRequestAcceptEventResp.Default);
28+
}
29+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Text.Json.Serialization;
2+
using Lagrange.Core;
3+
using Lagrange.Core.Common.Interface;
4+
5+
namespace Lagrange.Milky.Api.Handler.Friend;
6+
7+
[Api("accept_friend_request")]
8+
public class AcceptFriendRequestHandler(BotContext bot) : IEmptyResultApiHandler<AcceptFriendRequestHandlerParameter>
9+
{
10+
private readonly BotContext _bot = bot;
11+
12+
public async Task HandleAsync(AcceptFriendRequestHandlerParameter parameter, CancellationToken token)
13+
{
14+
await _bot.SetFriendRequestAccept(parameter.InitiatorUid);
15+
}
16+
}
17+
18+
public class AcceptFriendRequestHandlerParameter(string initiatorUid, bool isFiltered)
19+
{
20+
[JsonRequired]
21+
[JsonPropertyName("initiator_uid")]
22+
public string InitiatorUid { get; init; } = initiatorUid;
23+
24+
[JsonRequired]
25+
[JsonPropertyName("is_filtered")]
26+
public bool IsFiltered { get; init; } = isFiltered;
27+
}

0 commit comments

Comments
 (0)