mirror of
https://github.com/larksuite/cli.git
synced 2026-09-14 18:42:53 +08:00
bb03c8ac4d
* feat: support vc agent active meetings
* docs: clarify vc agent active meeting flow
* fix: align active meeting shortcut scope
* docs: clarify active meeting id fields
* fix: reject meeting numbers for vc events
* docs: clarify vc agent active meeting flow
* docs: refine vc agent meeting flow guidance
* docs: address vc agent skill review feedback
* docs: clarify vc meeting product wording
* docs: align vc agent skill with quality guidelines
* docs: trim vc agent skill token budget
* Revert "docs: trim vc agent skill token budget"
This reverts commit 8560bb9c19.
100 lines
3.1 KiB
Go
100 lines
3.1 KiB
Go
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package vc
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"io"
|
|
"regexp"
|
|
"strings"
|
|
|
|
"github.com/larksuite/cli/errs"
|
|
"github.com/larksuite/cli/shortcuts/common"
|
|
)
|
|
|
|
var meetingNumberRe = regexp.MustCompile(`^\d{9}$`)
|
|
|
|
// validMeetingNumber checks whether s is a valid 9-digit meeting number.
|
|
func validMeetingNumber(s string) bool {
|
|
return meetingNumberRe.MatchString(s)
|
|
}
|
|
|
|
// VCMeetingJoin joins a meeting by meeting number via /vc/v1/bots/join.
|
|
var VCMeetingJoin = common.Shortcut{
|
|
Service: "vc",
|
|
Command: "+meeting-join",
|
|
Description: "Join a meeting by meeting number (bot join)",
|
|
Risk: "write",
|
|
Scopes: []string{"vc:meeting.bot.join:write"},
|
|
AuthTypes: []string{"user", "bot"},
|
|
HasFormat: true,
|
|
Flags: []common.Flag{
|
|
{Name: "meeting-number", Required: true, Desc: "meeting number to join"},
|
|
{Name: "password", Desc: "meeting password (if required)"},
|
|
{Name: "call-id", Desc: "correlation id forwarded from invite event"},
|
|
},
|
|
Validate: func(ctx context.Context, runtime *common.RuntimeContext) error {
|
|
mn := strings.TrimSpace(runtime.Str("meeting-number"))
|
|
if !validMeetingNumber(mn) {
|
|
return errs.NewValidationError(errs.SubtypeInvalidArgument, "--meeting-number must be exactly 9 digits, got %q", mn).WithParam("--meeting-number")
|
|
}
|
|
return nil
|
|
},
|
|
DryRun: func(ctx context.Context, runtime *common.RuntimeContext) *common.DryRunAPI {
|
|
body := buildMeetingJoinBody(runtime)
|
|
return common.NewDryRunAPI().
|
|
POST("/open-apis/vc/v1/bots/join").
|
|
Body(body)
|
|
},
|
|
Execute: func(ctx context.Context, runtime *common.RuntimeContext) error {
|
|
body := buildMeetingJoinBody(runtime)
|
|
data, err := runtime.CallAPITyped("POST", "/open-apis/vc/v1/bots/join", nil, body)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if data == nil {
|
|
data = map[string]interface{}{}
|
|
}
|
|
runtime.OutFormat(data, nil, func(w io.Writer) {
|
|
meeting, _ := data["meeting"].(map[string]interface{})
|
|
if meeting == nil {
|
|
fmt.Fprintln(w, "Joined meeting (no meeting info returned).")
|
|
return
|
|
}
|
|
fmt.Fprintf(w, "Joined meeting successfully.\n")
|
|
if id := common.GetString(meeting, "id"); id != "" {
|
|
fmt.Fprintf(w, " Meeting ID: %s\n", id)
|
|
}
|
|
if no := common.GetString(meeting, "meeting_no"); no != "" {
|
|
fmt.Fprintf(w, " Meeting No: %s\n", no)
|
|
}
|
|
if topic := common.GetString(meeting, "topic"); topic != "" {
|
|
fmt.Fprintf(w, " Topic: %s\n", topic)
|
|
}
|
|
if startTime := common.GetString(meeting, "start_time"); startTime != "" {
|
|
fmt.Fprintf(w, " Start Time: %s\n", startTime)
|
|
}
|
|
})
|
|
return nil
|
|
},
|
|
}
|
|
|
|
func buildMeetingJoinBody(runtime *common.RuntimeContext) map[string]interface{} {
|
|
meetingNo := strings.TrimSpace(runtime.Str("meeting-number"))
|
|
body := map[string]interface{}{
|
|
"join_type": 1,
|
|
"join_identify": map[string]interface{}{
|
|
"meeting_no": meetingNo,
|
|
},
|
|
}
|
|
if pw := strings.TrimSpace(runtime.Str("password")); pw != "" {
|
|
body["password"] = pw
|
|
}
|
|
if cid := strings.TrimSpace(runtime.Str("call-id")); cid != "" {
|
|
body["call_id"] = cid
|
|
}
|
|
return body
|
|
}
|