Add emoji searching
Also update the emoji library
This commit is contained in:
parent
0937f3efeb
commit
bd82c95b31
75
main.go
75
main.go
@ -13,16 +13,12 @@ var emoticons map[string]string
|
|||||||
func main() {
|
func main() {
|
||||||
initEmoticons()
|
initEmoticons()
|
||||||
// We default to "shrug"
|
// We default to "shrug"
|
||||||
emt := "¯\\_(ツ)_/¯"
|
|
||||||
var done bool
|
var done bool
|
||||||
|
var which string
|
||||||
if len(os.Args) == 2 {
|
if len(os.Args) == 2 {
|
||||||
which := os.Args[1]
|
which = os.Args[1]
|
||||||
if which == "help" {
|
if which == "help" {
|
||||||
fmt.Println("There are a *ton* of emoji supported, to list them, do \"help-emoji\"")
|
showHelp()
|
||||||
for k, v := range emoticons {
|
|
||||||
fmt.Println(k, v)
|
|
||||||
}
|
|
||||||
os.Exit(0)
|
|
||||||
} else if which == "help-emoji" {
|
} else if which == "help-emoji" {
|
||||||
allEmoji := emoji.CodeMap()
|
allEmoji := emoji.CodeMap()
|
||||||
fmt.Println("== Supported Emoji ==")
|
fmt.Println("== Supported Emoji ==")
|
||||||
@ -30,41 +26,62 @@ func main() {
|
|||||||
fmt.Println(k + " " + v)
|
fmt.Println(k + " " + v)
|
||||||
}
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
} else {
|
|
||||||
var i string
|
|
||||||
if i, done = emoticons[which]; done {
|
|
||||||
emt = i
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if !done {
|
|
||||||
// it might be a one-word emoji request
|
// it might be a one-word emoji request
|
||||||
|
allEmoji := emoji.CodeMap()
|
||||||
|
if _, done = allEmoji[which]; done {
|
||||||
tst1 := ":" + which + ":"
|
tst1 := ":" + which + ":"
|
||||||
tst2 := emoji.Sprint(tst1)
|
tst2 := emoji.Sprint(tst1)
|
||||||
if tst1 != tst2 {
|
if tst1 != tst2 {
|
||||||
emt = tst2
|
fmt.Println(tst2)
|
||||||
done = true
|
done = true
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Search for any emoji that contain this string
|
||||||
|
var cnt int
|
||||||
|
for k, v := range allEmoji {
|
||||||
|
if strings.Contains(k, which) {
|
||||||
|
fmt.Println(k + " " + v)
|
||||||
|
cnt++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if cnt > 0 {
|
||||||
|
done = true
|
||||||
|
} else {
|
||||||
|
fmt.Println("No emoji for " + which + " found.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !done {
|
if !done {
|
||||||
rest := strings.Join(os.Args[1:], " ")
|
var i string
|
||||||
emt = emoji.Sprint(rest)
|
if i, done = emoticons[which]; done {
|
||||||
|
fmt.Println(i)
|
||||||
}
|
}
|
||||||
fmt.Println(emt)
|
}
|
||||||
|
if !done {
|
||||||
|
showHelp()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func showHelp() {
|
||||||
|
fmt.Println("There are a *ton* of emoji supported, to list them, do \"help-emoji\"")
|
||||||
|
for k, v := range emoticons {
|
||||||
|
fmt.Println(k, v)
|
||||||
|
}
|
||||||
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func initEmoticons() {
|
func initEmoticons() {
|
||||||
emoticons = make(map[string]string)
|
emoticons = make(map[string]string)
|
||||||
emoticons["bat"] = "~°·_·°~"
|
emoticons["ascii-bat"] = "~°·_·°~"
|
||||||
emoticons["bomb"] = "●~*"
|
emoticons["ascii-bomb"] = "●~*"
|
||||||
emoticons["fish"] = ">°)))彡"
|
emoticons["ascii-fish"] = ">°)))彡"
|
||||||
emoticons["flip"] = "(╯°□°)╯︵ ┻━┻"
|
emoticons["ascii-flip"] = "(╯°□°)╯︵ ┻━┻"
|
||||||
emoticons["lenny"] = "( ͡° ͜ʖ ͡°)"
|
emoticons["ascii-lenny"] = "( ͡° ͜ʖ ͡°)"
|
||||||
emoticons["octopus"] = "<コ:彡"
|
emoticons["ascii-octopus"] = "<コ:彡"
|
||||||
emoticons["shrug"] = "¯\\_(ツ)_/¯"
|
emoticons["ascii-shrug"] = "¯\\_(ツ)_/¯"
|
||||||
emoticons["smirk"] = "( ͡° ͜ʖ ͡°)"
|
emoticons["ascii-smirk"] = "( ͡° ͜ʖ ͡°)"
|
||||||
emoticons["snake"] = "~>°)~~~"
|
emoticons["ascii-snake"] = "~>°)~~~"
|
||||||
emoticons["squid"] = "C:.ミ"
|
emoticons["ascii-star"] = "☆彡"
|
||||||
emoticons["star"] = "☆彡"
|
emoticons["ascii-tadpole"] = "(°°)~"
|
||||||
emoticons["tadpole"] = "(°°)~"
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user