Make golangci-lint happy
This commit is contained in:
parent
5afd40fc63
commit
2b17a3c193
@ -135,12 +135,12 @@ func (b *Bmumble) extractFiles(msg *config.Message) []config.Message {
|
|||||||
mimeType = strings.TrimSpace(strings.Split(mimeType, ";")[0])
|
mimeType = strings.TrimSpace(strings.Split(mimeType, ";")[0])
|
||||||
// Build data:image/...;base64,... style image URL and embed image directly into the message
|
// Build data:image/...;base64,... style image URL and embed image directly into the message
|
||||||
du := dataurl.New(*fi.Data, mimeType)
|
du := dataurl.New(*fi.Data, mimeType)
|
||||||
url, err := du.MarshalText()
|
dataURL, err := du.MarshalText()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Log.WithError(err).Infof("Image Serialization into data URL failed (type: %s, length: %d)", mimeType, len(*fi.Data))
|
b.Log.WithError(err).Infof("Image Serialization into data URL failed (type: %s, length: %d)", mimeType, len(*fi.Data))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
imsg.Text = fmt.Sprintf(`<img src="%s"/>`, url)
|
imsg.Text = fmt.Sprintf(`<img src="%s"/>`, dataURL)
|
||||||
messages = append(messages, imsg)
|
messages = append(messages, imsg)
|
||||||
}
|
}
|
||||||
// Remove files from original message
|
// Remove files from original message
|
||||||
@ -150,16 +150,19 @@ func (b *Bmumble) extractFiles(msg *config.Message) []config.Message {
|
|||||||
|
|
||||||
func (b *Bmumble) parseChannelPath(client *gumble.Client, name string) ([]string, error) {
|
func (b *Bmumble) parseChannelPath(client *gumble.Client, name string) ([]string, error) {
|
||||||
if strings.HasPrefix(name, "ID:") {
|
if strings.HasPrefix(name, "ID:") {
|
||||||
if channelId, err := strconv.ParseUint(name[3:], 10, 32); err == nil {
|
// Parse the ID string into an int
|
||||||
if c, ok := client.Channels[uint32(channelId)]; ok {
|
channelID, err := strconv.ParseUint(name[3:], 10, 32)
|
||||||
return gumbleutil.ChannelPath(c)[1:], nil
|
if err != nil {
|
||||||
}
|
|
||||||
b.Log.Fatalf("No channel with ID %d", channelId)
|
|
||||||
return nil, errors.New("no such channel: " + name)
|
|
||||||
} else {
|
|
||||||
b.Log.WithError(err).Fatalf("Cannot parse channel ID: %s", name)
|
b.Log.WithError(err).Fatalf("Cannot parse channel ID: %s", name)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
// Verify that the ID refers to an existing channel
|
||||||
|
c, ok := client.Channels[uint32(channelID)]
|
||||||
|
if !ok {
|
||||||
|
b.Log.Fatalf("No channel with ID %d", channelID)
|
||||||
|
return nil, errors.New("no such channel: " + name)
|
||||||
|
}
|
||||||
|
return gumbleutil.ChannelPath(c)[1:], nil
|
||||||
} else {
|
} else {
|
||||||
if !strings.HasPrefix(name, "/") {
|
if !strings.HasPrefix(name, "/") {
|
||||||
return nil, errors.New("channel path must start with a '/': " + name)
|
return nil, errors.New("channel path must start with a '/': " + name)
|
||||||
@ -168,7 +171,7 @@ func (b *Bmumble) parseChannelPath(client *gumble.Client, name string) ([]string
|
|||||||
if name == "/" {
|
if name == "/" {
|
||||||
return make([]string, 0), nil
|
return make([]string, 0), nil
|
||||||
}
|
}
|
||||||
// Discard first token, which is the empty string before the leading /
|
// Iterate all path components, discarding the first token, which is the empty string before the leading /
|
||||||
tokens := strings.Split(name, "/")
|
tokens := strings.Split(name, "/")
|
||||||
var channelPath []string
|
var channelPath []string
|
||||||
for _, token := range tokens[1:] {
|
for _, token := range tokens[1:] {
|
||||||
|
@ -193,7 +193,7 @@ func (b *Bmumble) doConnect() error {
|
|||||||
func (b *Bmumble) doJoin(client *gumble.Client, channelPath []string) error {
|
func (b *Bmumble) doJoin(client *gumble.Client, channelPath []string) error {
|
||||||
c := client.Channels.Find(channelPath...)
|
c := client.Channels.Find(channelPath...)
|
||||||
if c == nil {
|
if c == nil {
|
||||||
return errors.New(fmt.Sprintf("no such channel: %v", channelPath))
|
return fmt.Errorf("no such channel: %v", channelPath)
|
||||||
}
|
}
|
||||||
b.Channel = gumbleutil.ChannelPath(c)[1:]
|
b.Channel = gumbleutil.ChannelPath(c)[1:]
|
||||||
client.Self.Move(c)
|
client.Self.Move(c)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user