4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-07-05 00:04:04 +00:00

Use mod vendor for vendored directory (backwards compatible)

This commit is contained in:
Wim
2018-08-06 21:47:05 +02:00
parent 4fb4b7aa6c
commit 51062863a5
1112 changed files with 15660 additions and 420183 deletions

8
vendor/github.com/peterhellberg/emojilib/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,8 @@
language: go
go:
- 1.8
- 1.7.5
- 1.6.4
sudo: false

61
vendor/github.com/peterhellberg/emojilib/README.md generated vendored Normal file
View File

@ -0,0 +1,61 @@
# :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`
_Youll 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-2017 [Peter Hellberg](http://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.

View File

@ -1,117 +0,0 @@
package giphy
import (
"encoding/json"
"fmt"
"net/http"
"net/url"
)
// DefaultClient is the default Giphy API client
var DefaultClient = NewClient()
// PublicBetaKey is the public beta key for the Giphy API
var PublicBetaKey = "dc6zaTOxFJmzC"
// A Client communicates with the Giphy API.
type Client struct {
// APIKey is the key used for requests to the Giphy API
APIKey string
// Limit is the limit used for requests to the Giphy API
Limit int
// Rating is the rating used for requests to the Giphy API
Rating string
// BaseURL is the base url for Giphy API.
BaseURL *url.URL
// BasePath is the base path for the gifs endpoints
BasePath string
// User agent used for HTTP requests to Giphy API.
UserAgent string
// HTTP client used to communicate with the Giphy API.
httpClient *http.Client
}
// NewClient returns a new Giphy API client.
// If no *http.Client were provided then http.DefaultClient is used.
func NewClient(httpClients ...*http.Client) *Client {
var httpClient *http.Client
if len(httpClients) > 0 && httpClients[0] != nil {
httpClient = httpClients[0]
} else {
cloned := *http.DefaultClient
httpClient = &cloned
}
c := &Client{
APIKey: Env("GIPHY_API_KEY", PublicBetaKey),
Rating: Env("GIPHY_RATING", "g"),
Limit: EnvInt("GIPHY_LIMIT", 10),
BaseURL: &url.URL{
Scheme: Env("GIPHY_BASE_URL_SCHEME", "https"),
Host: Env("GIPHY_BASE_URL_HOST", "api.giphy.com"),
},
BasePath: Env("GIPHY_BASE_PATH", "/v1"),
UserAgent: Env("GIPHY_USER_AGENT", "giphy.go"),
httpClient: httpClient,
}
return c
}
// NewRequest creates an API request.
func (c *Client) NewRequest(s string) (*http.Request, error) {
rel, err := url.Parse(c.BasePath + s)
if err != nil {
return nil, err
}
q := rel.Query()
q.Set("api_key", c.APIKey)
q.Set("rating", c.Rating)
rel.RawQuery = q.Encode()
u := c.BaseURL.ResolveReference(rel)
if EnvBool("GIPHY_VERBOSE", false) {
fmt.Println("giphy: GET", u.String())
}
req, err := http.NewRequest("GET", u.String(), nil)
if err != nil {
return nil, err
}
req.Header.Add("User-Agent", c.UserAgent)
return req, nil
}
// Do sends an API request and returns the API response. The API response is
// decoded and stored in the value pointed to by v, or returned as an error if
// an API error has occurred.
func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error) {
// Make sure to close the connection after replying to this request
req.Close = true
resp, err := c.httpClient.Do(req)
if err != nil {
return resp, err
}
defer resp.Body.Close()
if v != nil {
err = json.NewDecoder(resp.Body).Decode(v)
}
if err != nil {
return nil, fmt.Errorf("error reading response from %s %s: %s", req.Method, req.URL.RequestURI(), err)
}
return resp, nil
}

View File

@ -1,140 +0,0 @@
/*
A command line client for the Giphy API
Installation
Just go get the command:
go get -u github.com/peterhellberg/giphy/cmd/giphy
Configuration
The command line client can be used straight out of the box, but
there are also a few environment variables that you can use in order
to override the default configuration.
Environment variable | Default value
----------------------|--------------
GIPHY_API_KEY | dc6zaTOxFJmzC
GIPHY_RATING | g
GIPHY_LIMIT | 10
GIPHY_BASE_URL_SCHEME | http
GIPHY_BASE_URL_HOST | api.giphy.com
GIPHY_BASE_PATH | /v1
GIPHY_USER_AGENT | giphy.go
Usage
The command line client consists of a few sub commands.
Commands:
search, s [args]
gif, id [args]
random, rand, r [args]
translate, trans, t [args]
trending, trend, tr [args]
*/
package main
import (
"fmt"
"os"
"strings"
"github.com/peterhellberg/giphy"
)
func main() {
g := giphy.DefaultClient
if len(os.Args) < 2 {
fmt.Println(strings.Join([]string{
"Commands:",
"search, s [args]",
"gif, id [args]",
"random, rand, r [args]",
"translate, trans, t [args]",
"trending, trend, tr [args]",
}, "\n\t"))
return
}
args := os.Args[1:]
switch args[0] {
default:
search(g, args)
case "search", "s":
search(g, args[1:])
case "gif", "id":
gif(g, args[1:])
case "random", "rand", "r":
random(g, args[1:])
case "translate", "trans", "t":
translate(g, args[1:])
case "trending", "trend", "tr":
trending(g, args[1:])
}
}
func search(c *giphy.Client, args []string) {
res, err := c.Search(args)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
for _, d := range res.Data {
fmt.Println(d.Images.Original.URL)
}
}
func gif(c *giphy.Client, args []string) {
if len(args) == 0 {
fmt.Println("missing Giphy id")
os.Exit(1)
}
res, err := c.GIF(args[0])
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Println(res.Data.Images.Original.URL)
}
func random(c *giphy.Client, args []string) {
res, err := c.Random(args)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Println(res.Data.ImageOriginalURL)
}
func translate(c *giphy.Client, args []string) {
res, err := c.Translate(args)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Println(res.Data.Images.Original.URL)
}
func trending(c *giphy.Client, args []string) {
res, err := c.Trending(args)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
for _, d := range res.Data {
fmt.Println(d.Images.Original.URL)
}
}

View File

@ -1,34 +0,0 @@
package giphy
import (
"os"
"strconv"
)
// Env returns a string from the ENV, or fallback variable
func Env(key, fallback string) string {
v := os.Getenv(key)
if v != "" {
return v
}
return fallback
}
// EnvBool returns a bool from the ENV, or fallback variable
func EnvBool(key string, fallback bool) bool {
if b, err := strconv.ParseBool(os.Getenv(key)); err == nil {
return b
}
return fallback
}
// EnvInt returns an int from the ENV, or fallback variable
func EnvInt(key string, fallback int) int {
if i, err := strconv.Atoi(os.Getenv(key)); err == nil {
return i
}
return fallback
}

View File

@ -1,17 +0,0 @@
package giphy
import "errors"
var (
// ErrNoImageFound is the error returned when no image was found
ErrNoImageFound = errors.New("no image found")
// ErrUnknown is used for unknown errors from the Giphy API
ErrUnknown = errors.New("unknown error")
// ErrNoTrendingImagesFound is returned when no trending images were found
ErrNoTrendingImagesFound = errors.New("no trending images found")
// ErrNoRawData is returned if there was no data property in response
ErrNoRawData = errors.New("no raw data")
)

View File

@ -1,44 +0,0 @@
package giphy
import (
"encoding/json"
"fmt"
"strings"
)
// GIF returns a ID response from the Giphy API
func (c *Client) GIF(id string) (GIF, error) {
if strings.ContainsAny(id, "/&?") {
return GIF{}, fmt.Errorf("Invalid giphy id: `%v`", id)
}
req, err := c.NewRequest("/gifs/" + id)
if err != nil {
return GIF{}, err
}
var gif GIF
if _, err = c.Do(req, &gif); err != nil {
return GIF{}, err
}
if gif.RawData == nil || gif.RawData[0] == '[' {
return GIF{}, ErrNoImageFound
}
// Check if the first character in Data is a {
if gif.RawData[0] == '{' {
var d Data
err = json.Unmarshal(gif.RawData, &d)
if err != nil {
return GIF{}, err
}
gif.Data = d
return gif, nil
}
return GIF{}, ErrUnknown
}

View File

@ -1,37 +0,0 @@
package giphy
import (
"encoding/json"
"strings"
)
// Random returns a random response from the Giphy API
func (c *Client) Random(args []string) (Random, error) {
argsStr := strings.Join(args, " ")
req, err := c.NewRequest("/gifs/random?tag=" + argsStr)
if err != nil {
return Random{}, err
}
var random Random
if _, err = c.Do(req, &random); err != nil {
return Random{}, err
}
// Check if the first character in Data is a [
if random.RawData == nil || random.RawData[0] == '[' {
return Random{}, ErrNoImageFound
}
var d RandomData
err = json.Unmarshal(random.RawData, &d)
if err != nil {
return Random{}, err
}
random.Data = d
return random, nil
}

View File

@ -1,24 +0,0 @@
package giphy
import (
"fmt"
"strings"
)
// Search returns a search response from the Giphy API
func (c *Client) Search(args []string) (Search, error) {
argsStr := strings.Join(args, " ")
path := fmt.Sprintf("/gifs/search?limit=%v&q=%s", c.Limit, argsStr)
req, err := c.NewRequest(path)
if err != nil {
return Search{}, err
}
var search Search
if _, err = c.Do(req, &search); err != nil {
return Search{}, err
}
return search, nil
}

View File

@ -1,37 +0,0 @@
package giphy
import (
"encoding/json"
"strings"
)
// Translate returns a translate response from the Giphy API
func (c *Client) Translate(args []string) (Translate, error) {
argsStr := strings.Join(args, " ")
req, err := c.NewRequest("/gifs/translate?s=" + argsStr)
if err != nil {
return Translate{}, err
}
var translate Translate
if _, err = c.Do(req, &translate); err != nil {
return Translate{}, err
}
if len(translate.RawData) == 0 {
return Translate{}, ErrNoRawData
}
// Check if the first character in Data is a [
if translate.RawData[0] == '[' {
return Translate{}, ErrNoImageFound
}
err = json.Unmarshal(translate.RawData, &translate.Data)
if err != nil {
return Translate{}, err
}
return translate, nil
}

View File

@ -1,23 +0,0 @@
package giphy
import "fmt"
// Trending returns a trending response from the Giphy API
func (c *Client) Trending(args ...[]string) (Trending, error) {
path := fmt.Sprintf("/gifs/trending?limit=%v", c.Limit)
req, err := c.NewRequest(path)
if err != nil {
return Trending{}, err
}
var res Trending
if _, err = c.Do(req, &res); err != nil {
return res, err
}
if len(res.Data) == 0 {
return res, ErrNoTrendingImagesFound
}
return res, nil
}

View File

@ -1,116 +0,0 @@
package giphy
import "encoding/json"
// Search represents a search response from the Giphy API
type Search struct {
Data []Data `json:"data"`
Meta Meta `json:"meta"`
Pagination Pagination `json:"pagination"`
}
// GIF represents a ID response from the Giphy API
type GIF struct {
Data Data
RawData json.RawMessage `json:"data"`
Meta Meta `json:"meta"`
}
// Random represents a random response from the Giphy API
type Random struct {
Data RandomData
RawData json.RawMessage `json:"data"`
Meta Meta `json:"meta"`
}
// Translate represents a translate response from the Giphy API
type Translate struct {
Data
RawData json.RawMessage `json:"data"`
Meta Meta `json:"meta"`
}
// Trending represents a trending response from the Giphy API
type Trending struct {
Data []Data `json:"data"`
Meta Meta `json:"meta"`
Pagination Pagination `json:"pagination"`
}
// Data contains all the fields in a data response from the Giphy API
type Data struct {
Type string `json:"type"`
ID string `json:"id"`
URL string `json:"url"`
BitlyGifURL string `json:"bitly_gif_url"`
BitlyURL string `json:"bitly_url"`
EmbedURL string `json:"embed_url"`
Username string `json:"username"`
Source string `json:"source"`
Rating string `json:"rating"`
Caption string `json:"caption"`
ContentURL string `json:"content_url"`
ImportDatetime string `json:"import_datetime"`
TrendingDatetime string `json:"trending_datetime"`
Images Images `json:"images"`
}
// RandomData represents data section in random response from the Giphy API
type RandomData struct {
Type string `json:"type"`
ID string `json:"id"`
URL string `json:"url"`
ImageOriginalURL string `json:"image_original_url"`
ImageURL string `json:"image_url"`
ImageMp4URL string `json:"image_mp4_url"`
ImageFrames string `json:"image_frames"`
ImageWidth string `json:"image_width"`
ImageHeight string `json:"image_height"`
FixedHeightDownsampledURL string `json:"fixed_height_downsampled_url"`
FixedHeightDownsampledWidth string `json:"fixed_height_downsampled_width"`
FixedHeightDownsampledHeight string `json:"fixed_height_downsampled_height"`
FixedWidthDownsampledURL string `json:"fixed_width_downsampled_url"`
FixedWidthDownsampledWidth string `json:"fixed_width_downsampled_width"`
FixedWidthDownsampledHeight string `json:"fixed_width_downsampled_height"`
Rating string `json:"rating"`
Username string `json:"username"`
Caption string `json:"caption"`
Tags []string `json:"tags"`
}
// Images represents all the different types of images
type Images struct {
FixedHeight Image `json:"fixed_height"`
FixedHeightStill Image `json:"fixed_height_still"`
FixedHeightDownsampled Image `json:"fixed_height_downsampled"`
FixedWidth Image `json:"fixed_width"`
FixedWidthStill Image `json:"fixed_width_still"`
FixedWidthDownsampled Image `json:"fixed_width_downsampled"`
Downsized Image `json:"downsized"`
DownsizedStill Image `json:"downsized_still"`
Original Image `json:"original"`
OriginalStill Image `json:"original_still"`
}
// Image represents an image
type Image struct {
URL string `json:"url"`
Width string `json:"width"`
Height string `json:"height"`
Size string `json:"size,omitempty"`
Frames string `json:"frames,omitempty"`
Mp4 string `json:"mp4,omitempty"`
}
// Pagination represents the pagination section in a Giphy API response
type Pagination struct {
TotalCount int `json:"total_count"`
Count int `json:"count"`
Offset int `json:"offset"`
}
// Meta represents the meta section in a Giphy API response
type Meta struct {
Status int `json:"status"`
Msg string `json:"msg"`
}