830f8a4011
Memind CI / Test, build, and release guards (push) Successful in 5m36s
Ship the 10-item numeric subscription loop on WeChat MP, wire schedule delivery for news/weather/quote/health/finance/tech/knowledge/night/surprise pushes, and extend news morning draft cover generation plus a one-shot draft push script. Co-authored-by: Cursor <cursoragent@cursor.com>
104 lines
3.4 KiB
JavaScript
104 lines
3.4 KiB
JavaScript
import { hashString } from './push-content/daily-library-pick.mjs';
|
|
import { localDateKey, normalizeTimezone } from '../schedule-time.mjs';
|
|
import {
|
|
extractKnowledgeItemsFromHtml,
|
|
loadTodayNewsMorningHtml,
|
|
} from './push-content/news-section-extract.mjs';
|
|
|
|
export const DAILY_KNOWLEDGE_LIBRARY = Object.freeze([
|
|
{
|
|
title: '复利效应',
|
|
body: '每天进步 1%,一年后会变成原来的 37 倍;每天退步 1%,则会接近归零。关键在持续,而非一次爆发。',
|
|
},
|
|
{
|
|
title: '机会成本',
|
|
body: '每个选择都意味着放弃其它可能。做决策时,除了问「能得到什么」,也要问「因此放弃了什么」。',
|
|
},
|
|
{
|
|
title: '墨菲定律',
|
|
body: '可能出错的事,迟早会出错。重要事项要多留备份、多留时间余量,而不是赌运气。',
|
|
},
|
|
{
|
|
title: '帕累托法则',
|
|
body: '约 20% 的因素,往往带来 80% 的结果。把精力优先放在高杠杆事项上,效率会明显提升。',
|
|
},
|
|
{
|
|
title: '锚定效应',
|
|
body: '人容易被第一个信息「锚住」。看价格、看评价、看谈判条件时,先问:这个起点是否被故意设计?',
|
|
},
|
|
{
|
|
title: '沉没成本',
|
|
body: '已经付出的成本不应影响未来决策。该止损时止损,才能把资源留给更值得的方向。',
|
|
},
|
|
{
|
|
title: '峰终定律',
|
|
body: '人对体验的记忆,主要由「高峰」和「结束」决定。做产品、做服务、做沟通,收尾同样重要。',
|
|
},
|
|
{
|
|
title: '第一性原理',
|
|
body: '回到问题本质,从基本事实重新推导,而不是类比「别人怎么做」。创新常从这里开始。',
|
|
},
|
|
{
|
|
title: '延迟满足',
|
|
body: '短期诱惑与长期收益冲突时,能等待的人更容易积累优势。把目标拆小,会更容易坚持。',
|
|
},
|
|
{
|
|
title: '系统思维',
|
|
body: '很多问题不是单点故障,而是系统结构的结果。改结构,往往比反复补漏洞更有效。',
|
|
},
|
|
]);
|
|
|
|
export function pickDailyKnowledgeFromLibrary({
|
|
userId = '',
|
|
timezone = 'Asia/Shanghai',
|
|
now = Date.now(),
|
|
} = {}) {
|
|
const tz = normalizeTimezone(timezone);
|
|
const dateKey = localDateKey(now, tz);
|
|
const idx = hashString(`${String(userId)}:${dateKey}:knowledge`)
|
|
% DAILY_KNOWLEDGE_LIBRARY.length;
|
|
return DAILY_KNOWLEDGE_LIBRARY[idx];
|
|
}
|
|
|
|
export function formatDailyKnowledgeDeliveryText({
|
|
userId,
|
|
timezone = 'Asia/Shanghai',
|
|
now = Date.now(),
|
|
item = null,
|
|
} = {}) {
|
|
const knowledge = item ?? pickDailyKnowledgeFromLibrary({ userId, timezone, now });
|
|
return [
|
|
'📚 每日知识',
|
|
'',
|
|
`【${knowledge.title}】`,
|
|
knowledge.body,
|
|
'',
|
|
'回复「取消6」关闭推送',
|
|
].join('\n');
|
|
}
|
|
|
|
export async function formatKnowledgePushDelivery(options = {}) {
|
|
const { html } = await loadTodayNewsMorningHtml(options);
|
|
const items = html ? extractKnowledgeItemsFromHtml(html) : [];
|
|
if (items.length > 0) {
|
|
const picked = items[0];
|
|
return {
|
|
text: formatDailyKnowledgeDeliveryText({
|
|
userId: options.userId,
|
|
timezone: options.timezone,
|
|
now: options.now,
|
|
item: { title: picked.title, body: picked.body || '今日知识速递,详见新闻早报知识栏。' },
|
|
}),
|
|
verifiedHtmlUrls: [],
|
|
};
|
|
}
|
|
return {
|
|
text: formatDailyKnowledgeDeliveryText({
|
|
userId: options.userId,
|
|
timezone: options.timezone,
|
|
now: options.now,
|
|
}),
|
|
verifiedHtmlUrls: [],
|
|
};
|
|
}
|