From 3d00fcd99cd6359aeca71cd561334f2280989e38 Mon Sep 17 00:00:00 2001 From: Zhongwei Li Date: Sun, 30 Nov 2025 08:40:55 +0800 Subject: [PATCH] Initial commit --- .claude-plugin/plugin.json | 12 + README.md | 3 + plugin.lock.json | 52 ++++ skills/sayhello/SKILL.md | 210 +++++++++++++++ skills/sayhello/reference/greetings.md | 360 +++++++++++++++++++++++++ skills/sayhello/scripts/greet.py | 321 ++++++++++++++++++++++ 6 files changed, 958 insertions(+) create mode 100644 .claude-plugin/plugin.json create mode 100644 README.md create mode 100644 plugin.lock.json create mode 100644 skills/sayhello/SKILL.md create mode 100644 skills/sayhello/reference/greetings.md create mode 100755 skills/sayhello/scripts/greet.py diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..246795e --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,12 @@ +{ + "name": "common-skills", + "description": "公共工具技能 - 通用的辅助工具,如多语言问候、文本处理、格式转换等", + "version": "0.0.0-2025.11.28", + "author": { + "name": "FreeShip Team", + "email": "larry.koo711@gmail.com" + }, + "skills": [ + "./skills/sayhello" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..d039de3 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# common-skills + +公共工具技能 - 通用的辅助工具,如多语言问候、文本处理、格式转换等 diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..fd88103 --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,52 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:mojito-llm/freeship-skills:common-skills", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "591cfd45bde789c7907b5305dc13dd9479871986", + "treeHash": "d39bbe09483003c97f3b62b12b1e30007bb3ab4a7f3018ddc3683bd72ebdf7de", + "generatedAt": "2025-11-28T10:27:08.669836Z", + "toolVersion": "publish_plugins.py@0.2.0" + }, + "origin": { + "remote": "git@github.com:zhongweili/42plugin-data.git", + "branch": "master", + "commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390", + "repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data" + }, + "manifest": { + "name": "common-skills", + "description": "公共工具技能 - 通用的辅助工具,如多语言问候、文本处理、格式转换等" + }, + "content": { + "files": [ + { + "path": "README.md", + "sha256": "664283e0bbcee96c0a59ea235d048e16596f52dddeba42e75d83f0cd35397a0c" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "8d1d321ce8361925385fd5e7d7dc8ca2cfe00cdc17bf9afce411217ffeeb42ce" + }, + { + "path": "skills/sayhello/SKILL.md", + "sha256": "a9163ba8e875f5fc44fc0a115515aba317260b6198d74606aae4d09aad4ae329" + }, + { + "path": "skills/sayhello/scripts/greet.py", + "sha256": "1f482cad5f2e00680d8388f9e2c4893747a9105ad8a85edf3acd18d29cef207a" + }, + { + "path": "skills/sayhello/reference/greetings.md", + "sha256": "604d865ab36db76c4372ff8a21614777ea57bd8b741cd6ab5fbdca5880cb8609" + } + ], + "dirSha256": "d39bbe09483003c97f3b62b12b1e30007bb3ab4a7f3018ddc3683bd72ebdf7de" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file diff --git a/skills/sayhello/SKILL.md b/skills/sayhello/SKILL.md new file mode 100644 index 0000000..52e3613 --- /dev/null +++ b/skills/sayhello/SKILL.md @@ -0,0 +1,210 @@ +--- +name: sayhello +description: Generate friendly greetings in multiple languages and styles. Use this skill when users request greetings, welcome messages, or multilingual hello messages for various contexts (formal, casual, cultural). +--- + +# Say Hello Skill + +A skill that helps generate friendly, contextual greetings in multiple languages and styles. + +## Overview + +Generate personalized greetings for various contexts including: +- Multilingual greetings (English, Chinese, Japanese, Spanish, French, etc.) +- Different formality levels (formal, casual, professional) +- Cultural contexts (business meetings, social gatherings, emails) +- Time-based greetings (morning, afternoon, evening) +- Custom greeting templates + +## Quick Start + +### Basic Usage + +Generate a simple greeting: +``` +"Say hello in Chinese" +→ 你好!(Nǐ hǎo!) +``` + +Generate a formal greeting: +``` +"Generate a formal business greeting for a Japanese client" +→ おはようございます。お会いできて光栄です。(Ohayō gozaimasu. O-ai dekite kōei desu.) +``` + +Generate time-based greeting: +``` +"Create a good morning greeting" +→ Good morning! Hope you have a wonderful day ahead! +``` + +## Core Capabilities + +### 1. Multilingual Greetings + +Generate greetings in various languages with proper pronunciation guides: + +**Supported Languages:** +- English +- 中文 (Chinese - Simplified & Traditional) +- 日本語 (Japanese) +- Español (Spanish) +- Français (French) +- Deutsch (German) +- 한국어 (Korean) +- Italiano (Italian) +- Português (Portuguese) +- Русский (Russian) + +**Example:** +``` +"Say hello in Spanish with pronunciation" +→ ¡Hola! (OH-lah) + ¡Buenos días! (BWEH-nos DEE-ahs) +``` + +### 2. Context-Aware Greetings + +Generate greetings appropriate for different contexts: + +**Business Context:** +``` +"Professional greeting for email" +→ Dear [Name], + I hope this message finds you well. +``` + +**Casual Context:** +``` +"Casual greeting for friends" +→ Hey there! What's up? +``` + +**Cultural Events:** +``` +"Chinese New Year greeting" +→ 新年快乐!恭喜发财! + (Xīn nián kuài lè! Gōng xǐ fā cái!) + Happy New Year! Wishing you prosperity! +``` + +### 3. Time-Based Greetings + +Generate appropriate greetings based on time of day: + +- **Morning:** "Good morning", "早上好" +- **Afternoon:** "Good afternoon", "下午好" +- **Evening:** "Good evening", "晚上好" +- **Night:** "Good night", "晚安" + +### 4. Custom Templates + +Use the greeting templates in `assets/` for consistent, branded greetings: + +**Email Templates:** +- Formal business introduction +- Casual team communication +- Client outreach +- Meeting invitations + +**Social Templates:** +- Birthday greetings +- Holiday greetings +- Welcome messages +- Thank you notes + +## Using Scripts + +### greet.py + +Generate greetings programmatically using the included Python script: + +```bash +python scripts/greet.py --language chinese --style formal +``` + +**Parameters:** +- `--language`: Target language (default: english) +- `--style`: Formality level (formal/casual/professional) +- `--context`: Specific context (business/social/email) +- `--time`: Time of day (morning/afternoon/evening/night) + +**Example:** +```bash +# Generate formal Chinese business greeting +python scripts/greet.py --language chinese --style formal --context business + +# Generate casual morning greeting +python scripts/greet.py --style casual --time morning +``` + +## Reference Materials + +For comprehensive greeting conventions across cultures, pronunciation guides, and cultural etiquette, refer to: + +- `reference/greetings.md` - Complete greeting reference for all supported languages +- `reference/cultural_contexts.md` - Cultural considerations and etiquette guidelines + +## Best Practices + +1. **Consider Cultural Context:** Always consider the recipient's cultural background when choosing greetings +2. **Match Formality Level:** Ensure the greeting matches the relationship and context +3. **Include Pronunciation:** When using non-Latin scripts, include pronunciation guides +4. **Time Awareness:** Use time-appropriate greetings when context is known +5. **Personalization:** Customize greetings with names and specific details when available + +## Examples + +### Scenario 1: International Team Email +``` +Request: "Greeting for international team email" + +Response: +Hello Team / 大家好 / みなさん、こんにちは + +I hope this message finds you all well. I wanted to reach out regarding... +``` + +### Scenario 2: Formal Business Introduction +``` +Request: "Formal greeting for new Chinese business partner" + +Response: +尊敬的 [Partner Name], + +非常荣幸能与贵公司合作。期待我们之间建立长期互利的合作关系。 + +(Zūn jìng de [Partner Name], +Fēi cháng róng xìng néng yǔ guì gōng sī hé zuò. Qī dài wǒ men zhī jiān jiàn lì cháng qī hù lì de hé zuò guān xì.) + +Dear [Partner Name], +It is a great honor to collaborate with your esteemed company. We look forward to establishing a long-term mutually beneficial partnership. +``` + +### Scenario 3: Casual Social Greeting +``` +Request: "Fun greeting for team Slack channel" + +Response: +Hey everyone! 👋 +Hope you're all having an awesome day! ☀️ +``` + +## Advanced Features + +### Greeting Chains +Generate greeting sequences for multi-step interactions: +1. Initial greeting +2. Introduction +3. Purpose statement +4. Closing + +### Cultural Adaptations +Automatically adapt greetings based on: +- Regional dialects +- Cultural holidays +- Business customs +- Social norms + +### A/B Testing Support +Generate multiple greeting variations for testing effectiveness in different contexts. diff --git a/skills/sayhello/reference/greetings.md b/skills/sayhello/reference/greetings.md new file mode 100644 index 0000000..8aeb372 --- /dev/null +++ b/skills/sayhello/reference/greetings.md @@ -0,0 +1,360 @@ +# Greeting Reference Guide + +Complete reference for greetings across languages and cultures. + +## Table of Contents +- [Supported Languages](#supported-languages) +- [Formality Levels](#formality-levels) +- [Time-Based Greetings](#time-based-greetings) +- [Cultural Contexts](#cultural-contexts) +- [Pronunciation Guide](#pronunciation-guide) +- [Common Phrases](#common-phrases) + +## Supported Languages + +### English +**Region:** Global, primarily US, UK, Australia, Canada + +**Common Greetings:** +- Hello +- Hi +- Hey +- Good morning/afternoon/evening +- How are you? +- How's it going? + +**Formality:** +- Formal: "Good day", "Greetings", "Dear Sir/Madam" +- Casual: "Hey", "What's up", "Howdy" +- Professional: "Good morning", "Hello [Name]" + +--- + +### 中文 (Chinese) +**Region:** China, Taiwan, Singapore + +**Common Greetings:** +- 你好 (nǐ hǎo) - Hello [casual] +- 您好 (nín hǎo) - Hello [formal] +- 早上好 (zǎo shang hǎo) - Good morning +- 下午好 (xià wǔ hǎo) - Good afternoon +- 晚上好 (wǎn shang hǎo) - Good evening +- 晚安 (wǎn ān) - Good night + +**Formality:** +- Formal: 尊敬的 (zūn jìng de) - Respected/Dear +- Casual: 嗨 (hāi), 哈喽 (hā lou) +- Professional: 您好 (nín hǎo) + +**Cultural Notes:** +- Use 您 (nín) for elders and superiors +- Common to ask "吃了吗?" (Have you eaten?) as a greeting +- Handshakes are common in business settings + +--- + +### 日本語 (Japanese) +**Region:** Japan + +**Common Greetings:** +- おはようございます (ohayō gozaimasu) - Good morning [formal] +- こんにちは (konnichiwa) - Hello/Good afternoon +- こんばんは (konbanwa) - Good evening +- おやすみなさい (oyasuminasai) - Good night +- はじめまして (hajimemashite) - Nice to meet you + +**Formality:** +- Formal: ございます (gozaimasu) ending +- Casual: おはよう (ohayō), やあ (yā) +- Professional: お疲れ様です (otsukaresama desu) - Thank you for your hard work + +**Cultural Notes:** +- Bowing is standard when greeting +- Use さん (san) after names (honorific) +- Time-specific greetings are important +- Never use first names unless very close + +--- + +### Español (Spanish) +**Region:** Spain, Latin America + +**Common Greetings:** +- ¡Hola! (OH-lah) - Hello +- Buenos días (BWEH-nos DEE-ahs) - Good morning +- Buenas tardes (BWEH-nas TAR-des) - Good afternoon +- Buenas noches (BWEH-nas NOH-ches) - Good evening/night +- ¿Qué tal? (keh TAHL) - How's it going? +- ¿Cómo estás? (KOH-moh es-TAHS) - How are you? + +**Formality:** +- Formal: Estimado/a (esteemed), Buenos días +- Casual: ¡Hola!, ¿Qué tal?, ¡Buenas! +- Professional: Buenos días, Don/Doña [Name] + +**Cultural Notes:** +- Cheek kissing common in social settings (varies by region) +- Use "usted" for formal, "tú" for casual +- Handshakes common in business + +--- + +### Français (French) +**Region:** France, Belgium, Canada (Quebec), Switzerland, parts of Africa + +**Common Greetings:** +- Bonjour (bon-ZHOOR) - Hello/Good day +- Bonsoir (bon-SWAHR) - Good evening +- Salut (sa-LOO) - Hi [casual] +- Enchanté(e) (on-shon-TAY) - Pleased to meet you +- Ça va? (sa VAH) - How's it going? + +**Formality:** +- Formal: Bonjour Madame/Monsieur, Enchanté(e) +- Casual: Salut, Coucou, Ça va? +- Professional: Bonjour, Madame/Monsieur [Last Name] + +**Cultural Notes:** +- La bise (cheek kissing) common in France +- Use "vous" for formal, "tu" for casual +- Always say "Bonjour" before other conversation + +--- + +### Deutsch (German) +**Region:** Germany, Austria, Switzerland + +**Common Greetings:** +- Guten Morgen (GOO-ten MOR-gen) - Good morning +- Guten Tag (GOO-ten TAHK) - Good day +- Guten Abend (GOO-ten AH-bent) - Good evening +- Hallo (HAH-loh) - Hello +- Grüß Gott (GRUESS got) - Hello [Southern Germany/Austria] + +**Formality:** +- Formal: Sehr geehrter Herr/Frau +- Casual: Hallo, Hi, Servus +- Professional: Guten Tag, Herr/Frau [Last Name] + +--- + +### 한국어 (Korean) +**Region:** South Korea, North Korea + +**Common Greetings:** +- 안녕하세요 (an-nyeong-ha-se-yo) - Hello [formal] +- 안녕 (an-nyeong) - Hi [casual] +- 좋은 아침입니다 (jo-eun a-chim-im-ni-da) - Good morning +- 처음 뵙겠습니다 (cheo-eum boep-get-seum-ni-da) - Nice to meet you + +**Formality:** +- Formal: 하세요 (ha-se-yo) ending +- Casual: 안녕 (an-nyeong) +- Professional: 님 (nim) honorific + +--- + +## Formality Levels + +### Formal +**When to use:** +- First meetings with clients/superiors +- Official business correspondence +- Elderly people or authority figures +- Formal events and ceremonies + +**Characteristics:** +- Complete sentences +- Titles and honorifics +- Respectful language +- Proper grammar + +**Examples:** +- English: "Dear Mr. Smith, I hope this letter finds you well." +- Chinese: "尊敬的王先生" (Respected Mr. Wang) +- Japanese: "お世話になっております" (Thank you for your continued support) + +### Casual +**When to use:** +- Friends and peers +- Informal social settings +- Family members +- Familiar colleagues + +**Characteristics:** +- Shortened phrases +- Slang acceptable +- Relaxed tone +- First names + +**Examples:** +- English: "Hey! What's up?" +- Chinese: "嗨!最近怎么样?" (Hi! How have you been lately?) +- Spanish: "¡Hola! ¿Qué tal?" + +### Professional +**When to use:** +- Business meetings +- Email correspondence +- Networking events +- Office environment + +**Characteristics:** +- Polite but not overly formal +- Respectful +- Clear and direct +- Appropriate for workplace + +**Examples:** +- English: "Good morning, Sarah" +- Chinese: "早上好,李经理" (Good morning, Manager Li) +- Japanese: "おはようございます、田中さん" (Good morning, Tanaka-san) + +--- + +## Time-Based Greetings + +### Morning (5 AM - 12 PM) +- English: Good morning +- Chinese: 早上好 (zǎo shang hǎo) +- Japanese: おはようございます (ohayō gozaimasu) +- Spanish: Buenos días +- French: Bonjour +- German: Guten Morgen + +### Afternoon (12 PM - 5 PM) +- English: Good afternoon +- Chinese: 下午好 (xià wǔ hǎo) +- Japanese: こんにちは (konnichiwa) +- Spanish: Buenas tardes +- French: Bon après-midi +- German: Guten Tag + +### Evening (5 PM - 9 PM) +- English: Good evening +- Chinese: 晚上好 (wǎn shang hǎo) +- Japanese: こんばんは (konbanwa) +- Spanish: Buenas noches +- French: Bonsoir +- German: Guten Abend + +### Night (9 PM - 5 AM) +- English: Good night +- Chinese: 晚安 (wǎn ān) +- Japanese: おやすみなさい (oyasuminasai) +- Spanish: Buenas noches +- French: Bonne nuit +- German: Gute Nacht + +--- + +## Cultural Contexts + +### Business Meetings +**Best Practices:** +- Arrive on time (or early in some cultures) +- Use formal greetings initially +- Business cards exchange (especially in Asia) +- Firm handshake (Western cultures) +- Bow (Japan, Korea) +- Research cultural norms beforehand + +**Sample Greetings:** +- "Good morning, thank you for taking the time to meet with me." +- "您好,很高兴见到您。" (Hello, pleased to meet you.) +- "おはようございます。本日はお時間をいただきありがとうございます。" + +### Email Communication +**Structure:** +1. Greeting +2. Brief pleasantry (optional) +3. Purpose +4. Closing + +**Examples:** +``` +Dear [Name], + +I hope this email finds you well. + +I am writing to discuss... + +Best regards, +[Your Name] +``` + +### Social Events +**Characteristics:** +- Warmer, more personal +- Small talk encouraged +- Smile and eye contact +- Appropriate physical contact (culture-dependent) + +### Cultural Holidays +- Chinese New Year: 新年快乐!恭喜发财! +- Ramadan: Ramadan Kareem / رمضان كريم +- Christmas: Merry Christmas / Joyeux Noël +- Diwali: Happy Diwali / दिवाली की शुभकामनाएं + +--- + +## Pronunciation Guide + +### Pinyin (Chinese) +- ā, á, ǎ, à - Different tones (flat, rising, falling-rising, falling) +- zh - like 'j' in "jump" +- x - like 'sh' in "she" +- q - like 'ch' in "cheer" + +### Romanization (Japanese) +- Vowels: a(ah), i(ee), u(oo), e(eh), o(oh) +- Long vowels indicated by macron: ō, ū +- Double consonants indicate pause + +### Spanish +- j - like 'h' in "hot" +- ll - like 'y' in "yes" +- ñ - like 'ny' in "canyon" +- r - rolled r sound +- rr - strongly rolled r + +--- + +## Common Phrases + +### Introducing Yourself +- English: "Nice to meet you. My name is..." +- Chinese: "很高兴认识您。我叫..." (hěn gāo xìng rèn shi nín. wǒ jiào...) +- Japanese: "はじめまして。[Name]と申します。" (hajimemashite. [Name] to mōshimasu.) +- Spanish: "Mucho gusto. Me llamo..." + +### Asking How Someone Is +- English: "How are you?" +- Chinese: "你好吗?" (nǐ hǎo ma?) +- Japanese: "お元気ですか?" (o-genki desu ka?) +- Spanish: "¿Cómo está?" + +### Responding +- English: "I'm well, thank you" +- Chinese: "我很好,谢谢" (wǒ hěn hǎo, xiè xie) +- Japanese: "元気です、ありがとうございます" (genki desu, arigatō gozaimasu) +- Spanish: "Estoy bien, gracias" + +### Goodbye +- English: "Goodbye", "See you later" +- Chinese: "再见" (zài jiàn), "回头见" (huí tóu jiàn) +- Japanese: "さようなら" (sayōnara), "また後で" (mata ato de) +- Spanish: "Adiós", "Hasta luego" + +--- + +## Best Practices + +1. **Research Cultural Norms:** Always research greeting customs before international interactions +2. **Mirror Formality:** Match the formality level of the person you're greeting +3. **Use Names Appropriately:** Some cultures use first names, others use titles and last names +4. **Be Time-Aware:** Use appropriate greetings for time of day +5. **Respect Personal Space:** Physical contact varies widely across cultures +6. **Learn Pronunciation:** Make an effort to pronounce names and greetings correctly +7. **Smile:** Generally universal and well-received +8. **Follow Their Lead:** When unsure, follow the lead of locals or hosts diff --git a/skills/sayhello/scripts/greet.py b/skills/sayhello/scripts/greet.py new file mode 100755 index 0000000..9fd49ad --- /dev/null +++ b/skills/sayhello/scripts/greet.py @@ -0,0 +1,321 @@ +#!/usr/bin/env python3 +""" +Greeting Generator Script + +Generate contextual greetings in multiple languages and styles. + +Usage: + python greet.py --language chinese --style formal + python greet.py --style casual --time morning + python greet.py --language spanish --context business +""" + +import argparse +import sys +from datetime import datetime +from typing import Dict, List, Tuple + + +class GreetingGenerator: + """Generate greetings based on language, style, context, and time.""" + + GREETINGS: Dict[str, Dict[str, List[str]]] = { + "english": { + "formal": [ + "Good day", + "Greetings", + "I hope this message finds you well" + ], + "casual": [ + "Hey", + "Hi there", + "Hello", + "What's up" + ], + "professional": [ + "Good morning/afternoon", + "Hello", + "Dear [Name]" + ] + }, + "chinese": { + "formal": [ + "您好 (nín hǎo)", + "尊敬的 [Name] (zūn jìng de)", + "很高兴见到您 (hěn gāo xìng jiàn dào nín)" + ], + "casual": [ + "你好 (nǐ hǎo)", + "嗨 (hāi)", + "哈喽 (hā lou)" + ], + "professional": [ + "您好 (nín hǎo)", + "早上好 (zǎo shang hǎo)", + "下午好 (xià wǔ hǎo)" + ] + }, + "spanish": { + "formal": [ + "Buenos días (bweh-nos DEE-ahs)", + "Estimado/a [Name]", + "Es un placer conocerle" + ], + "casual": [ + "¡Hola! (OH-lah)", + "¿Qué tal?", + "¡Buenas!" + ], + "professional": [ + "Buenos días", + "Buenas tardes", + "Hola, [Name]" + ] + }, + "japanese": { + "formal": [ + "おはようございます (ohayō gozaimasu)", + "こんにちは (konnichiwa)", + "お会いできて光栄です (o-ai dekite kōei desu)" + ], + "casual": [ + "やあ (yā)", + "おっす (ossu)", + "こんちは (konchiwa)" + ], + "professional": [ + "おはようございます (ohayō gozaimasu)", + "こんにちは (konnichiwa)", + "[Name]さん、お疲れ様です" + ] + }, + "french": { + "formal": [ + "Bonjour (bon-ZHOOR)", + "Enchanté(e)", + "Ravi(e) de vous rencontrer" + ], + "casual": [ + "Salut (sa-LOO)", + "Coucou", + "Ça va?" + ], + "professional": [ + "Bonjour", + "Bonsoir", + "Madame/Monsieur [Name]" + ] + } + } + + TIME_GREETINGS: Dict[str, Dict[str, str]] = { + "morning": { + "english": "Good morning", + "chinese": "早上好 (zǎo shang hǎo)", + "spanish": "Buenos días", + "japanese": "おはようございます (ohayō gozaimasu)", + "french": "Bonjour" + }, + "afternoon": { + "english": "Good afternoon", + "chinese": "下午好 (xià wǔ hǎo)", + "spanish": "Buenas tardes", + "japanese": "こんにちは (konnichiwa)", + "french": "Bon après-midi" + }, + "evening": { + "english": "Good evening", + "chinese": "晚上好 (wǎn shang hǎo)", + "spanish": "Buenas noches", + "japanese": "こんばんは (konbanwa)", + "french": "Bonsoir" + }, + "night": { + "english": "Good night", + "chinese": "晚安 (wǎn ān)", + "spanish": "Buenas noches", + "japanese": "おやすみなさい (oyasuminasai)", + "french": "Bonne nuit" + } + } + + CONTEXT_TEMPLATES: Dict[str, str] = { + "business": """Dear [Name], + +{greeting} + +I hope this message finds you well. I am reaching out to discuss... + +Best regards, +[Your Name]""", + + "email": """Hello [Name], + +{greeting} + +I wanted to reach out regarding... + +Kind regards, +[Your Name]""", + + "social": """{greeting} + +Great to connect with you! + +Cheers, +[Your Name]""", + + "meeting": """{greeting} + +Thank you for taking the time to meet with me today. + +Looking forward to our discussion. + +Best, +[Your Name]""" + } + + def __init__(self): + self.current_hour = datetime.now().hour + + def get_auto_time(self) -> str: + """Automatically determine time of day based on current hour.""" + if 5 <= self.current_hour < 12: + return "morning" + elif 12 <= self.current_hour < 17: + return "afternoon" + elif 17 <= self.current_hour < 21: + return "evening" + else: + return "night" + + def generate( + self, + language: str = "english", + style: str = "casual", + context: str = None, + time: str = None + ) -> str: + """ + Generate a greeting based on parameters. + + Args: + language: Target language + style: Formality level (formal/casual/professional) + context: Specific context (business/email/social/meeting) + time: Time of day (morning/afternoon/evening/night) + + Returns: + Generated greeting string + """ + language = language.lower() + style = style.lower() + + # Validate inputs + if language not in self.GREETINGS: + available = ", ".join(self.GREETINGS.keys()) + return f"Error: Language '{language}' not supported. Available: {available}" + + if style not in self.GREETINGS[language]: + available = ", ".join(self.GREETINGS[language].keys()) + return f"Error: Style '{style}' not available. Available: {available}" + + # Generate greeting based on time if specified + if time: + time = time.lower() + if time in self.TIME_GREETINGS: + greeting = self.TIME_GREETINGS[time].get(language, "Hello") + else: + greeting = self.GREETINGS[language][style][0] + else: + # Use first greeting from the style list + greeting = self.GREETINGS[language][style][0] + + # Apply context template if specified + if context and context.lower() in self.CONTEXT_TEMPLATES: + template = self.CONTEXT_TEMPLATES[context.lower()] + return template.format(greeting=greeting) + + return greeting + + def list_options(self) -> str: + """List all available languages, styles, and contexts.""" + output = [] + output.append("Available Languages:") + for lang in self.GREETINGS.keys(): + output.append(f" - {lang}") + + output.append("\nAvailable Styles:") + output.append(" - formal") + output.append(" - casual") + output.append(" - professional") + + output.append("\nAvailable Contexts:") + for ctx in self.CONTEXT_TEMPLATES.keys(): + output.append(f" - {ctx}") + + output.append("\nAvailable Times:") + for t in self.TIME_GREETINGS.keys(): + output.append(f" - {t}") + + return "\n".join(output) + + +def main(): + parser = argparse.ArgumentParser( + description="Generate contextual greetings in multiple languages", + formatter_class=argparse.RawDescriptionHelpFormatter, + epilog=""" +Examples: + python greet.py --language chinese --style formal + python greet.py --style casual --time morning + python greet.py --language spanish --context business + python greet.py --list + """ + ) + + parser.add_argument( + "--language", + default="english", + help="Target language (default: english)" + ) + parser.add_argument( + "--style", + default="casual", + help="Formality level: formal, casual, professional (default: casual)" + ) + parser.add_argument( + "--context", + help="Specific context: business, email, social, meeting" + ) + parser.add_argument( + "--time", + help="Time of day: morning, afternoon, evening, night" + ) + parser.add_argument( + "--list", + action="store_true", + help="List all available options" + ) + + args = parser.parse_args() + + generator = GreetingGenerator() + + if args.list: + print(generator.list_options()) + return 0 + + greeting = generator.generate( + language=args.language, + style=args.style, + context=args.context, + time=args.time + ) + + print(greeting) + return 0 + + +if __name__ == "__main__": + sys.exit(main())