Thumbnail

rani/matterbridge.git

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

Viewing file on branch master

1# Tengo
2More 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
3
4FIXME: Document support for [dropping messages](https://github.com/42wim/matterbridge/pull/1272).
5
6## InMessage
7InMessage allows you to specify the location of a tengo (https://github.com/d5/tengo/) script.
8This script will receive every incoming message and can be used to modify the Username and the Text of that message.
9The script will have the following global variables: \
10to modify: `msgUsername` and `msgText` \
11to read: `msgChannel` and `msgAccount`
12
13The script is reloaded on every message, so you can modify the script on the fly.
14
15Example script can be found in https://github.com/42wim/matterbridge/tree/master/gateway/bench.tengo
16and https://github.com/42wim/matterbridge/tree/master/contrib/example.tengo
17
18The example below will check if the text contains blah and if so, it'll replace the text and the username of that message.
19```
20text := import("text")
21if text.re_match("blah",msgText) {
22 msgText="replaced by this"
23 msgUsername="fakeuser"
24}
25```
26
27Setting: OPTIONAL, RELOADABLE \
28Format: string
29Example:
30
31`InMessage="example.tengo"`
32
33## OutMessage
34OutMessage allows you to specify the location of the script that
35will be invoked on each message being sent to a bridge and can be used to modify the Username
36and the Text of that message.
37
38The script will have the following global variables:
39read-only:
40`inAccount`, `inProtocol`, `inChannel`, `inGateway`, `inEvent`
41`outAccount`, `outProtocol`, `outChannel`, `outGateway`, `outEvent`
42
43read-write:
44`msgText`, `msgUsername`
45
46Notice: `msgUsername` is already formatted by [RemoteNickFormat](https://github.com/42wim/matterbridge/wiki/Settings#remotenickformat) at this point.
47
48The script is reloaded on every message, so you can modify the script on the fly.
49
50The default script in https://github.com/42wim/matterbridge/tree/master/internal/tengo/outmessage.tengo
51is compiled in and will be executed if no script is specified.
52
53**Tengo scripts on a docker instance**
54Place your scripts in `/etc/matterbridge` on the container and reference them with `OutMessage="/etc/matterbridge/example.tengo"`
55
56Setting: OPTIONAL, RELOADABLE \
57Format: string
58Example:
59
60`OutMessage="example.tengo"`
61
62## RemoteNickFormat
63RemoteNickFormat allows you to specify the location of a tengo (https://github.com/d5/tengo/) script.
64The script will have the following global variables: \
65to modify: `result` \
66to read: `channel`, `bridge`, `gateway`, `protocol`, `nick`
67
68The result will be set in `{TENGO}` in the RemoteNickFormat key of every bridge where `{TENGO}` is specified
69
70The script is reloaded on every message, so you can modify the script on the fly.
71
72Example script can be found in https://github.com/42wim/matterbridge/tree/master/contrib/remotenickformat.tengo
73
74Setting: OPTIONAL, RELOADABLE \
75Format: string \
76Example:
77
78`RemoteNickFormat="remotenickformat.tengo"`
79