Update vendor (#1446)

* Update vendor

* Use upstream emoji lib again
This commit is contained in:
Wim
2021-04-03 19:16:46 +02:00
committed by GitHub
parent d3b60cc445
commit 21eb37e471
40 changed files with 8088 additions and 5397 deletions

View File

@@ -77,8 +77,8 @@ type Attachment struct {
// https://rocket.chat/docs/developer-guides/rest-api/chat/postmessage/
type AttachmentField struct {
Short bool `json:"short"`
Title string `json:"title"`
Value string `json:"value"`
Title string `json:"title,omitempty"`
Value string `json:"value,omitempty"`
}
type AttachmentActionType string
@@ -89,15 +89,15 @@ const (
// AttachmentAction are action buttons on message attachments
type AttachmentAction struct {
Type AttachmentActionType `json:"type"`
Text string `json:"text"`
Url string `json:"url"`
ImageURL string `json:"image_url"`
Type AttachmentActionType `json:"type,omitempty"`
Text string `json:"text,omitempty"`
Url string `json:"url,omitempty"`
ImageURL string `json:"image_url,omitempty"`
IsWebView bool `json:"is_webview"`
WebviewHeightRatio string `json:"webview_height_ratio"`
Msg string `json:"msg"`
WebviewHeightRatio string `json:"webview_height_ratio,omitempty"`
Msg string `json:"msg,omitempty"`
MsgInChatWindow bool `json:"msg_in_chat_window"`
MsgProcessingType MessageProcessingType `json:"msg_processing_type"`
MsgProcessingType MessageProcessingType `json:"msg_processing_type,omitempty"`
}
// AttachmentActionButtonAlignment configures how the actions buttons will be aligned

View File

@@ -19,6 +19,17 @@ type ChannelResponse struct {
Channel models.Channel `json:"channel"`
}
type GroupsResponse struct {
Status
models.Pagination
Groups []models.Channel `json:"groups"`
}
type GroupResponse struct {
Status
Group models.Channel `json:"group"`
}
// GetPublicChannels returns all channels that can be seen by the logged in user.
//
// https://rocket.chat/docs/developer-guides/rest-api/channels/list
@@ -31,6 +42,19 @@ func (c *Client) GetPublicChannels() (*ChannelsResponse, error) {
return response, nil
}
// GetPrivateGroups returns all channels that can be seen by the logged in user.
//
// https://rocket.chat/docs/developer-guides/rest-api/groups/list
func (c *Client) GetPrivateGroups() (*GroupsResponse, error) {
response := new(GroupsResponse)
if err := c.Get("groups.list", nil, response); err != nil {
return nil, err
}
return response, nil
}
// GetJoinedChannels returns all channels that the user has joined.
//
// https://rocket.chat/docs/developer-guides/rest-api/channels/list-joined
@@ -70,3 +94,20 @@ func (c *Client) GetChannelInfo(channel *models.Channel) (*models.Channel, error
return &response.Channel, nil
}
// GetGroupInfo get information about a group. That might be useful to update the usernames.
//
// https://rocket.chat/docs/developer-guides/rest-api/groups/info
func (c *Client) GetGroupInfo(channel *models.Channel) (*models.Channel, error) {
response := new(GroupResponse)
switch {
case channel.Name != "" && channel.ID == "":
if err := c.Get("groups.info", url.Values{"roomName": []string{channel.Name}}, response); err != nil {
return nil, err
}
default:
if err := c.Get("groups.info", url.Values{"roomId": []string{channel.ID}}, response); err != nil {
return nil, err
}
}
return &response.Group, nil
}

View File

@@ -1,2 +0,0 @@
.idea
emoji.iml

View File

@@ -1,21 +0,0 @@
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.

View File

@@ -1,53 +0,0 @@
# 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)

View File

@@ -1,133 +0,0 @@
// 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...)))
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,25 +0,0 @@
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