emt/main.go

71 lines
1.5 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"
emt := "¯\\_(ツ)_/¯"
2017-09-26 22:49:40 +00:00
var done bool
if len(os.Args) == 2 {
2017-08-31 15:35:41 +00:00
which := os.Args[1]
if which == "help" {
2017-09-26 22:49:40 +00:00
fmt.Println("There are a *ton* of emoji supported, to list them, do \"help-emoji\"")
2017-08-31 15:35:41 +00:00
for k, v := range emoticons {
fmt.Println(k, v)
}
os.Exit(0)
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
} else {
2017-09-26 22:49:40 +00:00
var i string
if i, done = emoticons[which]; done {
2017-08-31 15:35:41 +00:00
emt = i
}
}
2017-09-26 22:49:40 +00:00
if !done {
// it might be a one-word emoji request
tst1 := ":" + which + ":"
tst2 := emoji.Sprint(tst1)
if tst1 != tst2 {
emt = tst2
done = true
}
}
}
if !done {
rest := strings.Join(os.Args[1:], " ")
emt = emoji.Sprint(rest)
2017-08-31 15:35:41 +00:00
}
fmt.Println(emt)
}
func initEmoticons() {
emoticons = make(map[string]string)
emoticons["bat"] = "°·_·°"
emoticons["bomb"] = "●~*"
emoticons["fish"] = ">°)))彡"
emoticons["flip"] = "(╯°□°)╯︵ ┻━┻"
emoticons["lenny"] = "( ͡° ͜ʖ ͡°)"
emoticons["octopus"] = "<コ:彡"
emoticons["shrug"] = "¯\\_(ツ)_/¯"
emoticons["smirk"] = "( ͡° ͜ʖ ͡°)"
emoticons["snake"] = "~>°)"
emoticons["squid"] = ":.ミ"
emoticons["star"] = "☆彡"
emoticons["tadpole"] = "(°°)"
}