Commit Graph

137 Commits

Author SHA1 Message Date
Wim 6438a3dba3
Add support for deleting files from slack to discord. Fixes #1705 (#1709)
We create a new event EventFileDelete which will be used to delete
specific uploaded files using the Extra["file"] in the config.Message.

We also add a new NativeID key to the FileInfo struct which will contain
the native file ID of the sending bridge.

When a new file is added to the config.Message.Extra["file"] map, now
the bridge native file ID should be added here.

When the receiving bridge receives such a message, it should keep an
internal mapping of NativeID <> bridge fileid/message id. In the case of
discord we map it to the resulted discord message ID after uploading it.

Now when a bridge deletes a file, it should send a EventFileDelete and
setting the ID to the native file ID of the bridge.

When the receiving bridge will get this event it'll look into the
NativeID <> bridge id mapping to find their internal ID and use it to
delete the specific file on their side.

For now this is implemented for slack to discord but this will be add to
other bridges where useful.
2022-02-05 14:45:54 +01:00
vpzomtrrfrt 9a8ce9b17e
Reply support for Matrix (#1664)
* Post replies to matrix

* Handle replies from matrix

* Include protocol in canonical ID return

* fmt
2022-01-09 23:46:59 +01:00
Wim 21eb37e471
Update vendor (#1446)
* Update vendor

* Use upstream emoji lib again
2021-04-03 19:16:46 +02:00
Qais Patankar a9d8ac8bc0
Refactor "msg-parent-not-found" to config.ParentIDNotFound (#1347) 2020-12-31 18:01:57 +00:00
JeremyRand c3bcbd63c0
Add UserID to RemoteNickFormat and Tengo (#1308)
* Add UserID to RemoteNickFormat and Tengo

* Use strings.ReplaceAll in gateway.modifyUsername

Fixes a warning from gocritic linter.

* Use Unicode escape sequence instead of raw ZWSP in gateway.modifyUsername

Fixes a warning from stylecheck linter.
2020-11-25 23:54:27 +01:00
Wim b24e1bafa1
Add support for irc to irc notice (irc). Fixes #754 (#1305) 2020-11-22 22:21:02 +01:00
Wim eff41759bc
Add extra debug to log time spent sending a message per bridge (#1299) 2020-11-22 17:20:20 +01:00
Wim ae3bc3358b
Allow tengo to drop messages using msgDrop (#1272) 2020-10-21 21:57:14 +02:00
Wim 1e0b4532bd
Show deprecate warnings about old tengo settings (#1271) 2020-10-21 20:35:22 +02:00
Wim 06b7bad714
Lowercase account names. Fixes #1108 (#1110) 2020-04-21 20:42:11 +02:00
Qais Patankar c91bfd08d8 Add ability to procure avatars from the destination bridge (#1000)
* remote_avatar: add UseLocalAvatar

* remote_avatar: make sure msg.Protocol is always set correctly

* remote_avatars: support msg.Account

* remote_avatar: add to matterbridge.toml.sample

* remote_avatar: clarify something
2020-02-09 22:07:26 +01:00
Wim 9d84d6dd64
Update to tengo v2 (#976) 2020-01-09 21:52:19 +01:00
Wim 075ca9ca47
Switch to new emoji library kyokomi/emoji (#948) 2019-11-17 23:01:03 +01:00
Wim 28783a4146
Do configuration validation on start-up. Fixes #888 (#889)
Fail if:
* we don't have any gateways configured
* we have gateways configured but with non-existing bridge configuration
* we have gateways configured without any configuration
2019-09-09 23:48:00 +02:00
Wim bd0e81f5a0 Add msg event to tengo 2019-04-24 22:47:37 +02:00
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.
2019-04-19 18:27:31 +02:00
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"
2019-04-08 20:58:21 +02:00
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.
2019-04-06 23:12:48 +02:00
Wim 115d20373c
Update tengo vendor and load the stdlib. Fixes #789 (#792) 2019-04-06 22:18:25 +02:00
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.
2019-03-02 20:31:38 +01:00
Wim 7f1d86b338
Fail gracefully on incorrect human input. Fixes #739 (#740) 2019-02-26 18:03:50 +01:00
Wim bf21604d42
Make all loggers derive from non-default instance (#728) 2019-02-23 22:51:27 +01:00
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
2019-02-23 16:39:44 +01:00
Wim 3190703dc8
Support rewriting messages from relaybots using ExtractNicks. Fixes #466 (#730)
some examples:
this replaces a message like "Relaybot: <relayeduser> something interesting" to "relayeduser: something interesting"
ExtractNicks=[ [ "Relaybot", "<(.*?)>\\s+" ] ]
you can use multiple entries for multiplebots
this also replaces a message like "otherbot: (relayeduser) something else" to "relayeduser: something else"
ExtractNicks=[ [ "Relaybot", "<(.*?)>\\s+" ],[ "otherbot","\\((.*?)\\)\\s+" ]
OPTIONAL (default empty)
ExtractNicks=[ ["otherbot","<(.*?)>\\s+" ] ]
2019-02-23 16:35:54 +01:00
Wim dffd67eb31 Fix typo 2019-02-21 20:33:49 +01:00
Wim 240559581a Handle quit message relay better on gateways with one channel on the irc bridge #722 2019-02-21 17:55:04 +01:00
Wim eef654de98 Fix bug in #721 2019-02-17 22:45:23 +01:00
Wim d76a04bd0a
Support quits from irc correctly. Fixes #722 (#724) 2019-02-17 22:43:04 +01:00
Wim 0bcb0b882f
Support join/leaves from discord. Closes #654 (#721) 2019-02-17 21:49:45 +01:00
Wim 4525fa31aa
Allow regexs in ignoreNicks. Closes #690 (#720) 2019-02-17 21:49:28 +01:00
Wim 57f156be83
Hint at thread replies when messages are unthreaded (slack) (#684) 2019-02-10 17:23:50 +01:00
Wim 56749dfb20 Fail if channel starts with hashtag (mattermost). Closes #625 2019-01-07 00:26:11 +01:00
Duco van Amstel da8e415ae1 Use logrus imports instead of log (#662) 2018-12-26 15:16:09 +01:00
Wim ccd55d2a28
Refactor gateway (#648)
* Decrease complexity of handleMessage, handleReceive, handleFiles
* Move handlers to handlers.go
* Split ignoreMessage up in ignoreTextEmpty, ignoreNicks and IgnoreTexts
* Add ignoreEvent
* Add testcase for ignoreTextEmpty, ignoreNicks, ignoreTexts and ignoreEvent
2018-12-12 23:57:17 +01:00
Duco van Amstel af7a00d030 Enable gosec linter (#645) 2018-12-06 00:40:55 +01:00
Patrick Connolly 47d29ecf63 Tidy up fetching of config values. (#616) 2018-12-01 00:24:07 +01:00
Patrick Connolly f2088a687e Extract bridgeMap into own package to improve testability (#601) 2018-11-30 23:53:00 +01:00
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.
2018-11-26 09:47:04 +00:00
Wim ae32bae791
Add protocol to msg.ID in cache (#596) 2018-11-19 21:28:23 +01:00
Duco van Amstel ce21ba1545 Fix golint linter issues and enable it in CI (#593) 2018-11-15 20:43:43 +01:00
Duco van Amstel 16d5aeac7c Make config.Config more unit-test friendly (#586) 2018-11-13 23:30:56 +01:00
Duco van Amstel e19ba5a06a Add new Slack connection and forked legacy Slack bridge (#582) 2018-11-13 20:51:19 +01:00
Wim 730ccdd456 Add support for mattermost matterbridge plugin 2018-11-11 21:56:12 +01:00
Wim 9be0f8f000 Make gochecknoinits linter happy 2018-11-08 22:33:03 +01:00
Wim 78401214b0 Make scopelint happy 2018-11-08 22:29:34 +01:00
Wim b2a07aba3a Make goconst linter happy 2018-11-08 22:20:03 +01:00
Patrick Connolly 3d281b3316 Add ability to show when user is typing across Slack bridges (#559) 2018-11-08 20:45:40 +01:00
Wim 399789811e Make gocritic linter happy 2018-11-08 00:46:34 +01:00
Wim 1794922263 Make unparam linter happy 2018-11-08 00:29:30 +01:00
David Hill 0e2522279e Clean up various stuff (#508)
* various cleanups
2018-11-07 20:36:50 +01:00