Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
sisi0318 committed Nov 3, 2024
2 parents fcf419f + f726c96 commit 259d949
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 19 deletions.
8 changes: 4 additions & 4 deletions Lagrange.Core/Common/Interface/Api/OperationExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,11 @@ public static Task<string> UploadImage(this BotContext bot, ImageEntity entity)
public static Task<ImageOcrResult?> OcrImage(this BotContext bot, ImageEntity entity)
=> bot.ContextCollection.Business.OperationLogic.ImageOcr(entity);

public static Task<(int Code, string ErrMsg, string? Url)> GetGroupGenerateAiRecordUrl(this BotContext bot, uint groupUin, string character, string text, uint chattype)
=> bot.ContextCollection.Business.OperationLogic.GetGroupGenerateAiRecordUrl(groupUin, character, text, chattype);
public static Task<(int Code, string ErrMsg, string? Url)> GetGroupGenerateAiRecordUrl(this BotContext bot, uint groupUin, string character, string text, uint chatType)
=> bot.ContextCollection.Business.OperationLogic.GetGroupGenerateAiRecordUrl(groupUin, character, text, chatType);

public static Task<(int Code, string ErrMsg, RecordEntity? RecordEntity)> GetGroupGenerateAiRecord(this BotContext bot, uint groupUin, string character, string text, uint chattype)
=> bot.ContextCollection.Business.OperationLogic.GetGroupGenerateAiRecord(groupUin, character, text, chattype);
public static Task<(int Code, string ErrMsg, RecordEntity? RecordEntity)> GetGroupGenerateAiRecord(this BotContext bot, uint groupUin, string character, string text, uint chatType)
=> bot.ContextCollection.Business.OperationLogic.GetGroupGenerateAiRecord(groupUin, character, text, chatType);

public static Task<(int Code, string ErrMsg, List<AiCharacterList>? Result)> GetAiCharacters(this BotContext bot, uint chatType, uint groupUin = 42)
=> bot.ContextCollection.Business.OperationLogic.GetAiCharacters(chatType, groupUin);
Expand Down
1 change: 1 addition & 0 deletions Lagrange.Core/Event/EventArg/GroupMemberDecreaseEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public GroupMemberDecreaseEvent(uint groupUin, uint memberUin, uint? operatorUin
public enum EventType : uint
{
KickMe = 3,
Disband = 129,
Leave = 130,
Kick = 131
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -730,9 +730,9 @@ public async Task<bool> FriendJoinEmojiChain(uint friendUin, uint emojiId, uint
return results.Count != 0 && results[0].ResultCode == 0;
}

public async Task<(int Code, string ErrMsg, string? Url)> GetGroupGenerateAiRecordUrl(uint groupUin, string character, string text, uint chattype)
public async Task<(int Code, string ErrMsg, string? Url)> GetGroupGenerateAiRecordUrl(uint groupUin, string character, string text, uint chatType)
{
var (code, errMsg, record) = await GetGroupGenerateAiRecord(groupUin, character, text, chattype);
var (code, errMsg, record) = await GetGroupGenerateAiRecord(groupUin, character, text, chatType);
if (code != 0)
return (code, errMsg, null);

Expand All @@ -746,9 +746,9 @@ public async Task<bool> FriendJoinEmojiChain(uint friendUin, uint emojiId, uint
: (finalResult.ResultCode, "Failed to get group ai record", null);
}

public async Task<(int Code, string ErrMsg, RecordEntity? Record)> GetGroupGenerateAiRecord(uint groupUin, string character, string text, uint chattype)
public async Task<(int Code, string ErrMsg, RecordEntity? Record)> GetGroupGenerateAiRecord(uint groupUin, string character, string text, uint chatType)
{
var groupAiRecordEvent = GroupAiRecordEvent.Create(groupUin, character, text, chattype);
var groupAiRecordEvent = GroupAiRecordEvent.Create(groupUin, character, text, chatType);
while (true)
{
var results = await Collection.Business.SendEvent(groupAiRecordEvent);
Expand Down
10 changes: 4 additions & 6 deletions Lagrange.Core/Internal/Event/Action/GroupAiRecordEvent.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Lagrange.Core.Internal.Packets.Service.Oidb.Common;
using Lagrange.Core.Message.Entity;

namespace Lagrange.Core.Internal.Event.Action;

Expand All @@ -14,14 +13,13 @@ internal class GroupAiRecordEvent : ProtocolEvent
public MsgInfo? RecordInfo { get; set; }
public string ErrorMessage { get; set; } = string.Empty;

private GroupAiRecordEvent(uint groupUin, string character, string text ,uint chattype) : base(0)
private GroupAiRecordEvent(uint groupUin, string character, string text, uint chatType) : base(0)
{
GroupUin = groupUin;
Character = character;
Text = text;
ChatType = chattype;
ChatType = chatType;
}

private GroupAiRecordEvent(int resultCode, MsgInfo? msgInfo) : base(resultCode)
{
RecordInfo = msgInfo;
Expand All @@ -32,8 +30,8 @@ private GroupAiRecordEvent(int resultCode, string errMsg) : base(resultCode)
ErrorMessage = errMsg;
}

public static GroupAiRecordEvent Create(uint groupUin, string character, string text , uint chattype) =>
new(groupUin, character, text , chattype);
public static GroupAiRecordEvent Create(uint groupUin, string character, string text, uint chatType) =>
new(groupUin, character, text, chatType);

public static GroupAiRecordEvent Result(int resultCode, MsgInfo? msgInfo) => new(resultCode, msgInfo);

Expand Down
10 changes: 7 additions & 3 deletions Lagrange.Core/Internal/Service/Action/GroupAiRecordService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
using Lagrange.Core.Internal.Event;
using Lagrange.Core.Internal.Event.Action;
using Lagrange.Core.Internal.Packets.Service.Oidb;
using Lagrange.Core.Internal.Packets.Service.Oidb.Common;
using Lagrange.Core.Internal.Packets.Service.Oidb.Request;
using Lagrange.Core.Internal.Packets.Service.Oidb.Response;
using Lagrange.Core.Message.Entity;
using Lagrange.Core.Utility.Extension;
using ProtoBuf;

Expand All @@ -20,7 +18,13 @@ protected override bool Build(GroupAiRecordEvent input, BotKeystore keystore, Bo
out List<Memory<byte>>? extraPackets)
{
var packet = new OidbSvcTrpcTcpBase<OidbSvcTrpcTcp0x929B_0>(
new OidbSvcTrpcTcp0x929B_0 { GroupCode = input.GroupUin, VoiceId = input.Character, Text = input.Text , ChatType = input.ChatType}
new OidbSvcTrpcTcp0x929B_0
{
GroupCode = input.GroupUin,
VoiceId = input.Character,
Text = input.Text,
ChatType = input.ChatType
}
);
output = packet.Serialize();
extraPackets = null;
Expand Down
1 change: 1 addition & 0 deletions Lagrange.OneBot/Core/Notify/NotifyService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public void RegisterEvents()
string type = @event.Type switch
{
GroupMemberDecreaseEvent.EventType.KickMe => "kick_me",
GroupMemberDecreaseEvent.EventType.Disband => "disband",
GroupMemberDecreaseEvent.EventType.Leave => "leave",
GroupMemberDecreaseEvent.EventType.Kick => "kick",
_ => @event.Type.ToString()
Expand Down
7 changes: 6 additions & 1 deletion Lagrange.OneBot/Core/Operation/Group/GetAiRecordOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ public async Task<OneBotResult> HandleOperation(BotContext context, JsonNode? pa
var message = payload.Deserialize<OneBotGetAiRecord>(SerializerOptions.DefaultOptions);
if (message != null)
{
var (code, errMsg, url) = await context.GetGroupGenerateAiRecordUrl(message.GroupId, message.Character, message.Text,message.ChatType);
var (code, errMsg, url) = await context.GetGroupGenerateAiRecordUrl(
message.GroupId,
message.Character,
message.Text,
message.ChatType
);
return code != 0 ? new OneBotResult(errMsg, code, "failed") : new OneBotResult(url, 0, "ok");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ public async Task<OneBotResult> HandleOperation(BotContext context, JsonNode? pa
var message = payload.Deserialize<OneBotGetAiRecord>(SerializerOptions.DefaultOptions);
if (message != null)
{
(int code, string errMsg, var recordEntity) = await context.GetGroupGenerateAiRecord(message.GroupId, message.Character, message.Text , message.ChatType);
(int code, string _, var recordEntity) = await context.GetGroupGenerateAiRecord(
message.GroupId,
message.Character,
message.Text,
message.ChatType
);
if (code != 0 || recordEntity == null) return new OneBotResult(null, code, "failed");


Expand Down

0 comments on commit 259d949

Please sign in to comment.