MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / formatMessageCompact

Function formatMessageCompact

packages/tools/src/utils/format.ts:45–61  ·  view source on GitHub ↗
(
  msg: {
    id?: number
    senderName: string
    content: string | null
    timestamp: number
  },
  locale?: string
)

Source from the content-addressed store, hash-verified

43}
44
45export function formatMessageCompact(
46 msg: {
47 id?: number
48 senderName: string
49 content: string | null
50 timestamp: number
51 },
52 locale?: string
53): string {
54 const localeStr = isChineseLocale(locale) ? 'zh-CN' : 'en-US'
55 const time = new Date(msg.timestamp * 1000).toLocaleString(localeStr)
56 let content = msg.content || t('noContent', locale)
57 if (content.length > 200) {
58 content = content.slice(0, 200) + '...'
59 }
60 return `${time} ${msg.senderName}: ${content}`
61}

Callers

nothing calls this directly

Calls 2

isChineseLocaleFunction · 0.70
tFunction · 0.70

Tested by

no test coverage detected