返回 DeepSeek-Reasonix
keyboard.go
根目录 / internal / bot / qq / keyboard.go
1 package qq
2
3 import (
4 "strings"
5
6 "reasonix/internal/bot"
7 )
8
9 func qqKeyboardContent(keyboard *bot.InlineKeyboard, chatType bot.ChatType) map[string]any {
10 rows := make([]map[string]any, 0, len(keyboard.Rows))
11 for _, row := range keyboard.Rows {
12 buttons := make([]map[string]any, 0, len(row.Buttons))
13 for _, btn := range row.Buttons {
14 style := btn.Style
15 if style == 2 {
16 style = 3
17 }
18 buttons = append(buttons, map[string]any{
19 "id": strings.TrimSpace(btn.ID),
20 "render_data": map[string]any{
21 "label": btn.Label,
22 "style": style,
23 },
24 "action": map[string]any{
25 "type": 2,
26 "data": btn.CallbackID,
27 "permission": map[string]int{"type": 2},
28 "enter": chatType == bot.ChatDM,
29 },
30 })
31 }
32 rows = append(rows, map[string]any{"buttons": buttons})
33 }
34 return map[string]any{"content": map[string]any{"rows": rows}}
35 }
36
36 lines GO