Skip to content

Commit

Permalink
[OneBot] Fixed the problem that the friend message type is incorrect (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkRRb authored Feb 7, 2025
1 parent bc37832 commit 6dad4a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Lagrange.OneBot/Core/Notify/NotifyService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,16 @@ await service.SendJsonAsync(new OneBotGroupRecall(bot.BotUin)
logger.LogInformation(@event.ToString());

var sequence = realm.Do(realm => realm.All<MessageRecord>()
.First(record => record.TypeInt == (int)MessageType.Friend
.FirstOrDefault(record => record.TypeInt == (int)MessageType.Friend
&& record.FromUinLong == @event.FriendUin
&& record.ClientSequenceLong == @event.ClientSequence
&& record.MessageIdLong == (0x01000000L << 32 | @event.Random)
)
)?
.Sequence);
if (sequence == null) {
logger.LogWarning("Unable to find the {} message sent by {}", @event.ClientSequence, @event.FriendUin);
return;
}

await service.SendJsonAsync(new OneBotFriendRecall(bot.BotUin)
{
Expand Down
1 change: 1 addition & 0 deletions Lagrange.OneBot/Database/MessageRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public static int CalcMessageHash(ulong msgId, uint seq)
public static implicit operator MessageRecord(MessageChain chain) => new()
{
Id = CalcMessageHash(chain.MessageId, chain.Sequence),
Type = chain.Type,
Sequence = chain.Sequence,
ClientSequence = chain.ClientSequence,
MessageId = chain.MessageId,
Expand Down

0 comments on commit 6dad4a4

Please sign in to comment.