Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ name: Development
on:
push:
paths-ignore:
- 'docs/**'
- 'README.md'
- "docs/**"
- "README.md"
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- "docs/**"
- "README.md"
permissions:
contents: read
pull-requests: read
Expand All @@ -19,19 +19,19 @@ jobs:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: 1.24.x
go-version: 1.25.x
- name: golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: v2.1
version: v2.6
# Only compare with previous commit when pushing,
# and with base branch when in PR.
only-new-issues: true
test:
strategy:
matrix:
# Test on latest release and v1.24
go-version: [1.24.x, stable]
go-version: [1.25.x, stable]
runs-on: ubuntu-latest
steps:
- name: Install Go
Expand All @@ -46,7 +46,7 @@ jobs:
run: go test ./...
build-upload:
# Uploading artifacts only if lint/test succeeded
needs: [ "lint", "test" ]
needs: ["lint", "test"]
strategy:
matrix:
arch: [amd64]
Expand All @@ -67,7 +67,7 @@ jobs:
uses: actions/checkout@v5
- name: Build/upload matterbridge for ${{ matrix.platform.goos }}-${{ matrix.arch }}
run: |
CGO_ENABLED=0 GOOS=${{ matrix.platform.goos }} GOARCH=${{ matrix.arch }} go build -ldflags "-s -X github.com/42wim/matterbridge/version.GitHash=$(git log --pretty=format:'%h' -n 1)" -o matterbridge
CGO_ENABLED=0 GOOS=${{ matrix.platform.goos }} GOARCH=${{ matrix.arch }} go build -ldflags "-s -X github.com/matterbridge-org/matterbridge/version.GitHash=$(git log --pretty=format:'%h' -n 1)" -o matterbridge
- name: Upload matterbridge-${{ matrix.name }}-${{ matrix.arch }}
uses: actions/upload-artifact@v4
with:
Expand Down
11 changes: 9 additions & 2 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: "2"

# options for analysis running
run:
go: "1.22"
go: "1.25"

# which dirs to skip: they won't be analyzed;
# can use regexp here: generated.*, regexp is applied on full path;
Expand All @@ -23,7 +23,7 @@ output:

# linters that we should / shouldn't run
linters:
default: all
default: standard
disable:
- gochecknoglobals
- lll
Expand All @@ -32,7 +32,12 @@ linters:
- godox
- testpackage
- godot
- errcheck
- containedctx
- unused
- goheader
- wsl_v5
- gochecknoinits
- noctx
- errorlint
- nlreturn
Expand Down Expand Up @@ -65,6 +70,8 @@ linters:
# all available settings of specific linters, we can set an option for
# a given linter even if we deactivate that same linter at runtime
settings:
staticcheck:
checks: [ "all", "-QF1001", "-ST1020", "-ST1000"]
errcheck:
# report about not checking of errors in type assertions: `a := b.(MyStruct)`;
# default is false: such cases aren't reported by default.
Expand Down
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ builds:
- 6
- 7
ldflags:
- -s -w -X github.com/42wim/matterbridge/version.GitHash={{.ShortCommit}}
- -s -w -X github.com/matterbridge-org/matterbridge/version.GitHash={{.ShortCommit}}

archives:
-
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM alpine AS builder
COPY . /go/src/matterbridge
RUN apk --no-cache add go git \
&& cd /go/src/matterbridge \
&& CGO_ENABLED=0 go build -ldflags "-X github.com/42wim/matterbridge/version.GitHash=$(git log --pretty=format:'%h' -n 1)" -o /bin/matterbridge
&& CGO_ENABLED=0 go build -ldflags "-X github.com/matterbridge-org/matterbridge/version.GitHash=$(git log --pretty=format:'%h' -n 1)" -o /bin/matterbridge

FROM alpine
RUN apk --no-cache add ca-certificates mailcap
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile_whatsappmulti
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM alpine AS builder
COPY . /go/src/matterbridge
RUN apk --no-cache add go git \
&& cd /go/src/matterbridge \
&& CGO_ENABLED=0 go build -tags whatsappmulti -mod vendor -ldflags "-X github.com/42wim/matterbridge/version.GitHash=$(git log --pretty=format:'%h' -n 1)" -o /bin/matterbridge
&& CGO_ENABLED=0 go build -tags whatsappmulti -mod vendor -ldflags "-X github.com/matterbridge-org/matterbridge/version.GitHash=$(git log --pretty=format:'%h' -n 1)" -o /bin/matterbridge

FROM alpine
RUN apk --no-cache add ca-certificates mailcap
Expand Down
4 changes: 2 additions & 2 deletions bridge/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (

"github.com/olahol/melody"

"github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/config"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/matterbridge-org/matterbridge/bridge"
"github.com/matterbridge-org/matterbridge/bridge/config"
"github.com/mitchellh/mapstructure"
ring "github.com/zfjagann/golang-ring"
)
Expand Down
2 changes: 1 addition & 1 deletion bridge/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"sync"
"time"

"github.com/42wim/matterbridge/bridge/config"
"github.com/matterbridge-org/matterbridge/bridge/config"
"github.com/sirupsen/logrus"
)

Expand Down
9 changes: 4 additions & 5 deletions bridge/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package config

import (
"bytes"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -260,7 +259,7 @@ func NewConfig(rootLogger *logrus.Logger, cfgfile string) Config {
logger := rootLogger.WithFields(logrus.Fields{"prefix": "config"})

viper.SetConfigFile(cfgfile)
input, err := ioutil.ReadFile(cfgfile)
input, err := os.ReadFile(cfgfile)
if err != nil {
logger.Fatalf("Failed to read configuration file: %#v", err)
}
Expand Down Expand Up @@ -386,9 +385,9 @@ func GetIconURL(msg *Message, iconURL string) string {
info := strings.Split(msg.Account, ".")
protocol := info[0]
name := info[1]
iconURL = strings.Replace(iconURL, "{NICK}", msg.Username, -1)
iconURL = strings.Replace(iconURL, "{BRIDGE}", name, -1)
iconURL = strings.Replace(iconURL, "{PROTOCOL}", protocol, -1)
iconURL = strings.ReplaceAll(iconURL, "{NICK}", msg.Username)
iconURL = strings.ReplaceAll(iconURL, "{BRIDGE}", name)
iconURL = strings.ReplaceAll(iconURL, "{PROTOCOL}", protocol)
return iconURL
}

Expand Down
14 changes: 7 additions & 7 deletions bridge/discord/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (
"strings"
"sync"

"github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/config"
"github.com/42wim/matterbridge/bridge/discord/transmitter"
"github.com/42wim/matterbridge/bridge/helper"
"github.com/bwmarrin/discordgo"
lru "github.com/hashicorp/golang-lru"
"github.com/matterbridge-org/matterbridge/bridge"
"github.com/matterbridge-org/matterbridge/bridge/config"
"github.com/matterbridge-org/matterbridge/bridge/discord/transmitter"
"github.com/matterbridge-org/matterbridge/bridge/helper"
)

const (
Expand Down Expand Up @@ -73,7 +73,7 @@ func (b *Bdiscord) Connect() error {
}
// if we have a User token, remove the `Bot` prefix
if strings.HasPrefix(b.GetString("Token"), "User ") {
token = strings.Replace(b.GetString("Token"), "User ", "", -1)
token = strings.ReplaceAll(b.GetString("Token"), "User ", "")
}

b.c, err = discordgo.New(token)
Expand All @@ -98,7 +98,7 @@ func (b *Bdiscord) Connect() error {
if err != nil {
return err
}
serverName := strings.Replace(b.GetString("Server"), "ID:", "", -1)
serverName := strings.ReplaceAll(b.GetString("Server"), "ID:", "")
b.nick = userinfo.Username
b.userID = userinfo.ID

Expand Down Expand Up @@ -255,7 +255,7 @@ func (b *Bdiscord) Send(msg config.Message) (string, error) {

channelID := b.getChannelID(msg.Channel)
if channelID == "" {
return "", fmt.Errorf("Could not find channelID for %v", msg.Channel)
return "", fmt.Errorf("could not find channelID for %v", msg.Channel)
}

if msg.Event == config.EventUserTyping {
Expand Down
40 changes: 20 additions & 20 deletions bridge/discord/handlers.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package bdiscord

import (
"github.com/42wim/matterbridge/bridge/config"
"github.com/bwmarrin/discordgo"
"github.com/davecgh/go-spew/spew"
"github.com/matterbridge-org/matterbridge/bridge/config"
)

func (b *Bdiscord) messageDelete(s *discordgo.Session, m *discordgo.MessageDelete) { //nolint:unparam
Expand Down Expand Up @@ -72,7 +72,7 @@ func (b *Bdiscord) messageUpdate(s *discordgo.Session, m *discordgo.MessageUpdat
return
}
// only when message is actually edited
if m.Message.EditedTimestamp != nil {
if m.EditedTimestamp != nil {
b.Log.Debugf("Sending edit message")
m.Content += b.GetString("EditSuffix")
msg := &discordgo.MessageCreate{
Expand Down Expand Up @@ -110,7 +110,7 @@ func (b *Bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreat
b.Log.Debugf("== Receiving event %#v", m.Message)

if m.Content != "" {
m.Message.Content = b.replaceChannelMentions(m.Message.Content)
m.Content = b.replaceChannelMentions(m.Content)
rmsg.Text, err = m.ContentWithMoreMentionsReplaced(b.c)
if err != nil {
b.Log.Errorf("ContentWithMoreMentionsReplaced failed: %s", err)
Expand All @@ -132,8 +132,8 @@ func (b *Bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreat
}

// if we have embedded content add it to text
if b.GetBool("ShowEmbeds") && m.Message.Embeds != nil {
for _, embed := range m.Message.Embeds {
if b.GetBool("ShowEmbeds") && m.Embeds != nil {
for _, embed := range m.Embeds {
rmsg.Text += handleEmbed(embed)
}
}
Expand Down Expand Up @@ -175,22 +175,22 @@ func (b *Bdiscord) memberUpdate(s *discordgo.Session, m *discordgo.GuildMemberUp
b.membersMutex.Lock()
defer b.membersMutex.Unlock()

if currMember, ok := b.userMemberMap[m.Member.User.ID]; ok {
if currMember, ok := b.userMemberMap[m.User.ID]; ok {
b.Log.Debugf(
"%s: memberupdate: user %s (nick %s) changes nick to %s",
b.Account,
m.Member.User.Username,
b.userMemberMap[m.Member.User.ID].Nick,
m.Member.Nick,
m.User.Username,
b.userMemberMap[m.User.ID].Nick,
m.Nick,
)
delete(b.nickMemberMap, currMember.User.Username)
delete(b.nickMemberMap, currMember.Nick)
delete(b.userMemberMap, m.Member.User.ID)
delete(b.userMemberMap, m.User.ID)
}
b.userMemberMap[m.Member.User.ID] = m.Member
b.nickMemberMap[m.Member.User.Username] = m.Member
if m.Member.Nick != "" {
b.nickMemberMap[m.Member.Nick] = m.Member
b.userMemberMap[m.User.ID] = m.Member
b.nickMemberMap[m.User.Username] = m.Member
if m.Nick != "" {
b.nickMemberMap[m.Nick] = m.Member
}
}

Expand All @@ -206,9 +206,9 @@ func (b *Bdiscord) memberAdd(s *discordgo.Session, m *discordgo.GuildMemberAdd)
b.Log.Warnf("Received member update with no member information: %#v", m)
return
}
username := m.Member.User.Username
if m.Member.Nick != "" {
username = m.Member.Nick
username := m.User.Username
if m.Nick != "" {
username = m.Nick
}

rmsg := config.Message{
Expand All @@ -234,9 +234,9 @@ func (b *Bdiscord) memberRemove(s *discordgo.Session, m *discordgo.GuildMemberRe
b.Log.Warnf("Received member update with no member information: %#v", m)
return
}
username := m.Member.User.Username
if m.Member.Nick != "" {
username = m.Member.Nick
username := m.User.Username
if m.Nick != "" {
username = m.Nick
}

rmsg := config.Message{
Expand Down
4 changes: 2 additions & 2 deletions bridge/discord/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"bytes"
"strings"

"github.com/42wim/matterbridge/bridge/config"
"github.com/42wim/matterbridge/bridge/helper"
"github.com/bwmarrin/discordgo"
"github.com/matterbridge-org/matterbridge/bridge/config"
"github.com/matterbridge-org/matterbridge/bridge/helper"
)

// shouldMessageUseWebhooks checks if have a channel specific webhook, if we're not using auto webhooks
Expand Down
8 changes: 4 additions & 4 deletions bridge/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (

"golang.org/x/image/webp"

"github.com/42wim/matterbridge/bridge/config"
"github.com/gomarkdown/markdown"
"github.com/gomarkdown/markdown/html"
"github.com/gomarkdown/markdown/parser"
"github.com/matterbridge-org/matterbridge/bridge/config"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -155,19 +155,19 @@ func HandleDownloadSize(logger *logrus.Entry, msg *config.Message, name string,
continue
}
if re.MatchString(name) {
return fmt.Errorf("Matching blacklist %s. Not downloading %s", entry, name)
return fmt.Errorf("matching blacklist %s. Not downloading %s", entry, name)
}
}
}
logger.Debugf("Trying to download %#v with size %#v", name, size)
logger.Debugf("Trying to download %s with size %d", name, size)
if int(size) > general.MediaDownloadSize {
msg.Event = config.EventFileFailureSize
msg.Extra[msg.Event] = append(msg.Extra[msg.Event], config.FileInfo{
Name: name,
Comment: msg.Text,
Size: size,
})
return fmt.Errorf("File %#v to large to download (%#v). MediaDownloadSize is %#v", name, size, general.MediaDownloadSize)
return fmt.Errorf("file %s to large to download (%d). MediaDownloadSize is %d", name, size, general.MediaDownloadSize)
}
return nil
}
Expand Down
5 changes: 2 additions & 3 deletions bridge/helper/helper_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package helper

import (
"io/ioutil"
"os"
"testing"

Expand Down Expand Up @@ -118,7 +117,7 @@ func TestConvertWebPToPNG(t *testing.T) {
t.Skip()
}

input, err := ioutil.ReadFile("test.webp")
input, err := os.ReadFile("test.webp")
if err != nil {
t.Fail()
}
Expand All @@ -129,7 +128,7 @@ func TestConvertWebPToPNG(t *testing.T) {
t.Fail()
}

err = ioutil.WriteFile("test.png", *d, 0o644) // nolint:gosec
err = os.WriteFile("test.png", *d, 0o644) // nolint:gosec
if err != nil {
t.Fail()
}
Expand Down
Loading
Loading