diff options
author | Wim <wim@42.be> | 2019-11-17 23:01:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-17 23:01:03 +0100 |
commit | 075ca9ca471a7bfaf86fd0a762ed38b8cbf4edfb (patch) | |
tree | 4b402b7c48e1d54ebdc8706a5f996aafab581a3f /vendor/github.com/peterhellberg/emojilib/emojilib.go | |
parent | d4253d7a55f7af862304fb65c461547055dd294a (diff) | |
download | matterbridge-msglm-075ca9ca471a7bfaf86fd0a762ed38b8cbf4edfb.tar.gz matterbridge-msglm-075ca9ca471a7bfaf86fd0a762ed38b8cbf4edfb.tar.bz2 matterbridge-msglm-075ca9ca471a7bfaf86fd0a762ed38b8cbf4edfb.zip |
Switch to new emoji library kyokomi/emoji (#948)
Diffstat (limited to 'vendor/github.com/peterhellberg/emojilib/emojilib.go')
-rw-r--r-- | vendor/github.com/peterhellberg/emojilib/emojilib.go | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/vendor/github.com/peterhellberg/emojilib/emojilib.go b/vendor/github.com/peterhellberg/emojilib/emojilib.go deleted file mode 100644 index 29da98b5..00000000 --- a/vendor/github.com/peterhellberg/emojilib/emojilib.go +++ /dev/null @@ -1,88 +0,0 @@ -/* - -Package emojilib is a port of the Emoji keyword library to Go - -Installation - -Just go get the package: - - go get -u github.com/peterhellberg/emojilib - -Usage - -A small usage example - - package main - - import ( - "fmt" - - "github.com/peterhellberg/emojilib" - ) - - func main() { - fmt.Println(emojilib.ReplaceWithPadding("I :green_heart: You!")) - } - -*/ -package emojilib - -import "errors" - -//go:generate go run _generator/main.go - -// Emojis contain emojis keyed on their name -type Emojis map[string]Emoji - -// Emoji contains the keywords, char and category for an emoji -type Emoji struct { - Keywords []string `json:"keywords"` - Char string `json:"char"` - Category string `json:"category"` -} - -// ErrUnknownEmoji is returned from Find if provided with a unknown emoji name -var ErrUnknownEmoji = errors.New("unknown emoji") - -// ErrUnknownKeyword is returned from Keyword if provided with a unknown keyword -var ErrUnknownKeyword = errors.New("unknown keyword") - -// Find returns an Emoji if provided with a known name -func Find(n string) (Emoji, error) { - if e, ok := emojis[n]; ok { - return e, nil - } - - return Emoji{}, ErrUnknownEmoji -} - -// Keyword returns Emojis for the given keyword -func Keyword(k string) ([]Emoji, error) { - if names, ok := keywordLookup[k]; ok { - es := []Emoji{} - - for _, n := range names { - es = append(es, emojis[n]) - } - - return es, nil - } - - return []Emoji{}, ErrUnknownKeyword -} - -// All returns all the emojis -func All() Emojis { - return emojis -} - -// Replace takes a string and replaces all emoji names with their emoji character -func Replace(s string) string { - return emojiReplacer.Replace(s) -} - -// ReplaceWithPadding takes a string and replaces all emoji names with their -// emoji character and a space in order to display better in terminals -func ReplaceWithPadding(s string) string { - return emojiPaddedReplacer.Replace(s) -} |