update basic frame
This commit is contained in:
+5
-2
@@ -28,5 +28,8 @@ go.work.sum
|
||||
.env
|
||||
|
||||
# Editor/IDE
|
||||
# .idea/
|
||||
# .vscode/
|
||||
.idea/
|
||||
.vscode/
|
||||
.opencode/
|
||||
|
||||
docs/superpowers/
|
||||
@@ -0,0 +1,7 @@
|
||||
# AGENTS.md
|
||||
|
||||
## Safety Rules
|
||||
- **Branch safety**: If the current branch is NOT a dev branch (name does NOT contain `feat`, `refactor`, `docs`, `fix`), do NOT commit directly — warn the user first.
|
||||
- **Commit SOP**: Before every `git commit`, run `git branch --show-current`. If the branch is not a dev branch, ask the user for a branch name, create it, and commit there.
|
||||
- **Branch naming**: Dev branches must contain `feat`, `refactor`, `docs`, or `fix`.
|
||||
- **CHANGELOG**: Core changes → `docs/CHANGELOG.md` only. Higher versions on TOP, lower versions below.
|
||||
@@ -1,2 +0,0 @@
|
||||
# rainyun_api_go_sdk
|
||||
An Easy sdk for rainyun(雨云) api callings
|
||||
@@ -0,0 +1,56 @@
|
||||
package apis
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/constant"
|
||||
"github.com/bytedance/sonic"
|
||||
"github.com/go-resty/resty/v2"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
APIKey string
|
||||
client *resty.Client
|
||||
}
|
||||
|
||||
func New(apiKey string) *Client {
|
||||
c := resty.New()
|
||||
c.SetBaseURL(constant.BaseURL)
|
||||
c.SetHeader("x-api-key", apiKey)
|
||||
c.SetHeader("User-Agent", "github.com/XingfenD/rainyun_api_go_sdk/"+constant.RainyunSdkVersion)
|
||||
c.SetHeader("Accept", "application/json")
|
||||
|
||||
return &Client{
|
||||
APIKey: apiKey,
|
||||
client: c,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) Do(method constant.HTTPMethod, endpoint string, body, result any) error {
|
||||
req := c.client.R()
|
||||
if body != nil {
|
||||
req.SetBody(body)
|
||||
}
|
||||
|
||||
if result != nil {
|
||||
req.SetResult(result)
|
||||
}
|
||||
resp, err := req.Execute(string(method), endpoint)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if resp.StatusCode() != 200 {
|
||||
var baseResp struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
if err := sonic.Unmarshal(resp.Body(), &baseResp); err != nil {
|
||||
return err
|
||||
}
|
||||
return fmt.Errorf(fmt.Sprint(baseResp.Code))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package public
|
||||
|
||||
import "github.com/XingfenD/rainyun_api_go_sdk/apis"
|
||||
|
||||
type Service struct {
|
||||
client *apis.Client
|
||||
}
|
||||
|
||||
func NewService(c *apis.Client) *Service {
|
||||
return &Service{client: c}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package public
|
||||
|
||||
import "github.com/XingfenD/rainyun_api_go_sdk/constant"
|
||||
|
||||
type AppConfigItemResponse struct {
|
||||
Code int `json:"code"`
|
||||
Data []AppConfigItem `json:"data"`
|
||||
Messages []string `json:"messages,omitempty"`
|
||||
Msg string `json:"msg,omitempty"`
|
||||
}
|
||||
|
||||
type AppConfigItem struct {
|
||||
AgentID int `json:"agent_id"`
|
||||
Type string `json:"type"`
|
||||
Value []AppConfigValue `json:"value"`
|
||||
}
|
||||
|
||||
type AppConfigValue struct {
|
||||
SenderID int `json:"sender_id"`
|
||||
Content string `json:"content"`
|
||||
Title string `json:"title"`
|
||||
Name string `json:"name"`
|
||||
Order int `json:"order"`
|
||||
Page string `json:"page"`
|
||||
VgtID int `json:"vgt_id"`
|
||||
OriginalIndex int `json:"originalIndex"`
|
||||
}
|
||||
|
||||
func (s *Service) GetAppConfig() (*AppConfigItemResponse, error) {
|
||||
path := "/app_config"
|
||||
var resp AppConfigItemResponse
|
||||
err := s.client.Do(constant.HTTPMethod_GET, path, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
package public
|
||||
@@ -0,0 +1,10 @@
|
||||
package constant
|
||||
|
||||
const (
|
||||
TBPass = "关注成功"
|
||||
BiliPass = "雨云爱你"
|
||||
QQPass = "我爱雨云"
|
||||
ZZY = "关注雨云谢谢喵"
|
||||
)
|
||||
|
||||
const BaseURL = "https://api.v2.rainyun.com/"
|
||||
@@ -0,0 +1,10 @@
|
||||
package constant
|
||||
|
||||
type HTTPMethod string
|
||||
|
||||
const (
|
||||
HTTPMethod_GET HTTPMethod = "GET"
|
||||
HTTPMethod_POST HTTPMethod = "POST"
|
||||
HTTPMethod_DELETE HTTPMethod = "DELETE"
|
||||
HTTPMethod_PUT HTTPMethod = "PUT"
|
||||
)
|
||||
@@ -0,0 +1,5 @@
|
||||
package constant
|
||||
|
||||
const APIDocVersion = "2.4"
|
||||
|
||||
const RainyunSdkVersion = "0.0.0"
|
||||
@@ -0,0 +1,17 @@
|
||||
# Changelog / 更新日志
|
||||
|
||||
All notable changes to this template should be documented in this file.
|
||||
本模板的重要变更建议统一记录在此文件中。
|
||||
|
||||
The format loosely follows Keep a Changelog and can be adapted to the team's habits.
|
||||
本文档参考了 Keep a Changelog 的思路,也可以根据团队习惯调整。
|
||||
|
||||
## [0.0.0] - 2026-08-02
|
||||
|
||||
### Notes / 说明
|
||||
|
||||
- The repository currently provides structure and placeholder files rather than a finished implementation.
|
||||
- 当前仓库主要提供目录结构和占位文件,尚不是一个已完成功能实现的成品项目。
|
||||
|
||||
- Future updates should record framework selection, startup steps, deployment workflow, and major documentation changes.
|
||||
- 后续若补充了技术栈、启动流程、部署方式或重要文档内容,建议继续记录在本文件中。
|
||||
@@ -0,0 +1,5 @@
|
||||

|
||||
|
||||
# rainyun_api_go_sdk
|
||||
|
||||
An Easy sdk for rainyun(雨云) api callings
|
||||
@@ -0,0 +1,16 @@
|
||||
module github.com/XingfenD/rainyun_api_go_sdk
|
||||
|
||||
go 1.24.1
|
||||
|
||||
require (
|
||||
github.com/bytedance/gopkg v0.1.3 // indirect
|
||||
github.com/bytedance/sonic v1.15.2 // indirect
|
||||
github.com/bytedance/sonic/loader v0.5.1 // indirect
|
||||
github.com/cloudwego/base64x v0.1.6 // indirect
|
||||
github.com/go-resty/resty/v2 v2.17.2 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
|
||||
golang.org/x/net v0.43.0 // indirect
|
||||
golang.org/x/sys v0.35.0 // indirect
|
||||
)
|
||||
@@ -0,0 +1,35 @@
|
||||
github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M=
|
||||
github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM=
|
||||
github.com/bytedance/sonic v1.15.2 h1:90H+rcF/FwLXwfB1cudOLq/je83n683Utf4Cbp0xHCo=
|
||||
github.com/bytedance/sonic v1.15.2/go.mod h1:mT2NbXunuaEbnZ+mRIX/vYqKISmgEuHFDI4UzmKx2SA=
|
||||
github.com/bytedance/sonic/loader v0.5.1 h1:Ygpfa9zwRCCKSlrp5bBP/b/Xzc3VxsAW+5NIYXrOOpI=
|
||||
github.com/bytedance/sonic/loader v0.5.1/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo=
|
||||
github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M=
|
||||
github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/go-resty/resty/v2 v2.17.2 h1:FQW5oHYcIlkCNrMD2lloGScxcHJ0gkjshV3qcQAyHQk=
|
||||
github.com/go-resty/resty/v2 v2.17.2/go.mod h1:kCKZ3wWmwJaNc7S29BRtUhJwy7iqmn+2mLtQrOyQlVA=
|
||||
github.com/klauspost/cpuid/v2 v2.2.9 h1:66ze0taIn2H33fBvCkXuv9BmCwDfafmiIVpKV9kKGuY=
|
||||
github.com/klauspost/cpuid/v2 v2.2.9/go.mod h1:rqkxqrZ1EhYM9G+hXH7YdowN5R5RGN6NK4QwQ3WMXF8=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 h1:18EFjUmQOcUvxNYSkA6jO9VAiXCnxFY6NyDX0bHDmkU=
|
||||
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
||||
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
|
||||
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
|
||||
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
|
||||
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
@@ -0,0 +1 @@
|
||||
package sdk
|
||||
Reference in New Issue
Block a user