Skip to content

Commit

Permalink
[OneBot] Fixed retCode for Operations
Browse files Browse the repository at this point in the history
  • Loading branch information
Linwenxuan authored and Linwenxuan committed Feb 14, 2024
1 parent bf0b93b commit 59fb29e
Show file tree
Hide file tree
Showing 16 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public async Task<OneBotResult> HandleOperation(BotContext context, JsonObject?
if (message != null)
{
bool _ = await context.SetGroupAdmin(message.GroupId, message.UserId, message.Enable);
return new OneBotResult(null, 0, "ok");
return new OneBotResult(null, 200, "ok");
}

throw new Exception();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public async Task<OneBotResult> HandleOperation(BotContext context, JsonObject?
if (message != null)
{
bool _ = await context.MuteGroupMember(message.GroupId, message.UserId, message.Duration);
return new OneBotResult(null, 0, "ok");
return new OneBotResult(null, 200, "ok");
}

throw new Exception();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public async Task<OneBotResult> HandleOperation(BotContext context, JsonObject?
if (message != null)
{
bool _ = await context.RenameGroupMember(message.GroupId, message.UserId, message.Card);
return new OneBotResult(null, 0, "ok");
return new OneBotResult(null, 200, "ok");
}

throw new Exception();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public async Task<OneBotResult> HandleOperation(BotContext context, JsonObject?
if (message != null)
{
bool _ = await context.KickGroupMember(message.GroupId, message.UserId, message.RejectAddRequest);
return new OneBotResult(null, 0, "ok");
return new OneBotResult(null, 200, "ok");
}

throw new Exception();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public async Task<OneBotResult> HandleOperation(BotContext context, JsonObject?
if (message != null)
{
bool _ = await context.LeaveGroup(message.GroupId); // TODO: Figure out is_dismiss
return new OneBotResult(null, 0, "ok");
return new OneBotResult(null, 200, "ok");
}

throw new Exception();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public async Task<OneBotResult> HandleOperation(BotContext context, JsonObject?
if (message != null)
{
bool _ = await context.RenameGroup(message.GroupId, message.GroupName);
return new OneBotResult(null, 0, "ok");
return new OneBotResult(null, 200, "ok");
}

throw new Exception();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public async Task<OneBotResult> HandleOperation(BotContext context, JsonObject?
if (message != null)
{
bool _ = await context.MuteGroupGlobal(message.GroupId, message.Enable);
return new OneBotResult(null, 0, "ok");
return new OneBotResult(null, 200, "ok");
}

throw new Exception();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public async Task<OneBotResult> HandleOperation(BotContext context, JsonObject?

return result == null
? new OneBotResult(null, -1, "failed")
: new OneBotResult(new OneBotGroup(result.GroupUin, result.GroupName), 0, "ok");
: new OneBotResult(new OneBotGroup(result.GroupUin, result.GroupName), 200, "ok");
}

throw new Exception();
Expand Down
4 changes: 2 additions & 2 deletions Lagrange.OneBot/Core/Operation/Info/GetGroupListOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public async Task<OneBotResult> HandleOperation(BotContext context, JsonObject?
if (payload.Deserialize<OneBotGetGroupInfo>() is { } message)
{
var result = await context.FetchGroups(message.NoCache);
return new OneBotResult(result.Select(x => new OneBotGroup(x.GroupUin, x.GroupName)), 0, "ok");
return new OneBotResult(result.Select(x => new OneBotGroup(x.GroupUin, x.GroupName)), 200, "ok");
}
else
{
var result = await context.FetchGroups();
return new OneBotResult(result.Select(x => new OneBotGroup(x.GroupUin, x.GroupName)), 0, "ok");
return new OneBotResult(result.Select(x => new OneBotGroup(x.GroupUin, x.GroupName)), 200, "ok");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public async Task<OneBotResult> HandleOperation(BotContext context, JsonObject?
if (payload.Deserialize<OneBotGetGroupMemberInfo>() is { } message)
{
var result = await context.FetchMembers(message.GroupId, message.NoCache);
return new OneBotResult(result.Select(x => new OneBotGroupMember(message.GroupId, x.Uin, x.Permission.ToString().ToLower(), x.GroupLevel.ToString(), x.MemberCard, x.MemberName, (uint)new DateTimeOffset(x.JoinTime).ToUnixTimeSeconds(), (uint)new DateTimeOffset(x.LastMsgTime).ToUnixTimeSeconds())), 0, "ok");
return new OneBotResult(result.Select(x => new OneBotGroupMember(message.GroupId, x.Uin, x.Permission.ToString().ToLower(), x.GroupLevel.ToString(), x.MemberCard, x.MemberName, (uint)new DateTimeOffset(x.JoinTime).ToUnixTimeSeconds(), (uint)new DateTimeOffset(x.LastMsgTime).ToUnixTimeSeconds())), 200, "ok");
}

throw new Exception();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public Task<OneBotResult> HandleOperation(BotContext context, JsonObject? payloa
{
var keystore = context.ContextCollection.Keystore;
var result = new OneBotLoginInfoResponse(keystore.Uin, keystore.Info?.Name ?? "");
return Task.FromResult(new OneBotResult(result, 0, "ok"));
return Task.FromResult(new OneBotResult(result, 200, "ok"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public Task<OneBotResult> HandleOperation(BotContext context, JsonObject? payloa
var appInfo = context.ContextCollection.AppInfo;
string version = $"{appInfo.Os} | {appInfo.CurrentVersion}";

return Task.FromResult(new OneBotResult(new OneBotVersionInfoResponse(version), 0, "ok"));
return Task.FromResult(new OneBotResult(new OneBotVersionInfoResponse(version), 200, "ok"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public async Task<OneBotResult> HandleOperation(BotContext context, JsonObject?
nodes.Add(new OneBotSegment("node", node));
}

return new OneBotResult(new OneBotGetForwardMsgResponse(nodes), 0, "ok");
return new OneBotResult(new OneBotGetForwardMsgResponse(nodes), 200, "ok");
}

throw new Exception();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ public async Task<OneBotResult> HandleOperation(BotContext context, JsonObject?
_ => throw new Exception()
};

return new OneBotResult(new OneBotMessageResponse(0), 0, "ok");
return new OneBotResult(new OneBotMessageResponse(0), 200, "ok");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ public async Task<OneBotResult> HandleOperation(BotContext context, JsonObject?
_ => throw new Exception()
};

return new OneBotResult(new OneBotMessageResponse(0), 0, "ok");
return new OneBotResult(new OneBotMessageResponse(0), 200, "ok");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ public async Task<OneBotResult> HandleOperation(BotContext context, JsonObject?
_ => throw new Exception()
};

return new OneBotResult(new OneBotMessageResponse(0), 0, "ok");
return new OneBotResult(new OneBotMessageResponse(0), 200, "ok");
}
}

0 comments on commit 59fb29e

Please sign in to comment.