Thumbnail

rani/matterbridge.git

Clone URL: https://git.buni.party/rani/matterbridge.git

commit e830c9dc0dbc9d00cd4b4b3910cf33c20ed4a169 Author: selfhoster1312 <selfhoster1312@kl.netlib.re> Date: Fri Oct 24 17:06:48 2025 +0000 deprecation: keybase bridge has been removed for now diff --git a/bridge/config/config.go b/bridge/config/config.go index 31b48ce..23ad83f 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -1587 +1587 @@ type Protocol struct {   StripMarkdown bool // irc   SyncTopic bool // slack   TengoModifyMessage string // general - Team string // mattermost, keybase + Team string // mattermost   TeamID string // msteams   TenantID string // msteams   Token string // slack, discord, api, matrix diff --git a/bridge/keybase/handlers.go b/bridge/keybase/handlers.go deleted file mode 100644 index a29208d..0000000 --- a/bridge/keybase/handlers.go +++ /dev/null @@ -159 +00 @@ -package bkeybase - -import ( - "strconv" - - "github.com/42wim/matterbridge/bridge/config" - "github.com/keybase/go-keybase-chat-bot/kbchat/types/chat1" -) - -func (b *Bkeybase) handleKeybase() { - sub, err := b.kbc.ListenForNewTextMessages() - if err != nil { - b.Log.Errorf("Error listening: %s", err.Error()) - } - - go func() { - for { - msg, err := sub.Read() - if err != nil { - b.Log.Errorf("failed to read message: %s", err.Error()) - } - - if msg.Message.Content.TypeName != "text" { - continue - } - - if msg.Message.Sender.Username == b.kbc.GetUsername() { - continue - } - - b.handleMessage(msg.Message) - - } - }() -} - -func (b *Bkeybase) handleMessage(msg chat1.MsgSummary) { - b.Log.Debugf("== Receiving event: %#v", msg) - if msg.Channel.TopicName != b.channel || msg.Channel.Name != b.team { - return - } - - if msg.Sender.Username != b.kbc.GetUsername() { - - // TODO download avatar - - // Create our message - rmsg := config.Message{Username: msg.Sender.Username, Text: msg.Content.Text.Body, UserID: string(msg.Sender.Uid), Channel: msg.Channel.TopicName, ID: strconv.Itoa(int(msg.Id)), Account: b.Account} - - // Text must be a string - if msg.Content.TypeName != "text" { - b.Log.Errorf("message is not text") - return - } - - b.Log.Debugf("<= Sending message from %s on %s to gateway", msg.Sender.Username, msg.Channel.Name) - b.Remote <- rmsg - } -} diff --git a/bridge/keybase/keybase.go b/bridge/keybase/keybase.go deleted file mode 100644 index d41e95f..0000000 --- a/bridge/keybase/keybase.go +++ /dev/null @@ -1106 +00 @@ -package bkeybase - -import ( - "io/ioutil" - "os" - "path/filepath" - "strconv" - - "github.com/42wim/matterbridge/bridge" - "github.com/42wim/matterbridge/bridge/config" - "github.com/keybase/go-keybase-chat-bot/kbchat" -) - -// Bkeybase bridge structure -type Bkeybase struct { - kbc *kbchat.API - user string - channel string - team string - *bridge.Config -} - -// New initializes Bkeybase object and sets team -func New(cfg *bridge.Config) bridge.Bridger { - b := &Bkeybase{Config: cfg} - b.team = b.Config.GetString("Team") - return b -} - -// Connect starts keybase API and listener loop -func (b *Bkeybase) Connect() error { - var err error - b.Log.Infof("Connecting %s", b.GetString("Team")) - - // use default keybase location (`keybase`) - b.kbc, err = kbchat.Start(kbchat.RunOptions{}) - if err != nil { - return err - } - b.user = b.kbc.GetUsername() - b.Log.Info("Connection succeeded") - go b.handleKeybase() - return nil -} - -// Disconnect doesn't do anything for now -func (b *Bkeybase) Disconnect() error { - return nil -} - -// JoinChannel sets channel name in struct -func (b *Bkeybase) JoinChannel(channel config.ChannelInfo) error { - if _, err := b.kbc.JoinChannel(b.team, channel.Name); err != nil { - return err - } - b.channel = channel.Name - return nil -} - -// Send receives bridge messages and sends them to Keybase chat room -func (b *Bkeybase) Send(msg config.Message) (string, error) { - b.Log.Debugf("=> Receiving %#v", msg) - - // Handle /me events - if msg.Event == config.EventUserAction { - msg.Text = "_" + msg.Text + "_" - } - - // Delete message if we have an ID - // Delete message not supported by keybase go library yet - - // Edit message if we have an ID - // kbchat lib does not support message editing yet - - if len(msg.Extra["file"]) > 0 { - // Upload a file - dir, err := ioutil.TempDir("", "matterbridge") - if err != nil { - return "", err - } - defer os.RemoveAll(dir) - - for _, f := range msg.Extra["file"] { - fname := f.(config.FileInfo).Name - fdata := *f.(config.FileInfo).Data - fcaption := f.(config.FileInfo).Comment - fpath := filepath.Join(dir, fname) - - if err = ioutil.WriteFile(fpath, fdata, 0600); err != nil { - return "", err - } - - _, _ = b.kbc.SendAttachmentByTeam(b.team, &b.channel, fpath, fcaption) - } - - return "", nil - } - - // Send regular message - text := msg.Username + msg.Text - resp, err := b.kbc.SendMessageByTeamName(b.team, &b.channel, text) - if err != nil { - return "", err - } - return strconv.Itoa(int(*resp.Result.MessageID)), err -} diff --git a/changelog.md b/changelog.md index 141ed2e..6e2ffb5 100644 --- a/changelog.md +++ b/changelog.md @@ -96 +98 @@   - harmony protocol does not exist anymore   - gitter protocol does not exist anymore ; gitter.im is now a matrix protocol server   - steam protocol has changed profoundly + - keybase has been removed because we don't have a maintainer for it. See + [issue #9](https://github.com/matterbridge-org/matterbridge/issues/9)    # v1.26.0   diff --git a/docs/credits.md b/docs/credits.md index 3f72898..14c6649 100644 --- a/docs/credits.md +++ b/docs/credits.md @@ -107 +106 @@ Matterbridge wouldn't exist without these libraries:  - gozulipbot - <https://github.com/ifo/gozulipbot>  - gumble - <https://github.com/layeh/gumble>  - irc - <https://github.com/lrstanley/girc> -- keybase - <https://github.com/keybase/go-keybase-chat-bot>  - matrix - <https://github.com/matrix-org/gomatrix>  - mattermost - <https://github.com/mattermost/mattermost-server>  - msgraph.go - <https://github.com/yaegashi/msgraph.go> diff --git a/docs/protocols/README.md b/docs/protocols/README.md index 45373f5..c853b31 100644 --- a/docs/protocols/README.md +++ b/docs/protocols/README.md @@ -219 +216 @@ Matterbridge supports many protocols, although not all of them support all featu - [xmpp docs](xmpp/) - [xmpp settings](xmpp/settings.md)   - Channel format: `channel_name` (for `channel_name@muc.server.org` where `muc.server.org` has been configured as `Muc` for the corresponding xmpp account) -- [Keybase](https://keybase.io) - - Matterbridge [keybase docs](keybase/) - - Channel format: `channel_name` (without the leading `#`), or `general` if your team doesn't have multiple channels  - [Matrix](https://matrix.org)   - Matterbridge docs: - [matrix docs](matrix/) @@ -936 +909 @@ Matterbridge supports many protocols, although not all of them support all featu    ## Dropped official support   +- [Keybase](https://keybase.io) + - Dropped because noone is maintaining it on our side + - Reach out [here](https://github.com/matterbridge-org/community/issues/1) if you want to help bring it back  - [Gitter](https://gitter.im)   - Has moved to matrix protocol  - [Harmony](https://harmonyapp.io) diff --git a/docs/protocols/keybase/README.md b/docs/protocols/keybase/README.md deleted file mode 100644 index 0e61ee9..0000000 --- a/docs/protocols/keybase/README.md +++ /dev/null @@ -152 +00 @@ -# Keybase - -- Status: ??? -- Maintainers: ??? -- Features: ??? - -> [!WARNING] -> **Remember to create a dedicated Keybase user (a new account specifically for the bot).** -``` - -## Configuration - -**Basic configuration example:** - -```toml -[keybase.mykeybase] -# Your bot account MUST already have access to the provided team or subteam! -Team="mykeybase.team" -RemoteNickFormat="[{PROTOCOL}/{BRIDGE}] <{NICK}> " -``` - -## FAQ - -### How to create a new account for the bot? - -Install Keybase on the server running matterbridge (https://keybase.io/download) -Log into the bot account on your server - -## Headless server install + systemd - -If you run matterbridge as a service in systemd and want to use a bridge with keybase, be sure to run the service as the default user via *user.slice*, since keybase also runs its services in *user.slice*. - -Create a `matterbridge-user.service` in `~/.config/systemd/user/`: - -``` -[Unit] -Description=matterbridge -After=network.target - -[Service] -ExecStart=/path-to-your-executable/matterbridge -Restart=on-failure -RestartSec=10s - -[Install] -WantedBy=multi-user.target -``` - -Then add the `--user` argument to all your `systemctl` commands. For example, `systemctl --user enable --now matterbridge-user.service`. - -> [!WARNING] -> **If you are using an SSH session, user services might shut down, use this to prevent:** `loginctl enable-linger` \ No newline at end of file diff --git a/gateway/bridgemap/bkeybase.go b/gateway/bridgemap/bkeybase.go deleted file mode 100644 index 92ff894..0000000 --- a/gateway/bridgemap/bkeybase.go +++ /dev/null @@ -112 +00 @@ -//go:build !nokeybase -// +build !nokeybase - -package bridgemap - -import ( - bkeybase "github.com/42wim/matterbridge/bridge/keybase" -) - -func init() { - FullMap["keybase"] = bkeybase.New -} diff --git a/go.mod b/go.mod index ea38049..021eabd 100644 --- a/go.mod +++ b/go.mod @@ -147 +146 @@ require (   github.com/gorilla/schema v1.4.1   github.com/hashicorp/golang-lru v1.0.2   github.com/jpillora/backoff v1.0.0 - github.com/keybase/go-keybase-chat-bot v0.0.0-20221220212439-e48d9abd2c20   github.com/kyokomi/emoji/v2 v2.2.13   github.com/labstack/echo/v4 v4.12.0   github.com/lrstanley/girc v0.0.0-20240823210506-80555f2adb03 diff --git a/go.sum b/go.sum index ddb8030..fbaa689 100644 --- a/go.sum +++ b/go.sum @@ -1678 +1676 @@ github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCV  github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=  github.com/kettek/apng v0.0.0-20191108220231-414630eed80f h1:dnCYnTSltLuPMfc7dMrkz2uBUcEf/OFBR8yRh3oRT98=  github.com/kettek/apng v0.0.0-20191108220231-414630eed80f/go.mod h1:x78/VRQYKuCftMWS0uK5e+F5RJ7S4gSlESRWI0Prl6Q= -github.com/keybase/go-keybase-chat-bot v0.0.0-20221220212439-e48d9abd2c20 h1:imPu/fy8VhpzD318SnouRyvIgJAoouEyph6+7XAZbbk= -github.com/keybase/go-keybase-chat-bot v0.0.0-20221220212439-e48d9abd2c20/go.mod h1:Yan1Krk0q1FglHdCkNrF5hFQ4Sgq8LnuG4gI2U4xQAk=  github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=  github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=  github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample index 1ad39e2..530f40e 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -5126 +5127 @@ StripNick=false  ShowTopicChange=false    ################################################################### +<<<<<<< HEAD  #  # Keybase  # You should have a separate bridge account on Keybase