mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-06-26 14:19:24 +00:00
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.
This commit is contained in:
19
internal/tengo/outmessage.tengo
Normal file
19
internal/tengo/outmessage.tengo
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
variables available
|
||||
read-only:
|
||||
inAccount, inProtocol, inChannel, inGateway
|
||||
outAccount, outProtocol, outChannel, outGateway
|
||||
|
||||
read-write:
|
||||
msgText, msgUsername
|
||||
*/
|
||||
|
||||
text := import("text")
|
||||
|
||||
// start - strip irc colors
|
||||
// if we're not sending to an irc bridge we strip the IRC colors
|
||||
if inProtocol == "irc" {
|
||||
re := text.re_compile(`\x03(?:\d{1,2}(?:,\d{1,2})?)?|[[:cntrl:]]`)
|
||||
msgText=re.replace(msgText,"")
|
||||
}
|
||||
// end - strip irc colors
|
Reference in New Issue
Block a user