Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Elivia Plugins
## format
![Screenshot from 2020-08-04 15-36-29](/home/qwexta/Pictures/Screenshot from 2020-08-04 15-36-29.png)
All the plugins are located in the "package" directory.
They all have the same architecture :
* `.go` file making the code of the module
* a resource folder `res` that holds the triggers and response of all languages
### triggers.json
holds a json array of handlers
those handlers are relative to a specific function of the plugins although multiple handlers with different pattern can be link to the same function
the object is defined as follow
```json
{
"entries": [] // optional will be explain more in depth after
"pattern": [] // the format of the sentence you want to match
"olivia-feed": [] // temporary and mendary, helps the IA to recognize your sentence from various exemple
"callback": "" // the function you want to be called then this pattern is uncountered
}
```
the "pattern", "feed", and "callback" may seems straight forward, yet, the entries needs a bit more explainations
### Entries
Entry helps to retreive element from the string you match, note that you should leave a blank in the pattern if you want to catch something there.
entries are composed of 3 elements
```json
{
"name":""
"parser":""
"resources": {}
}
```
the name is string you will use to retreive that entry within your code.
the parser is the function that will be called to find out your entry, 3 of them are available nowadays :
* after : gets the rest of the string after the match
it uses a specific ressourse to define the match requieres
```json
"ressources":{
"key":"" // the needle you want to find, will not be included in the selection
"x":0 // the xth occurence of the key before considering it a match
// note that you can set it with negative value to get the x nth last // element
}
```
* before : works the same as after but gets everything before, match not included
* between : gets everything between the 2 matchs
it also define a resource format to match its need
```json
"ressources":{
"after": "", // The key for the starting match
"x": 0, // the x for the starting match
"before": "",// the key for the starting match
"y": 0 // the x for the starting match
}
```