-
Notifications
You must be signed in to change notification settings - Fork 1
/
get_guild_service_profile.go
59 lines (48 loc) · 1.52 KB
/
get_guild_service_profile.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package handlers
import (
"encoding/json"
"github.com/hoshinonyaruko/gensokyo-kook/callapi"
"github.com/hoshinonyaruko/gensokyo-kook/mylog"
)
type GuildServiceProfileResponse struct {
Data GuildServiceProfileData `json:"data"`
Message string `json:"message"`
RetCode int `json:"retcode"`
Status string `json:"status"`
Echo interface{} `json:"echo"`
}
type GuildServiceProfileData struct {
Nickname string `json:"nickname"`
TinyID int64 `json:"tiny_id"`
}
func init() {
callapi.RegisterHandler("get_guild_service_profile", GetGuildServiceProfile)
}
func GetGuildServiceProfile(client callapi.Client, Token string, BaseUrl string, message callapi.ActionMessage) (string, error) {
var response GuildServiceProfileResponse
response.Data = GuildServiceProfileData{
Nickname: "",
TinyID: 0,
}
response.Message = ""
response.RetCode = 0
response.Status = "ok"
response.Echo = message.Echo
// Convert the members slice to a map
outputMap := structToMap(response)
mylog.Printf("get_guild_service_profile: %+v/n", outputMap)
err := client.SendMessage(outputMap)
if err != nil {
mylog.Printf("Error sending message via client: %v", err)
} else {
mylog.Printf("响应get_guild_service_profile: %+v", outputMap)
}
//把结果从struct转换为json
result, err := json.Marshal(response)
if err != nil {
mylog.Printf("Error marshaling data: %v", err)
//todo 符合onebotv11 ws返回的错误码
return "", nil
}
return string(result), nil
}