Skill: jiajiaoy/daily-idiom (version 1.0.3)

--- name: daily-idiom description: "Daily Chinese idiom (成语) — origin story, meaning, usage examples, and memory tip. Build Chinese vocabulary and cultural knowledge one 成语 per day." keywords: - 成语 - 每日成语 - 今日成语 - 成语故事 - 俗语 - 歇后语 - 谚语 - 学成语 - 成语打卡 - 中文学习 - 汉语成语 - 四字成语 - 成语典故 - 成语用法 - 成语造句 - 文化成语 - 历史成语 - Chinese idiom - chengyu - idiom of the day - learn Chinese - daily chengyu - Chinese culture - idiom story - Chinese proverb - Mandarin learning - Chinese language - 成语接龙 metadata: openclaw: runtime: node: ">=18" --- # 每日成语 > 每日成语 — 典故故事 · 用法例句 · 测验打卡 · 中文文化输出 ## 何时使用 - 用户说"成语""今日成语""成语故事" - 用户学习中文或想了解中国文化 - 用户说"idiom""chengyu""learn Chinese" - 用户说"成语接龙""猜成语""成语测验" --- ## 推送管理 ```bash node scripts/push-toggle.js on <userId> node scripts/push-toggle.js on <userId> --morning 08:00 --evening 21:00 --channel feishu node scripts/push-toggle.js off <userId> node scripts/push-toggle.js status <userId> ``` 支持渠道：`telegram` / `feishu` / `slack` / `discord`

path: README.md
content: # Daily Idiom — Chinese Idiom Learning Skill

> One Chinese idiom (成语) every day — story, usage, examples, quiz. Perfect for Chinese learners.

[![clawhub](https://img.shields.io/badge/clawhub-daily--idiom-blue)](https://clawhub.ai/skills/daily-idiom)
[![openclaw](https://img.shields.io/badge/openclaw-skill-orange)](https://openclaw.ai)

An [OpenClaw](https://openclaw.ai) skill for learning one Chinese idiom (成语) or proverb every day — with origin story, modern usage, example sentences, and an evening quiz. Perfect for Chinese learners, culture enthusiasts, and anyone who wants to level up their Mandarin.

---

## Features

- **Daily Idiom** — One 成语/俗语/谚语 per day, theme-based by weekday
- **Origin Story** — Historical/literary background (50–80 words)
- **Bilingual** — Chinese original + English translation (meaning, not literal)
- **Usage Guide** — When and how to use it in modern context
- **Example Sentences** — 2 sentences with translations
- **Memory Tip** — Mnemonic or word-root breakdown
- **Evening Quiz** — 3-question review with answers and explanations

---

## Daily Push Schedule

| Push | Time | Content |
|------|------|---------|
| Morning | 08:00 | Today's idiom + story + usage + quiz teaser |
| Evening | 21:00 | Quiz on today's idiom + tomorrow's preview hint |

```bash
node scripts/push-toggle.js on <userId>
node scripts/push-toggle.js on <userId> --morning 08:00 --evening 21:00 --channel feishu
node scripts/push-toggle.js off <userId>
node scripts/push-toggle.js status <userId>
```

Supported channels: `telegram` / `feishu` / `slack` / `discord`

---

## Weekly Themes

| Day | Theme |
|-----|-------|
| Mon | 励志 Motivation |
| Tue | 智慧 Wisdom |
| Wed | 友情 Friendship |
| Thu | 财富 Wealth |
| Fri | 趣味 Fun |
| Sat | 历史 History |
| Sun | 生活 Daily Life |

---

*MIT License · OpenClaw Skill*

## Keywords

Chinese idiom · chengyu · 成语 · daily idiom · Chinese learning · learn Chinese · Chinese proverb · 每日成语 · 成语故事 · 俗语 · 中文学习 · idiom of the day

---

Built for [OpenClaw](https://openclaw.ai) · Published on [clawhub.ai](https://clawhub.ai/skills/daily-idiom)


path: _meta.json
content: {
  "slug": "daily-idiom",
  "version": "1.0.0",
  "runtime": {
    "node": ">=18"
  },
  "ownerId": "kn79bebfnwg15sb0g7cj5z5nyd83gxh0"
}

path: package.json
content: {
  "name": "daily-idiom",
  "version": "1.0.2",
  "description": "Daily Chinese idiom (成语) — origin story, meaning, usage examples, and memory tip. Build Chinese vocabulary and cultural knowledge one 成语 per day.",
  "engines": {
    "node": ">=18"
  },
  "license": "MIT"
}

path: scripts/evening-push.js
content: #!/usr/bin/env node
'use strict';
const fs=require('fs'),path=require('path');
const USERS_DIR=path.join(__dirname,'../data/users');
function sanitizeId(v){if(typeof v!=='string'||!/^[a-zA-Z0-9_-]{1,128}$/.test(v)){console.error('invalid userId');process.exit(1);}return v;}
function safeUserPath(u){const r=path.resolve(USERS_DIR,u+'.json');if(!r.startsWith(path.resolve(USERS_DIR)+path.sep)){console.error('illegal path');process.exit(1);}return r;}
function loadUser(u){const f=safeUserPath(u);return fs.existsSync(f)?JSON.parse(fs.readFileSync(f,'utf8')):{};}
const userId=sanitizeId(process.argv[2]||'default');
loadUser(userId);
const now=new Date();
const WEEKDAYS=['星期日','星期一','星期二','星期三','星期四','星期五','星期六'];
const wd=now.getDay();
const date=`${now.getFullYear()}-${String(now.getMonth()+1).padStart(2,'0')}-${String(now.getDate()).padStart(2,'0')}`;
const weekday=WEEKDAYS[wd];
const month=now.getMonth()+1;
const day=now.getDate();
const tomorrow_weekday=WEEKDAYS[(wd+1)%7];
console.log(`成语晚间复习🏮今天是${date}。请回顾今日成语，出3道复习题：①释义选择（4选1）②填空造句③情景应用判断。给出答案与详解。预告明日成语主题，给出一个悬念提示（不揭晓答案）。轻松有趣，适合睡前温习。`);


path: scripts/morning-push.js
content: #!/usr/bin/env node
'use strict';
const fs=require('fs'),path=require('path');
const USERS_DIR=path.join(__dirname,'../data/users');
function sanitizeId(v){if(typeof v!=='string'||!/^[a-zA-Z0-9_-]{1,128}$/.test(v)){console.error('invalid userId');process.exit(1);}return v;}
function safeUserPath(u){const r=path.resolve(USERS_DIR,u+'.json');if(!r.startsWith(path.resolve(USERS_DIR)+path.sep)){console.error('illegal path');process.exit(1);}return r;}
function loadUser(u){const f=safeUserPath(u);return fs.existsSync(f)?JSON.parse(fs.readFileSync(f,'utf8')):{};}
const userId=sanitizeId(process.argv[2]||'default');
loadUser(userId);
const now=new Date();
const WEEKDAYS=['星期日','星期一','星期二','星期三','星期四','星期五','星期六'];
const wd=now.getDay();
const date=`${now.getFullYear()}-${String(now.getMonth()+1).padStart(2,'0')}-${String(now.getDate()).padStart(2,'0')}`;
const weekday=WEEKDAYS[wd];
const month=now.getMonth()+1;
const day=now.getDate();
const tomorrow_weekday=WEEKDAYS[(wd+1)%7];
console.log(`早安！今天是${weekday}（${date}）。请选一个有趣实用的中文成语或俗语（主题轮换：周一励志/周二智慧/周三友情/周四财富/周五趣味/周六历史/周日生活），呈现：①成语原文（大字）+拼音②英文意译③出处典故（50-80字）④现代用法（1-2句）⑤中文例句×2（含翻译）⑥近义词1个+反义词1个⑦记忆口诀。结尾出1道选择题，答案晚间揭晓。`);


path: scripts/push-toggle.js
content: #!/usr/bin/env node
'use strict';
const fs=require('fs'),path=require('path');
const SKILL='daily-idiom',DEFAULT_MORNING='08:00',DEFAULT_EVENING='21:00';
const USERS_DIR=path.join(__dirname,'../data/users');
const ALLOWED_CH=new Set(['telegram','feishu','slack','discord']);
function sanitizeId(v){if(typeof v!=='string'||!/^[a-zA-Z0-9_-]{1,128}$/.test(v)){console.error('invalid userId');process.exit(1);}return v;}
function sanitizeTime(v,l){if(!/^\d{1,2}:\d{2}$/.test(v)){console.error('invalid '+l);process.exit(1);}const[h,m]=v.split(':').map(Number);if(h>23||m>59){console.error('invalid '+l);process.exit(1);}return{h,m};}
function safeUserPath(u){const r=path.resolve(USERS_DIR,u+'.json');if(!r.startsWith(path.resolve(USERS_DIR)+path.sep)){console.error('illegal path');process.exit(1);}return r;}
function loadUser(u){const f=safeUserPath(u);return fs.existsSync(f)?JSON.parse(fs.readFileSync(f,'utf8')):{};}
function saveUser(u,d){fs.mkdirSync(USERS_DIR,{recursive:true});fs.writeFileSync(safeUserPath(u),JSON.stringify(d,null,2),'utf8');}
function enablePush(userId,opts){
  userId=sanitizeId(userId);
  const user=loadUser(userId);
  const mt=opts.morning||user.morningTime||DEFAULT_MORNING;
  const et=opts.evening||user.eveningTime||DEFAULT_EVENING;
  const{h:mh,m:mm}=sanitizeTime(mt,'--morning');
  const{h:eh,m:em}=sanitizeTime(et,'--evening');
  const ch=opts.channel||user.channel||'telegram';
  if(!ALLOWED_CH.has(ch)){console.error('unsupported channel:'+ch);process.exit(1);}
  const sk=`agent:main:${ch}:direct:${userId}`;
  console.log('__OPENCLAW_CRON_ADD__:'+JSON.stringify({name:`${SKILL}-morning-${userId}`,cronExpr:`${mm} ${mh} * * *`,tz:'Asia/Shanghai',session:'isolated',sessionKey:sk,channel:ch,to:userId,announce:true,timeoutSeconds:180,message:`node ${path.join(__dirname,'morning-push.js')} ${userId}`}));
  console.log('__OPENCLAW_CRON_ADD__:'+JSON.stringify({name:`${SKILL}-evening-${userId}`,cronExpr:`${em} ${eh} * * *`,tz:'Asia/Shanghai',session:'isolated',sessionKey:sk,channel:ch,to:userId,announce:true,timeoutSeconds:180,message:`node ${path.join(__dirname,'evening-push.js')} ${userId}`}));
  saveUser(userId,{...user,morningTime:mt,eveningTime:et,channel:ch,pushEnabled:true,updatedAt:new Date().toISOString()});
  console.log(`\n✅ ${SKILL} 推送已开启\n⏰ 早推: ${mt}  🌙 晚推: ${et}  📡 渠道: ${ch}\n关闭: node push-toggle.js off ${userId}`);
}
function disablePush(userId){
  userId=sanitizeId(userId);
  console.log(`__OPENCLAW_CRON_RM__:${SKILL}-morning-${userId}`);
  console.log(`__OPENCLAW_CRON_RM__:${SKILL}-evening-${userId}`);
  saveUser(userId,{...loadUser(userId),pushEnabled:false,updatedAt:new Date().toISOString()});
  console.log(`✅ ${SKILL} 推送已关闭`);
}
function showStatus(userId){
  userId=sanitizeId(userId);
  const u=loadUser(userId);
  console.log(`\n📡 ${SKILL} — ${userId}\n状态: ${u.pushEnabled?'✅ 开启':'❌ 关闭'}  早推: ${u.morningTime||DEFAULT_MORNING}  晚推: ${u.eveningTime||DEFAULT_EVENING}  渠道: ${u.channel||'telegram'}\n`);
}
if(require.main!==module)return;
const[cmd,uid,...rest]=process.argv.slice(2);
if(!cmd||!uid){console.log('Usage: node push-toggle.js on|off|status <userId>');process.exit(1);}
const opts={};
const mi=rest.indexOf('--morning');if(mi!==-1)opts.morning=rest[mi+1];
const ei=rest.indexOf('--evening');if(ei!==-1)opts.evening=rest[ei+1];
const ci=rest.indexOf('--channel');if(ci!==-1)opts.channel=rest[ci+1];
if(cmd==='on')enablePush(uid,opts);
else if(cmd==='off')disablePush(uid);
else if(cmd==='status')showStatus(uid);
else{console.error('unknown cmd:'+cmd);process.exit(1);}


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (HIGH)