Code Monkey home page Code Monkey logo

Comments (6)

Executor-Cheng avatar Executor-Cheng commented on August 18, 2024

/about接口返回的信息有所变动。
原响应为

{
    "code": 0,
    "errorMessage": "",
    "data": {
        "version": "v1.0.0"
    }
}

新的响应为

{
    "data": {
        "version": "1.8.4"
    }
}

int code = root.GetProperty("code").GetInt32();

本行按照以前的规范会固定获取$.code属性判断api返回是否正常, 由于新版返回没有这个$.code, 所以抛了个System.Collections.Generic.KeyNotFoundException
如果mirai-api-httpv1.9.0正式发布时此接口返回未更改的话, 我就会修掉它。

from mirai-csharp.

Executor-Cheng avatar Executor-Cheng commented on August 18, 2024

补充一句, 你也可以自己先行改下本项目源码, 修改MiraiHttpSession.GetVersionAsync(HttpClient, MiraiHttpSessionOptions)方法如下:

public static async Task<Version> GetVersionAsync(HttpClient client, MiraiHttpSessionOptions options)
{
    using JsonDocument j = await client.GetAsync($"{options.BaseUrl}/about").GetJsonAsync();
    JsonElement root = j.RootElement;
    if (!root.TryGetProperty("code", out JsonElement codeToken) || codeToken.GetInt32() == 0)
    {
        string version = root.GetProperty("data").GetProperty("version").GetString()!;
        int vIndex = version.IndexOf('v');
#if NETSTANDARD2_0
        return Version.Parse(vIndex > 0 ? version.Substring(vIndex) : version); // v1.0.0 ~ v1.7.2, skip 'v'
#else
        return Version.Parse(vIndex > 0 ? version[vIndex..] : version); // v1.0.0 ~ v1.7.2, skip 'v'
#endif
    }
    throw GetCommonException(codeToken.GetInt32(), in root);
}

from mirai-csharp.

s158298261 avatar s158298261 commented on August 18, 2024

好的,非常感谢!

from mirai-csharp.

Executor-Cheng avatar Executor-Cheng commented on August 18, 2024

好的,非常感谢!

@s158298261 我发现这个code缺键的地方不止一处了, 建议你使用一下release/v1.0.2.2分支来重新build本项目

from mirai-csharp.

ryuujo1573 avatar ryuujo1573 commented on August 18, 2024

这个部分是否已经修复?我在使用1.10.0版本的http api,没有遇到以上问题

from mirai-csharp.

Executor-Cheng avatar Executor-Cheng commented on August 18, 2024

这个部分是否已经修复?我在使用1.10.0版本的http api,没有遇到以上问题

已经修复, 版本更新后统一close

from mirai-csharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.