mirror of
https://github.com/42wim/matterbridge.git
synced 2024-11-21 02:02:00 -08:00
Switch to new emoji library kyokomi/emoji (#948)
This commit is contained in:
parent
d4253d7a55
commit
075ca9ca47
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,5 +1,4 @@
|
||||
# Exclude matterbridge binary
|
||||
matterbridge
|
||||
|
||||
# Exclude configuration file
|
||||
matterbridge.toml
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
"github.com/d5/tengo/script"
|
||||
"github.com/d5/tengo/stdlib"
|
||||
lru "github.com/hashicorp/golang-lru"
|
||||
"github.com/peterhellberg/emojilib"
|
||||
"github.com/matterbridge/emoji"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@ -372,7 +372,7 @@ func (gw *Gateway) modifyMessage(msg *config.Message) {
|
||||
}
|
||||
|
||||
// replace :emoji: to unicode
|
||||
msg.Text = emojilib.Replace(msg.Text)
|
||||
msg.Text = emoji.Sprint(msg.Text)
|
||||
|
||||
br := gw.Bridges[msg.Account]
|
||||
// loop to replace messages
|
||||
|
2
go.mod
2
go.mod
@ -26,6 +26,7 @@ require (
|
||||
github.com/labstack/echo/v4 v4.1.10
|
||||
github.com/lrstanley/girc v0.0.0-20190801035559-4fc93959e1a7
|
||||
github.com/matterbridge/Rocket.Chat.Go.SDK v0.0.0-20190210153444-cc9d05784d5d
|
||||
github.com/matterbridge/emoji v2.1.1-0.20191117213217-af507f6b02db+incompatible
|
||||
github.com/matterbridge/go-xmpp v0.0.0-20180529212104-cd19799fba91
|
||||
github.com/matterbridge/gomatrix v0.0.0-20191026211822-6fc7accd00ca
|
||||
github.com/matterbridge/gozulipbot v0.0.0-20190212232658-7aa251978a18
|
||||
@ -42,7 +43,6 @@ require (
|
||||
github.com/onsi/gomega v1.4.1 // indirect
|
||||
github.com/paulrosania/go-charset v0.0.0-20190326053356-55c9d7a5834c
|
||||
github.com/pborman/uuid v0.0.0-20160216163710-c55201b03606 // indirect
|
||||
github.com/peterhellberg/emojilib v0.0.0-20190124112554-c18758d55320
|
||||
github.com/rs/xid v1.2.1
|
||||
github.com/russross/blackfriday v1.5.2
|
||||
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca
|
||||
|
4
go.sum
4
go.sum
@ -126,6 +126,8 @@ github.com/matterbridge/Rocket.Chat.Go.SDK v0.0.0-20190210153444-cc9d05784d5d h1
|
||||
github.com/matterbridge/Rocket.Chat.Go.SDK v0.0.0-20190210153444-cc9d05784d5d/go.mod h1:c6MxwqHD+0HvtAJjsHMIdPCiAwGiQwPRPTp69ACMg8A=
|
||||
github.com/matterbridge/discordgo v0.0.0-20191026232317-01823f4ebba4 h1:RvH3lC4bEp+bieca+Yh5xPU8tLJgnk7ridiSwMFHrrw=
|
||||
github.com/matterbridge/discordgo v0.0.0-20191026232317-01823f4ebba4/go.mod h1:O9S4p+ofTFwB02em7jkpkV8M3R0/PUVOwN61zSZ0r4Q=
|
||||
github.com/matterbridge/emoji v2.1.1-0.20191117213217-af507f6b02db+incompatible h1:oaOqwbg5HxHRxvAbd84ks0Okwoc1ISyUZ87EiVJFhGI=
|
||||
github.com/matterbridge/emoji v2.1.1-0.20191117213217-af507f6b02db+incompatible/go.mod h1:igE6rUAn3jai2wCdsjFHfhUoekjrFthoEjFObKKwSb4=
|
||||
github.com/matterbridge/go-xmpp v0.0.0-20180529212104-cd19799fba91 h1:KzDEcy8eDbTx881giW8a6llsAck3e2bJvMyKvh1IK+k=
|
||||
github.com/matterbridge/go-xmpp v0.0.0-20180529212104-cd19799fba91/go.mod h1:ECDRehsR9TYTKCAsRS8/wLeOk6UUqDydw47ln7wG41Q=
|
||||
github.com/matterbridge/gomatrix v0.0.0-20191026211822-6fc7accd00ca h1:3ypqEpFpt6vg5Sv2xxA8/v4WiSOnWMXW7DqxTxpM4XI=
|
||||
@ -173,8 +175,6 @@ github.com/pborman/uuid v0.0.0-20160216163710-c55201b03606 h1:/CPgDYrfeK2LMK6xcU
|
||||
github.com/pborman/uuid v0.0.0-20160216163710-c55201b03606/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34=
|
||||
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/peterhellberg/emojilib v0.0.0-20190124112554-c18758d55320 h1:YxcQy/DV+48NGv1lxx1vsWBzs6W1f1ogubkuCozxpX0=
|
||||
github.com/peterhellberg/emojilib v0.0.0-20190124112554-c18758d55320/go.mod h1:G7LufuPajuIvdt9OitkNt2qh0mmvD4bfRgRM7bhDIOA=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
|
2
vendor/github.com/matterbridge/emoji/.gitignore
generated
vendored
Normal file
2
vendor/github.com/matterbridge/emoji/.gitignore
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
.idea
|
||||
emoji.iml
|
21
vendor/github.com/matterbridge/emoji/LICENSE
generated
vendored
Normal file
21
vendor/github.com/matterbridge/emoji/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 kyokomi
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
53
vendor/github.com/matterbridge/emoji/README.md
generated
vendored
Normal file
53
vendor/github.com/matterbridge/emoji/README.md
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
# Emoji
|
||||
Emoji is a simple golang package.
|
||||
|
||||
[![wercker status](https://app.wercker.com/status/7bef60de2c6d3e0e6c13d56b2393c5d8/s/master "wercker status")](https://app.wercker.com/project/byKey/7bef60de2c6d3e0e6c13d56b2393c5d8)
|
||||
[![Coverage Status](https://coveralls.io/repos/kyokomi/emoji/badge.png?branch=master)](https://coveralls.io/r/kyokomi/emoji?branch=master)
|
||||
[![GoDoc](https://godoc.org/github.com/kyokomi/emoji?status.svg)](https://godoc.org/github.com/kyokomi/emoji)
|
||||
|
||||
Get it:
|
||||
|
||||
```
|
||||
go get github.com/kyokomi/emoji
|
||||
```
|
||||
|
||||
Import it:
|
||||
|
||||
```
|
||||
import (
|
||||
"github.com/kyokomi/emoji"
|
||||
)
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/kyokomi/emoji"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("Hello World Emoji!")
|
||||
|
||||
emoji.Println(":beer: Beer!!!")
|
||||
|
||||
pizzaMessage := emoji.Sprint("I like a :pizza: and :sushi:!!")
|
||||
fmt.Println(pizzaMessage)
|
||||
}
|
||||
```
|
||||
|
||||
## Demo
|
||||
|
||||
![demo](screen/image.png)
|
||||
|
||||
## Reference
|
||||
|
||||
- [GitHub EMOJI CHEAT SHEET](http://www.emoji-cheat-sheet.com/)
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/kyokomi/emoji/blob/master/LICENSE)
|
133
vendor/github.com/matterbridge/emoji/emoji.go
generated
vendored
Normal file
133
vendor/github.com/matterbridge/emoji/emoji.go
generated
vendored
Normal file
@ -0,0 +1,133 @@
|
||||
// Package emoji terminal output.
|
||||
package emoji
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"regexp"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
//go:generate generateEmojiCodeMap -pkg emoji
|
||||
|
||||
// Replace Padding character for emoji.
|
||||
const (
|
||||
ReplacePadding = ""
|
||||
)
|
||||
|
||||
// CodeMap gets the underlying map of emoji.
|
||||
func CodeMap() map[string]string {
|
||||
return emojiCodeMap
|
||||
}
|
||||
|
||||
// regular expression that matches :flag-[countrycode]:
|
||||
var flagRegexp = regexp.MustCompile(":flag-([a-z]{2}):")
|
||||
|
||||
func emojize(x string) string {
|
||||
str, ok := emojiCodeMap[x]
|
||||
if ok {
|
||||
return str + ReplacePadding
|
||||
}
|
||||
if match := flagRegexp.FindStringSubmatch(x); len(match) == 2 {
|
||||
return regionalIndicator(match[1][0]) + regionalIndicator(match[1][1])
|
||||
}
|
||||
return x
|
||||
}
|
||||
|
||||
// regionalIndicator maps a lowercase letter to a unicode regional indicator
|
||||
func regionalIndicator(i byte) string {
|
||||
return string('\U0001F1E6' + rune(i) - 'a')
|
||||
}
|
||||
|
||||
func replaseEmoji(input *bytes.Buffer) string {
|
||||
emoji := bytes.NewBufferString(":")
|
||||
for {
|
||||
i, _, err := input.ReadRune()
|
||||
if err != nil {
|
||||
// not replase
|
||||
return emoji.String()
|
||||
}
|
||||
|
||||
if i == ':' && emoji.Len() == 1 {
|
||||
return emoji.String() + replaseEmoji(input)
|
||||
}
|
||||
|
||||
emoji.WriteRune(i)
|
||||
switch {
|
||||
case unicode.IsSpace(i):
|
||||
return emoji.String()
|
||||
case i == ':':
|
||||
return emojize(emoji.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func compile(x string) string {
|
||||
if x == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
input := bytes.NewBufferString(x)
|
||||
output := bytes.NewBufferString("")
|
||||
|
||||
for {
|
||||
i, _, err := input.ReadRune()
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
switch i {
|
||||
default:
|
||||
output.WriteRune(i)
|
||||
case ':':
|
||||
output.WriteString(replaseEmoji(input))
|
||||
}
|
||||
}
|
||||
return output.String()
|
||||
}
|
||||
|
||||
// Print is fmt.Print which supports emoji
|
||||
func Print(a ...interface{}) (int, error) {
|
||||
return fmt.Print(compile(fmt.Sprint(a...)))
|
||||
}
|
||||
|
||||
// Println is fmt.Println which supports emoji
|
||||
func Println(a ...interface{}) (int, error) {
|
||||
return fmt.Println(compile(fmt.Sprint(a...)))
|
||||
}
|
||||
|
||||
// Printf is fmt.Printf which supports emoji
|
||||
func Printf(format string, a ...interface{}) (int, error) {
|
||||
return fmt.Printf(compile(fmt.Sprintf(format, a...)))
|
||||
}
|
||||
|
||||
// Fprint is fmt.Fprint which supports emoji
|
||||
func Fprint(w io.Writer, a ...interface{}) (int, error) {
|
||||
return fmt.Fprint(w, compile(fmt.Sprint(a...)))
|
||||
}
|
||||
|
||||
// Fprintln is fmt.Fprintln which supports emoji
|
||||
func Fprintln(w io.Writer, a ...interface{}) (int, error) {
|
||||
return fmt.Fprintln(w, compile(fmt.Sprint(a...)))
|
||||
}
|
||||
|
||||
// Fprintf is fmt.Fprintf which supports emoji
|
||||
func Fprintf(w io.Writer, format string, a ...interface{}) (int, error) {
|
||||
return fmt.Fprint(w, compile(fmt.Sprintf(format, a...)))
|
||||
}
|
||||
|
||||
// Sprint is fmt.Sprint which supports emoji
|
||||
func Sprint(a ...interface{}) string {
|
||||
return compile(fmt.Sprint(a...))
|
||||
}
|
||||
|
||||
// Sprintf is fmt.Sprintf which supports emoji
|
||||
func Sprintf(format string, a ...interface{}) string {
|
||||
return compile(fmt.Sprintf(format, a...))
|
||||
}
|
||||
|
||||
// Errorf is fmt.Errorf which supports emoji
|
||||
func Errorf(format string, a ...interface{}) error {
|
||||
return errors.New(compile(Sprintf(format, a...)))
|
||||
}
|
4114
vendor/github.com/matterbridge/emoji/emoji_codemap.go
generated
vendored
Normal file
4114
vendor/github.com/matterbridge/emoji/emoji_codemap.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
25
vendor/github.com/matterbridge/emoji/wercker.yml
generated
vendored
Normal file
25
vendor/github.com/matterbridge/emoji/wercker.yml
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
box: golang
|
||||
build:
|
||||
steps:
|
||||
- setup-go-workspace
|
||||
- script:
|
||||
name: install goveralls
|
||||
code: |
|
||||
go get github.com/mattn/goveralls
|
||||
- script:
|
||||
name: go get
|
||||
code: |
|
||||
go get ./...
|
||||
- script:
|
||||
name: go build
|
||||
code: |
|
||||
go build ./...
|
||||
- script:
|
||||
name: go test
|
||||
code: |
|
||||
go test ./...
|
||||
- script:
|
||||
name: coveralls
|
||||
code: |
|
||||
goveralls -v -service wercker.com -repotoken $COVERALLS_TOKEN
|
||||
|
26
vendor/github.com/matterbridge/gomatrix/tags.go
generated
vendored
Normal file
26
vendor/github.com/matterbridge/gomatrix/tags.go
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright 2019 Sumukha PK
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package gomatrix
|
||||
|
||||
// TagContent contains the data for an m.tag message type
|
||||
// https://matrix.org/docs/spec/client_server/r0.4.0.html#m-tag
|
||||
type TagContent struct {
|
||||
Tags map[string]TagProperties `json:"tags"`
|
||||
}
|
||||
|
||||
// TagProperties contains the properties of a Tag
|
||||
type TagProperties struct {
|
||||
Order float32 `json:"order,omitempty"` // Empty values must be neglected
|
||||
}
|
10
vendor/github.com/peterhellberg/emojilib/.travis.yml
generated
vendored
10
vendor/github.com/peterhellberg/emojilib/.travis.yml
generated
vendored
@ -1,10 +0,0 @@
|
||||
language: go
|
||||
|
||||
dist: xenial
|
||||
|
||||
go:
|
||||
- "1.11.5"
|
||||
- "1.10.8"
|
||||
|
||||
script:
|
||||
- go test ./...
|
19
vendor/github.com/peterhellberg/emojilib/LICENSE
generated
vendored
19
vendor/github.com/peterhellberg/emojilib/LICENSE
generated
vendored
@ -1,19 +0,0 @@
|
||||
Copyright (c) 2015-2019 Peter Hellberg https://c7.se
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
61
vendor/github.com/peterhellberg/emojilib/README.md
generated
vendored
61
vendor/github.com/peterhellberg/emojilib/README.md
generated
vendored
@ -1,61 +0,0 @@
|
||||
# :book: emojilib
|
||||
|
||||
[![Build Status](https://travis-ci.org/peterhellberg/emojilib.svg?branch=master)](https://travis-ci.org/peterhellberg/emojilib)
|
||||
[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/peterhellberg/emojilib)
|
||||
[![License MIT](https://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat)](https://github.com/peterhellberg/emojilib#license-mit)
|
||||
|
||||
The [Emoji keyword library](https://github.com/muan/emojilib) by [@muan](https://github.com/muan/) ported to Go. (using `go generate`)
|
||||
|
||||
## Installation
|
||||
|
||||
go get -u github.com/peterhellberg/emojilib
|
||||
|
||||
## Usage
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/peterhellberg/emojilib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println(emojilib.ReplaceWithPadding("I :green_heart: You!"))
|
||||
}
|
||||
```
|
||||
|
||||
## Generating a new version
|
||||
|
||||
```bash
|
||||
$ go generate
|
||||
```
|
||||
|
||||
This will download the latest version of [emojis.json](https://raw.githubusercontent.com/muan/emojilib/master/emojis.json)
|
||||
and generate a new version of `generated.go`
|
||||
|
||||
_You’ll need to have the [golang.org/x/tools/imports](https://golang.org/x/tools/imports) package installed in order to run the generator._
|
||||
|
||||
## License (MIT)
|
||||
|
||||
Copyright (c) 2015-2019 [Peter Hellberg](https://c7.se)
|
||||
|
||||
> Permission is hereby granted, free of charge, to any person obtaining
|
||||
> a copy of this software and associated documentation files (the
|
||||
> "Software"), to deal in the Software without restriction, including
|
||||
> without limitation the rights to use, copy, modify, merge, publish,
|
||||
> distribute, sublicense, and/or sell copies of the Software, and to
|
||||
> permit persons to whom the Software is furnished to do so, subject to
|
||||
> the following conditions:
|
||||
|
||||
> The above copyright notice and this permission notice shall be
|
||||
> included in all copies or substantial portions of the Software.
|
||||
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
> NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
> LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
> OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
> WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
88
vendor/github.com/peterhellberg/emojilib/emojilib.go
generated
vendored
88
vendor/github.com/peterhellberg/emojilib/emojilib.go
generated
vendored
@ -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)
|
||||
}
|
20414
vendor/github.com/peterhellberg/emojilib/generated.go
generated
vendored
20414
vendor/github.com/peterhellberg/emojilib/generated.go
generated
vendored
File diff suppressed because it is too large
Load Diff
4
vendor/modules.txt
vendored
4
vendor/modules.txt
vendored
@ -104,6 +104,8 @@ github.com/magiconair/properties
|
||||
github.com/matterbridge/Rocket.Chat.Go.SDK/models
|
||||
github.com/matterbridge/Rocket.Chat.Go.SDK/realtime
|
||||
github.com/matterbridge/Rocket.Chat.Go.SDK/rest
|
||||
# github.com/matterbridge/emoji v2.1.1-0.20191117213217-af507f6b02db+incompatible
|
||||
github.com/matterbridge/emoji
|
||||
# github.com/matterbridge/go-xmpp v0.0.0-20180529212104-cd19799fba91
|
||||
github.com/matterbridge/go-xmpp
|
||||
# github.com/matterbridge/gomatrix v0.0.0-20191026211822-6fc7accd00ca
|
||||
@ -148,8 +150,6 @@ github.com/paulrosania/go-charset/data
|
||||
github.com/pborman/uuid
|
||||
# github.com/pelletier/go-toml v1.2.0
|
||||
github.com/pelletier/go-toml
|
||||
# github.com/peterhellberg/emojilib v0.0.0-20190124112554-c18758d55320
|
||||
github.com/peterhellberg/emojilib
|
||||
# github.com/pkg/errors v0.8.1
|
||||
github.com/pkg/errors
|
||||
# github.com/pmezard/go-difflib v1.0.0
|
||||
|
Loading…
Reference in New Issue
Block a user