Skip to content

Commit f180d39

Browse files
committed
[Core] Merge group invite self to group notification
1 parent 9cee0c8 commit f180d39

4 files changed

Lines changed: 22 additions & 56 deletions

File tree

Lagrange.Core/Events/EventArgs/BotGroupInviteSelfEvent.cs

Lines changed: 0 additions & 15 deletions
This file was deleted.

Lagrange.Core/Internal/Logic/PushLogic.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,19 @@ public async ValueTask Incoming(ProtocolEvent e)
3636
string url = root.GetProperty("meta").GetProperty("news").GetProperty("jumpUrl").GetString() ?? throw new Exception("sb tx! Is this 'com.tencent.qun.invite' or 'com.tencent.tuwen.lua'?");
3737
var query = HttpUtility.ParseQueryString(new Uri(url).Query);
3838
long groupUin = uint.Parse(query["groupcode"] ?? throw new Exception("sb tx! Is this '/group/invite_join'?"));
39-
long sequence = long.Parse(query["msgseq"] ?? throw new Exception("sb tx! Is this '/group/invite_join'?"));
40-
context.EventInvoker.PostEvent(new BotGroupInviteSelfEvent(
39+
ulong sequence = ulong.Parse(query["msgseq"] ?? throw new Exception("sb tx! Is this '/group/invite_join'?"));
40+
context.EventInvoker.PostEvent(new BotGroupInviteNotificationEvent(new BotGroupInviteNotification(
41+
groupUin,
4142
sequence,
43+
context.BotUin,
44+
context.CacheContext.ResolveCachedUid(context.BotUin) ?? string.Empty,
45+
BotGroupNotificationState.Wait,
46+
null,
47+
null,
4248
message.Contact.Uin,
43-
groupUin
44-
));
49+
message.Contact.Uid,
50+
false
51+
)));
4552
break;
4653
}
4754
context.EventInvoker.PostEvent(new BotMessageEvent(message, messageEvent.Raw));

Lagrange.Milky/Event/EventService.cs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using Lagrange.Core.Common.Entity;
33
using Lagrange.Core.Message;
44
using Lagrange.Milky.Configuration;
5-
using Lagrange.Milky.Entity;
65
using Lagrange.Milky.Extension;
76
using Lagrange.Milky.Utility;
87
using Microsoft.Extensions.Hosting;
@@ -32,7 +31,6 @@ public Task StartAsync(CancellationToken token)
3231
_bot.EventInvoker.RegisterEvent<LgrEvents.BotGroupNudgeEvent>(HandleGroupNudgeEvent);
3332
_bot.EventInvoker.RegisterEvent<LgrEvents.BotGroupMemberDecreaseEvent>(HandleGroupMemberDecreaseEvent);
3433
_bot.EventInvoker.RegisterEvent<LgrEvents.BotFriendRequestEvent>(HandleFriendRequestEvent);
35-
_bot.EventInvoker.RegisterEvent<LgrEvents.BotGroupInviteSelfEvent>(HandleGroupInvitationEvent);
3634

3735
return Task.CompletedTask;
3836
}
@@ -176,31 +174,6 @@ private void HandleFriendRequestEvent(BotContext bot, LgrEvents.BotFriendRequest
176174
_logger.LogHandleEventException(nameof(LgrEvents.BotFriendRequestEvent), e);
177175
}
178176
}
179-
180-
private void HandleGroupInvitationEvent(BotContext bot, LgrEvents.BotGroupInviteSelfEvent @event)
181-
{
182-
try
183-
{
184-
_logger.LogGroupInvitationEvent(
185-
@event.InvitationSeq,
186-
@event.InitiatorUin,
187-
@event.GroupUin
188-
);
189-
var result = _convert.GroupInvitationEvent(@event);
190-
byte[] bytes = JsonUtility.SerializeToUtf8Bytes(result.GetType(), result);
191-
using (_lock.UsingReadLock())
192-
{
193-
foreach (var handler in _handlers)
194-
{
195-
handler(bytes);
196-
}
197-
}
198-
}
199-
catch (Exception e)
200-
{
201-
_logger.LogHandleEventException(nameof(LgrEvents.BotGroupInviteSelfEvent), e);
202-
}
203-
}
204177

205178
public Task StopAsync(CancellationToken token)
206179
{

Lagrange.Milky/Utility/EntityConvert.Event.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,21 @@ public partial class EntityConvert
2727
public GroupMemberDecreaseEvent GroupMemberDecreaseEvent(LgrEventArgs.BotGroupMemberDecreaseEvent @event) => new(
2828
@event.EventTime.ToUnixTimeSeconds(),
2929
_bot.BotUin,
30-
new GroupMemberDecreaseEventData(@event.GroupUin, @event.UserUin, @event.OperatorUin == 0 ? null : @event.OperatorUin)
30+
new GroupMemberDecreaseEventData(
31+
@event.GroupUin,
32+
@event.UserUin,
33+
@event.OperatorUin == 0 ? null : @event.OperatorUin
34+
)
3135
);
3236

3337
public FriendRequestEvent FriendRequestEvent(LgrEventArgs.BotFriendRequestEvent @event) => new(
3438
@event.EventTime.ToUnixTimeSeconds(),
3539
_bot.BotUin,
36-
new FriendRequestEventData(@event.InitiatorUid, @event.InitiatorUin,
37-
@event.Message, @event.Source)
38-
);
39-
40-
public GroupInvitationEvent GroupInvitationEvent(LgrEventArgs.BotGroupInviteSelfEvent @event) => new(
41-
@event.EventTime.ToUnixTimeSeconds(),
42-
_bot.BotUin,
43-
new GroupInvitationEventData(@event.InvitationSeq,
44-
@event.InitiatorUin, @event.GroupUin)
40+
new FriendRequestEventData(
41+
@event.InitiatorUid,
42+
@event.InitiatorUin,
43+
@event.Message,
44+
@event.Source
45+
)
4546
);
4647
}

0 commit comments

Comments
 (0)