Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PythonSDK支持直接返回一张本地图片的二进制而不是URL给机器人,GolangSDK支持吗 #36

Open
37Vision opened this issue Mar 12, 2023 · 1 comment
Labels

Comments

@37Vision
Copy link

找了很久没找到FileImage字段

@thesixonenine
Copy link

@37Vision
找了一圈没看到, 就写了个直接发HTTP请求的

func SendPicToDirectMsg(guildId string, qrContent []byte, data map[string]string) ([]byte, error) {
    resp, err := resty.New().R().SetContext(ctx).SetAuthScheme("Bot").
    SetAuthToken(strconv.FormatUint(botToken.AppID, 10)+"."+botToken.AccessToken).
    SetFormData(data).
    SetFileReader("file_image", "qrcode.png", bytes.NewReader(qrContent)).
    SetContentLength(true).
    SetResult(dto.Message{}).
    SetPathParam("guild_id", guildId).
    Post(fmt.Sprintf("%s://%s%s", "https", "api.sgroup.qq.com", "/dms/{guild_id}/messages"))
    if err != nil {
        return nil, err
    }
    return resp.Body(), nil
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants