mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-19 13:37:31 +08:00
feishu sheets: auto-set public editable permission and clean table link text
This commit is contained in:
@@ -122,14 +122,20 @@ func (c *FeishuChannel) Send(ctx context.Context, msg bus.OutboundMessage) error
|
|||||||
var tables []feishuTableData
|
var tables []feishuTableData
|
||||||
if strings.TrimSpace(workMsg.Media) == "" {
|
if strings.TrimSpace(workMsg.Media) == "" {
|
||||||
workMsg.Content, tables = extractMarkdownTables(strings.TrimSpace(workMsg.Content))
|
workMsg.Content, tables = extractMarkdownTables(strings.TrimSpace(workMsg.Content))
|
||||||
|
links := make([]string, 0, len(tables))
|
||||||
for i, t := range tables {
|
for i, t := range tables {
|
||||||
link, lerr := c.createFeishuSheetFromTable(ctx, t.Name, t.Rows)
|
link, lerr := c.createFeishuSheetFromTable(ctx, t.Name, t.Rows)
|
||||||
ph := fmt.Sprintf("[Table %d converted: %s]", i+1, t.Name)
|
|
||||||
if lerr != nil {
|
if lerr != nil {
|
||||||
logger.WarnCF("feishu", "create sheet from markdown table failed", map[string]interface{}{logger.FieldError: lerr.Error(), logger.FieldChatID: msg.ChatID})
|
logger.WarnCF("feishu", "create sheet from markdown table failed", map[string]interface{}{logger.FieldError: lerr.Error(), logger.FieldChatID: msg.ChatID})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
workMsg.Content = strings.ReplaceAll(workMsg.Content, ph, fmt.Sprintf("[Table %d] %s", i+1, link))
|
links = append(links, fmt.Sprintf("表格%d: %s", i+1, link))
|
||||||
|
}
|
||||||
|
if len(links) > 0 {
|
||||||
|
if strings.TrimSpace(workMsg.Content) != "" {
|
||||||
|
workMsg.Content = strings.TrimSpace(workMsg.Content) + "\n\n"
|
||||||
|
}
|
||||||
|
workMsg.Content += strings.Join(links, "\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -664,7 +670,7 @@ func extractMarkdownTables(content string) (string, []feishuTableData) {
|
|||||||
tableIdx++
|
tableIdx++
|
||||||
name := fmt.Sprintf("table_%d", tableIdx)
|
name := fmt.Sprintf("table_%d", tableIdx)
|
||||||
tables = append(tables, feishuTableData{Name: name, Rows: rows})
|
tables = append(tables, feishuTableData{Name: name, Rows: rows})
|
||||||
out = append(out, fmt.Sprintf("[Table %d converted: %s]", tableIdx, name))
|
// keep message clean: do not inject table placeholder text
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user