emt/main.go

88 lines
1.8 KiB
Go
Raw Normal View History

2017-08-31 15:35:41 +00:00
package main
import (
"fmt"
"os"
2017-09-26 22:02:57 +00:00
"strings"
"github.com/kyokomi/emoji"
2017-08-31 15:35:41 +00:00
)
var emoticons map[string]string
func main() {
initEmoticons()
// We default to "shrug"
2017-09-26 22:49:40 +00:00
var done bool
var which string
2017-09-26 22:49:40 +00:00
if len(os.Args) == 2 {
which = os.Args[1]
2017-08-31 15:35:41 +00:00
if which == "help" {
showHelp()
2017-09-26 22:49:40 +00:00
} else if which == "help-emoji" {
allEmoji := emoji.CodeMap()
fmt.Println("== Supported Emoji ==")
for k, v := range allEmoji {
fmt.Println(k + " " + v)
}
os.Exit(0)
2017-08-31 15:35:41 +00:00
}
// it might be a one-word emoji request
allEmoji := emoji.CodeMap()
if _, done = allEmoji[which]; done {
2017-09-26 22:49:40 +00:00
tst1 := ":" + which + ":"
tst2 := emoji.Sprint(tst1)
if tst1 != tst2 {
fmt.Println(tst2)
2017-09-26 22:49:40 +00:00
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 {
var i string
if i, done = emoticons[which]; done {
fmt.Println(i)
2017-09-26 22:49:40 +00:00
}
}
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)
2017-08-31 15:35:41 +00:00
}
os.Exit(0)
2017-08-31 15:35:41 +00:00
}
func initEmoticons() {
emoticons = make(map[string]string)
emoticons["ascii-bat"] = "°·_·°"
emoticons["ascii-bomb"] = "●~*"
emoticons["ascii-fish"] = ">°)))彡"
emoticons["ascii-flip"] = "(╯°□°)╯︵ ┻━┻"
emoticons["ascii-lenny"] = "( ͡° ͜ʖ ͡°)"
emoticons["ascii-octopus"] = "<コ:彡"
emoticons["ascii-shrug"] = "¯\\_(ツ)_/¯"
emoticons["ascii-smirk"] = "( ͡° ͜ʖ ͡°)"
emoticons["ascii-snake"] = "~>°)"
emoticons["ascii-star"] = "☆彡"
emoticons["ascii-tadpole"] = "(°°)"
2017-08-31 15:35:41 +00:00
}