Commit Graph

656 Commits (ddc262593449357e4d0399af82d26cee0fb65c45)

Author SHA1 Message Date
Wim 65781b9316
Disable user lookups on delete messages (slack) (#812) 5 years ago
Duco van Amstel 9be0be0316 Add lacking clean-up in Slack synchronisation (#811) 5 years ago
Wim fed77cccf3 Handle unthreaded messages (mattermost). Fixes #803 5 years ago
Wim 9b520dfb78 Fix panic on nil message.Post (mattermost). Fixes #804 5 years ago
Wim 2d277a15f5
Add scripting (tengo) support for every outgoing message (#806)
Adds a new key OutMessage under [tengo] table, which specifies the location of the script that
will be invoked on each message being sent to a bridge and can be used to modify the Username
and the Text of that message.

The script will have the following global variables:
read-only:
inAccount, inProtocol, inChannel, inGateway
outAccount, outProtocol, outChannel, outGateway

read-write:
msgText, msgUsername

The script is reloaded on every message, so you can modify the script on the fly.

The default script in https://github.com/42wim/matterbridge/tree/master/internal/tengo/outmessage.tengo
is compiled in and will be executed if no script is specified.
5 years ago
chotaire 6b47e29583 Add verbose IRC joins/parts (ident@host) (#805)
New configuration setting: VerboseJoinPart (default is false)
5 years ago
Wim 380c38674c Fix deadlock on reconnect (irc). Closes #757 5 years ago
Wim 5677c912a8
Add useraction support (rocketchat). Closes #772 (#794) 5 years ago
Wim 7a24de15e4
Add tengo support to RemoteNickFormat (#793)
This commit add support for using the result of a tengo script in RemoteNickFormat using {TENGO}
Also adds a new toml table [tengo] with key RemoteNickFormat and value location of the script.
This also moves the TengoModifyMessage from [general] to Message in [tengo]

Documentation:

RemoteNickFormat allows you to specify the location of a tengo (https://github.com/d5/tengo/) script.
The script will have the following global variables:
to modify: result
to read: channel, bridge, gateway, protocol, nick

The result will be set in {TENGO} in the RemoteNickFormat key of every bridge where {TENGO} is specified
The script is reloaded on every message, so you can modify the script on the fly.
Example script can be found in https://github.com/42wim/matterbridge/tree/master/contrib/remotenickformat.tengo

[tengo]
RemoteNickFormat="remotenickformat.tengo"
5 years ago
Wim 8a875f292e Revert fix for #722. Closes #781
Revert "Fix typo"

This reverts commit dffd67eb31.

Revert "Handle quit message relay better on gateways with one channel on the irc bridge #722"

This reverts commit 240559581a.

Revert "Support quits from irc correctly. Fixes #722 (#724)"

This reverts commit d76a04bd0a.
5 years ago
Wim 60a85621ea Return when not connected and drop a message (irc). Fixes #786 5 years ago
Wim cdf33e5748 Use default nick if none specified (irc). Fixes #785 5 years ago
Wim 01d0a9f412 Handle nil message (telegram). Fixes #777 5 years ago
Wim 8cc2d3b4fe Revert "Bail if any vars are nil, not if all (telegram) (#778)"
This reverts commit efd2c99862.
5 years ago
Wim 64b57f2da3
Ignore message_replied and hidden messages (slack). Fixes #709 (#779) 5 years ago
David Hill efd2c99862 Bail if any vars are nil, not if all (telegram) (#778) 5 years ago
Wim 16763b715a
Look up #channel too (rocketchat). Fix #773 (#775) 5 years ago
David Hill 97f9d4be67 Fix double unlock (slack) (#771) 5 years ago
Wim 77516c97db
Allow the # in rocketchat channels (backward compatible) (#769) 5 years ago
Duco van Amstel 8b754017ca Fix race-condition in populateUser() (#767)
Fix the root-cause of #759 by introducing synchronisation points for
individual user fetches.
5 years ago
Wim a27600046e
Fix regression for legacy slack by #766 (#768) 5 years ago
Duco van Amstel fb2667631d Refactor channel and user management (slack) (#766) 5 years ago
Duco van Amstel b638f7037a Force Slack link unfurling (#763) 5 years ago
Duco van Amstel 74699a8262 Split-out Slack user and channel management (#762) 5 years ago
Wim e955a056e2
Trim <p> and </p> tags (matrix). Closes #686 (#753) 5 years ago
Wim 53aa076555
Do not send duplicate messages (rocketchat). Fixes #745 (#752)
For an unknown reason we get duplicate messages (from the same channel)
using the realtime API when we have > 1 channel subscribed on.
Solution for now is caching the message ID in a LRU cache and ignoring
the duplicates.

This should be reviewed when we have actual editing support from the
realtime API
5 years ago
Wim f57370f33a
Add support for URL in messageEntities (telegram). Fixes #735 (#736) 5 years ago
Wim c557d51b6f
Need to specify /topic:mytopic for channel configuration (zulip). (#751)
Breaking change for zulip channel configuration.

For zulip the channel configuration will now need to specify also
the topic with /topic:yourtopic.

Example:
[[gateway.inout]]
account="zulip.streamchat"
channel="general/topic:mytopic"

This fixes the incorrect PR #701 which didn't work with multiple
gateways.
5 years ago
Wim df3fdc26a0
Use whatsapp forks (#750) 5 years ago
Wim af00c34aac
Do not relay any bot messages (discord) (#743) 5 years ago
Wim 26a7e35f27
Add MediaConvertWebPToPNG option (telegram). (#741)
* Add MediaConvertWebPToPNG option (telegram).

When enabled matterbridge will convert .webp files to .png files
before uploading them to the mediaserver of the other bridges.

Fixes #398
5 years ago
Wim b09a73040f
Print errors as string instead of %#v (#738) 5 years ago
Wim 740b5f2602
Keep reconnecting until succeed (zulip) (#737) 5 years ago
Wim 96841c70c7 Fix regression in HTML handling (telegram). Closes #734
* Revert back to blackfriday v1
* Add testing
5 years ago
Wim a775b57134
Do not send topic changes on connect (xmpp). Fixes #732 (#733)
This checks if we get a topic change < 5 seconds after connection.
If that's the case, ignore it.
Also this PR makes the topic change an actual EventTopicChange.
5 years ago
Wim bf21604d42
Make all loggers derive from non-default instance (#728) 5 years ago
Wim 1bb39eba87
Add scripting (tengo) support for every incoming message (#731)
TengoModifyMessage allows you to specify the location of a tengo (https://github.com/d5/tengo/) script.
This script will receive every incoming message and can be used to modify the Username and the Text of that message.
The script will have the following global variables:
to modify: msgUsername and msgText
to read: msgChannel and msgAccount

The script is reloaded on every message, so you can modify the script on the fly.

Example script can be found in https://github.com/42wim/matterbridge/tree/master/gateway/bench.tengo
and https://github.com/42wim/matterbridge/tree/master/contrib/example.tengo

The example below will check if the text contains blah and if so, it'll replace the text and the username of that message.
text := import("text")
if text.re_match("blah",msgText) {
    msgText="replaced by this"
    msgUsername="fakeuser"
}

More information about tengo on: https://github.com/d5/tengo/blob/master/docs/tutorial.md and
https://github.com/d5/tengo/blob/master/docs/stdlib.md
5 years ago
Wim 1f1634ea59 Add extra debug option (slack) 5 years ago
Declan Hoare a7dd033c3b Allow sending discriminator with Discord username (#726) 5 years ago
Krzysiek Madejski 55e79063d6 Add initial WhatsApp support (#711) 5 years ago
Wim d76a04bd0a
Support quits from irc correctly. Fixes #722 (#724) 5 years ago
Wim a8fe54a78d
Allow zulip bridge to specify topic per channel. Closes #701 (#723) 5 years ago
Wim 0bcb0b882f
Support join/leaves from discord. Closes #654 (#721) 5 years ago
Wim aeaea0574f
Detect html nicks in RemoteNickFormat (matrix). Fixes #696 (#719) 5 years ago
Wim 99d71c2177
Send notices on join/parts (matrix). Fixes #712 (#716) 5 years ago
Wim 3e60cfafd3
Send username when uploading video/images (matrix). Fixes #715 (#717) 5 years ago
Wim 3123695869
Upgrade to latest girc version (irc) (#718) 5 years ago
Wim 716751cf76
Refactor and update RocketChat bridge (#707)
* Add support for editing/deleting messages
* Add support for uploading files
* Add support for avatars
* Use the Rocket.Chat.Go.SDK
* Use the rest and streaming api
5 years ago
Wim 6ebd5cbbd8 Refactor and update RocketChat bridge
* Add support for editing/deleting messages
* Add support for uploading files
* Add support for avatars
* Use the Rocket.Chat.Go.SDK
* Use the rest and streaming api
5 years ago
Wim 077b818d82 Add extra debug of SubMessage to empty messages error (slack). #709 5 years ago
Wim 5af1d80055 Do not panic on non-json response from server (zulip) 5 years ago
Wim 40d76b2296 Fix error handling on bad event queue id (zulip). Closes #694 5 years ago
Wim 57f156be83
Hint at thread replies when messages are unthreaded (slack) (#684) 5 years ago
Wim c81c0dd22a Update vendor, move to labstack/echo/v4 Fixes #698 6 years ago
Wim 4ae028fe73 Optimize handling of very large slack teams. Fixes #695
Stop getting users if we reach 2000 users. Slack will rate-limit us
even if we follow their limits.
This means that we now have to lookup every user that says a message
for the first time. This should be less intensive on the API.

This also disables partly fb713ed91b for now.
ChannelMembers will not be filled.
6 years ago
Wim 94812d8648 Handle servers without MOTD (irc). Closes #692 6 years ago
Wim 8548b69e6e Fix possible data race (irc). Closes #693 6 years ago
Wim e3cb665d92 Make discord user token work correctly (discord) #689 6 years ago
Wim fb713ed91b
Add initial support for getting ChannelMember info of all bridges (#678)
* Add initial support for getting ChannelMember info of all bridges.

Adds an EventGetChannelMembers event, which gets send every x time to
all bridges. Bridges should respond on this event with a Message
containing ChannelMembers in the EventGetChannelMembers key in the
Extra field.

handleEventGetChannelMembers will handle this Message and sets the
contained ChannelMembers to the Bridge struct.

* Add ChannelMembers support to the slack bridge
6 years ago
Wim d99eacc2e1 Run go fmt 6 years ago
Zomboy Alfrir 62e55214fc Allow to bridge non-bot Discord users (discord) (#689)
If you prefix a token with `User ` it'll treat is as a user token.

Co-Authored-By: zomboy-alfrir <zomboy@dancodes.com.ar>
6 years ago
David Hill f88c5f6c08 Fix displaying usernames for plain text clients. (matrix) (#685) 6 years ago
Patrick Connolly b33b50987b Add support for mattermost threading (#627) 6 years ago
James Nylen 5193634a52 Use only one webhook if possible (discord) (#681) 6 years ago
Wim 46e2683995 Add file comment to webhook messages (discord). Fixes #358 6 years ago
James Nylen 492722af8b Improve error reporting on failure to join Discord. Fixes #672 (#680) 6 years ago
Wim 04567c765e
Add support for markdown to HTML conversion (matrix). Closes #663 (#670)
This uses our own gomatrix lib with the SendHTML function which
adds HTML to formatted_body in matrix.
golang-commonmark is used to convert markdown into valid HTML.
6 years ago
ValdikSS 7326b9e10d Add various sshchat fixes (#675)
* SSH-Chat: set quiet mode to filter joins/quits
* SSH-Chat: Trim newlines in the end of relayed messages
* SSH-Chat: fix media links
* SSH-Chat: do not relay "Rate limiting is in effect" message
6 years ago
Qais Patankar 8522d8f29c Fix #668 strip lang in code fences sent to Slack (#673) 6 years ago
Wim bab385c342 Remove unused key (config) 6 years ago
Wim c585d00f16 Ignore LatencyReport event (slack) 6 years ago
Duco van Amstel da8e415ae1 Use logrus imports instead of log (#662) 6 years ago
Duco van Amstel 1b834c6858 Fix sshchat connection logic (#661) 6 years ago
Jerry Heiselman d82726cd1b Try downloading files again if slack is too slow (slack). Closes #655 (#656) 6 years ago
Wim 53c86702a3
Add wait option for populateUsers/Channels (slack) Fixes #579 (#653)
When setting wait to true, we wait until the populating isn't in progress anymore.
This is used on startup connections where we really need the initial information
which could take a long time on big servers.
6 years ago
David Hill 192fe89789 Populate user on channel join (slack) (#644) 6 years ago
Wim 959ca3cef3 Fix bot (legacy token) messages not being send. Closes #571 6 years ago
Wim bfa9a83d31
Refactor telegram (#649)
* Decrease complexity in Send() (makes codeclimate happy)
6 years ago
Wim 2f7b4d7f68
Refactor sshchat bridge (#650)
* Decrease complexity in Send()
* Add handleUploadFile() function
6 years ago
Wim d887855e16 Add bot debug info (slack) 6 years ago
Duco van Amstel a2754f15fc Enable errcheck linter (#646) 6 years ago
Wim f9fb33e696
Refactor steam bridge (#630)
* split up in different files
* decrease complexity
6 years ago
Wim f72d5de2d7 Disable some unparam checks (discord) 6 years ago
Duco van Amstel 0365c0786a Split Discord bridge in multiple files (#632) 6 years ago
Duco van Amstel 8a7efce941 Move golangci-lint configuration to file (#635) 6 years ago
Wim 4265d43096
Refactor handleUploadFile (matrix) (#629) 6 years ago
Wim 27f5a1a685 Fix multiple channel join regression. Closes #639 6 years ago
Wim 859ebad55d
Make slack-legacy change less restrictive (#626) 6 years ago
Patrick Connolly e538a4d304 Update nlopes/slack to 4.1-dev (#595) 6 years ago
Wim f94c2b40a3
Refactor mattermost bridge (#622)
* Split up in different files
* Decrease complexity
* Fix linting issues
6 years ago
Wim 7923cfe8f8 Fix telegram crash #620 6 years ago
Wim df02f51c56 Fix regression on using server ID (discord). #619 #617 6 years ago
Patrick Connolly fc5e3a6728 Create getChannelsByX functions to make codeclimate happy (slack) (#610) 6 years ago
Wim 57fbd3c723
Refactor irc handlers. Fix linting (#611) 6 years ago
Wim 25cd1e2cc1
Refactor telegram handlers. Fix linting (#609)
* Refactor telegram handlers. Fix linting
6 years ago
Patrick Connolly f5659d455d Sync channel topics between Slack bridges (#585)
Added logic to allow for configurable synchronisation of topics and purposes of channels between Slack bridges.
6 years ago
Duco van Amstel 09875fe160 Update direct dependencies where possible 6 years ago
Wim f716b8fc0f
Merge pull request #606 from 42wim/fix-590 6 years ago
Wim 9f66f93641
Add option to send RAW commands after connection (irc). Fixes #490 (#604) 6 years ago
Wim f00d4d7d3f Make sure threaded files stay in thread (slack). Fixes #590 6 years ago
Wim 0929535b2e Do not post empty messages (slack). Fixes #574 6 years ago
Wim 8869e253ca Handle deleted/edited thread starting messages (slack). Fixes #600 (#605) 6 years ago
Wim f4d4dc91b1
Add option to ignore failing bridge on start. Fixes #455 (#603) 6 years ago
Wim c6fd65d1d7 Limit discord username via webhook to 32 chars 6 years ago
Wim 0795906533 Rework connection logic (irc)
If IRC connection fails on first connect, bail out.
Wait until after nickserv auth until joining channels (also after reconnects)
Don't do a separate irc timeout, some connections take a while #503
6 years ago
Wim a2b45bc799 Fix Nickserv logic (irc) #602 6 years ago
Wim ae32bae791
Add protocol to msg.ID in cache (#596) 6 years ago
Wim 32f57b7c26 Add links to slack bot and legacy config in error message (slack) 6 years ago
Duco van Amstel ce21ba1545 Fix golint linter issues and enable it in CI (#593) 6 years ago
Duco van Amstel c89085bf44 Fix and enable goimports linter (#591) 6 years ago
Patrick Connolly 4254ed3c63 Fix regression in skip logic (slack). (#592) 6 years ago
Duco van Amstel 85564a35fd Fix IRC line splitting. Closes #584 (#587) 6 years ago
Patrick Connolly 09713d40ba Fix file caching issue (slack). #572 (#575) 6 years ago
Duco van Amstel 16d5aeac7c Make config.Config more unit-test friendly (#586) 6 years ago
Duco van Amstel e19ba5a06a Add new Slack connection and forked legacy Slack bridge (#582) 6 years ago
Wim f7a5077d5d Fix goconst linter failure 6 years ago
Wim f8dc24bc09 Switch back go upstream bwmarrin/discordgo
Commit ffa9956c9b got merged in.
6 years ago
Duco van Amstel e9419f10d3 Restore file comments coming from Slack (#583) 6 years ago
Wim d2ae3ebf9e Disable Connect(), JoinChannel(), Send() for mattermost.plugin 6 years ago
Duco van Amstel 2f042ad915 Add more rate-limit handling (slack) (#581) 6 years ago
Wim 78401214b0 Make scopelint happy 6 years ago
Wim b2a07aba3a Make goconst linter happy 6 years ago
Wim 1e0bb3da95 Make gocritic linter happier 6 years ago
Wim 59994da176 Act only on UserTypingEvents when enabled 6 years ago
Patrick Connolly 3d281b3316 Add ability to show when user is typing across Slack bridges (#559) 6 years ago
Duco van Amstel ea86849a58 Fix Slack edit usernames (#570) 6 years ago
Wim 399789811e Make gocritic linter happy 6 years ago
Wim 8d117cb0a4 Make structcheck linter happy 6 years ago
Wim 588b8e0303 Make interfacer linter happy 6 years ago
Wim 1794922263 Make unparam linter happy 6 years ago
Patrick Connolly f2703979a4 Clean up config loading. (#561) 6 years ago
Duco van Amstel d2a1dc792f Refactor and clean-up handlers. (slack) (#533) 6 years ago
David Hill 0e2522279e Clean up various stuff (#508)
* various cleanups
6 years ago
Duco van Amstel a1bf37e457 Do not join Slack channel without API access (slack) (#563) 6 years ago
Patrick Connolly a20b7895a9 Preserve threading between Slack instances (#529)
* Opportunistically preserve Slack threading when parent thread in cache. [#529]

* Removed slack-specific processing from gateway.

* Added docs.

* Add option to enable threading, with default to off.

* Did cleanup on @42wim's comments.

* Update gateway/gateway.go

Co-Authored-By: patcon <patrick.c.connolly@gmail.com>

* Suggestion from @42wim :)

* Suggestions from @42wim.

* More suggestions.
6 years ago
Patrick Connolly 5666821e7b Add a health endpoint to API (#554) 6 years ago
Patrick Connolly 5132d8f097 Stop setting API ring buffer capacity if not specified. (#552) 6 years ago
Patrick Connolly 7e62bc4819 Remove hyphens when auto-loading envvars from viper config (#545)
* When auto-loading envvars from toml keys, remove hyphens.

See: https://unix.stackexchange.com/questions/23659/can-shell-variable-include-character
6 years ago
NikkyAI d058be25ad Respond with message on connect (api) (#550)
fix #549
6 years ago
Duco van Amstel 1269be1d04 Prevent Slack API rate-limit overflow (#539) 6 years ago
Wim e2b50d6194 Add better support for multiperson DM (mattermost) 6 years ago
Wim 107969c09a
Split up cookie token and personal token (mattermost). Fixes #530 (#540) 6 years ago
Patrick Connolly d379118772 Fix bridge no longer POSTing username and avatar (slack) (#536)
* Fixed pointer/reference issue in populateUsers. [#536]

* Accepted codestyle suggestion.

* Update bridge/slack/helpers.go

Co-Authored-By: patcon <patrick.c.connolly@gmail.com>

* Update helpers.go
6 years ago
Duco van Amstel f2cdda7278 Update Blackfriday dependency (closes #522) (#532)
- Fixup Telegram bridge implementation to support updated dependency.
6 years ago
Duco van Amstel 6911458d15 Clean up message send logic (slack). (#531) 6 years ago
Duco van Amstel 6238effdc2 Clean up user and channel information management (slack) (#521) 6 years ago
Duco van Amstel 498377a230 Clean up code and strengthening (slack) (#519)
Changes include:
- Refactor of strings into package-wide constants.
- Predeclaration of regexps to be instantiated at package load time.
- Checking of unchecked errors.
- Structural changes:
  - Adding verifications to type-casting code.
  - Remove unnecessary 'len(X) > 0' checks before iterating over X.
  - Remove unnecessary 'else' clause after 'if' with 'return'.
  - Unexporting of public fields of Bridge struct.
- Formatting:
  - One-field-per-line struct definitions.
6 years ago
Duco van Amstel e15b0e04b8 Refactor slack bridge prelude (#517)
Distributing the source of the Slack bridge across multiple files to
increase readability and as a prelude to various refactors and
clean-ups.
6 years ago
NikkyAI 54adb0509e Fix mentions cuttíng off all text after the mention (discord) (#506) 6 years ago
Wim bd3a3b6eaf Let webhook also replace mentions (discord). Closes #502 6 years ago