mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 22:00:11 +08:00
31 lines
646 B
Go
31 lines
646 B
Go
package chouxianghua
|
|
|
|
import sql "github.com/FloatTech/sqlite"
|
|
|
|
type pinyin struct {
|
|
Word string `db:"word"`
|
|
Pronun string `db:"pronunciation"`
|
|
}
|
|
type emoji struct {
|
|
Pronun string `db:"pronunciation"`
|
|
Emoji string `db:"emoji"`
|
|
}
|
|
|
|
var db = &sql.Sqlite{}
|
|
|
|
func getPinyinByWord(word string) string {
|
|
var p pinyin
|
|
_ = db.Find("pinyin", &p, "where word = '"+word+"'")
|
|
return p.Pronun
|
|
}
|
|
|
|
func getPronunByDWord(w0, w1 rune) string {
|
|
return getPinyinByWord(string(w0)) + getPinyinByWord(string(w1))
|
|
}
|
|
|
|
func getEmojiByPronun(pronun string) string {
|
|
var e emoji
|
|
_ = db.Find("emoji", &e, "where pronunciation = '"+pronun+"'")
|
|
return e.Emoji
|
|
}
|