-
Notifications
You must be signed in to change notification settings - Fork 1
/
get_guild_channel_list.go
72 lines (61 loc) · 2.26 KB
/
get_guild_channel_list.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
60
61
62
63
64
65
66
67
68
69
70
71
72
package handlers
type GuildChannelListResponse struct {
Data []interface{} `json:"data"`
Message string `json:"message"`
RetCode int `json:"retcode"`
Status string `json:"status"`
Echo interface{} `json:"echo"`
}
// func init() {
// callapi.RegisterHandler("get_guild_channel_list", GetGuildChannelList)
// }
// func GetGuildChannelList(client callapi.Client, Token string, BaseUrl string, message callapi.ActionMessage) (string, error) {
// var response GuildChannelListResponse
// // 解析请求参数
// guildID := message.Params.GuildID
// // 根据请求参数调用API
// channels, err := api.Channels(context.TODO(), guildID)
// if err != nil {
// // 如果发生错误,记录日志并返回null
// mylog.Printf("Error fetching channels: %v", err)
// client.SendMessage(map[string]interface{}{"data": nil})
// return "", nil
// }
// // 构建响应数据
// for _, channel := range channels {
// channelInfo := map[string]interface{}{
// "owner_guild_id": guildID,
// "channel_id": channel.ID,
// "channel_type": channel.Type,
// "channel_name": channel.Name,
// "create_time": 0, // Default value as actual value is not available
// "creator_tiny_id": channel.OwnerID,
// "talk_permission": channel.Permissions,
// "visible_type": channel.Position,
// "current_slow_mode": 0, // Default value as actual value is not available
// }
// // Append the channel information to the response data
// response.Data = append(response.Data, channelInfo)
// }
// // Set other fields of the response
// response.Message = ""
// response.RetCode = 0
// response.Status = "ok"
// response.Echo = message.Echo
// // Convert the response to a map for sending
// outputMap := structToMap(response)
// mylog.Printf("get_guild_channel_list: %s", outputMap)
// // Send the response
// err = client.SendMessage(outputMap)
// if err != nil {
// mylog.Printf("Error sending message via client: %v", err)
// }
// //把结果从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
// }