mirror of
https://github.com/prosolis/gogobee.git
synced 2026-07-16 08:52:42 +00:00
Add dictionary commands, antonym/etymology integrations, and audit fixes
New DictionaryPlugin with !antonym, !pronounce, !etymology, !difficulty, and !rhyme commands. Integrate antonyms into !define (concurrent 500ms fetch), difficulty tier into Hangman headers, and etymology into WOTD. Fix rhyme limit bug (request 50, display 7), variable shadowing, and add spec-required emoji prefixes to all dictionary command outputs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -160,6 +160,19 @@ func (p *WOTDPlugin) pickWord(lang string) (string, string, string, string) {
|
||||
transMap["syn"] = synonyms
|
||||
}
|
||||
|
||||
// Fetch etymology
|
||||
if etym, err := p.dict.Etymology(candidate, lang); err == nil && etym != "" {
|
||||
// Truncate for WOTD display (max 200 chars).
|
||||
if len(etym) > 200 {
|
||||
if idx := strings.LastIndex(etym[:200], "."); idx > 100 {
|
||||
etym = etym[:idx+1] + "..."
|
||||
} else {
|
||||
etym = etym[:200] + "..."
|
||||
}
|
||||
}
|
||||
transMap["_etym"] = []string{etym}
|
||||
}
|
||||
|
||||
var translationsJSON string
|
||||
if data, err := json.Marshal(transMap); err == nil {
|
||||
translationsJSON = string(data)
|
||||
@@ -414,6 +427,13 @@ func (p *WOTDPlugin) formatWOTD(word, definition, partOfSpeech, translationsJSON
|
||||
sb.WriteString("\n")
|
||||
}
|
||||
|
||||
// Etymology section (if available).
|
||||
if transMap != nil {
|
||||
if etym, ok := transMap["_etym"]; ok && len(etym) > 0 && etym[0] != "" {
|
||||
sb.WriteString(fmt.Sprintf("Etymology\n %s\n\n", etym[0]))
|
||||
}
|
||||
}
|
||||
|
||||
sb.WriteString("━━━━━━━━━━━━━━━━━━━━\n")
|
||||
sb.WriteString(fmt.Sprintf("Learn more: `!define %s %s`\n", word, lang))
|
||||
sb.WriteString("Use this word in a message today to earn 25 XP!")
|
||||
|
||||
Reference in New Issue
Block a user