File tree Expand file tree Collapse file tree 1 file changed +35
-1
lines changed Expand file tree Collapse file tree 1 file changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -153,6 +153,40 @@ webot.set('domain-1 act-2', {
153153So when ` / some pattern/ ` and ` / another pattern/ ` is matched, webot will run into the ` domain- 1 ` middleware first,
154154to check whether user is logged in.
155155
156+ ### webot.loads(file1, _[file2, ...]_)
157+
158+ 载入 nodejs 模块作为 webot 的回复规则,以方便你在比较复杂的项目中组织文件。
159+
160+ file1, file2 是相对于调用此方法的文件所在目录的文件名。
161+
162+
163+ ` ` ` javascript
164+ webot .loads (' ./rules/a' , ' ./rules.b' );
165+ ` ` `
166+
167+ In file ` ./ rules/ a .js ` and ` ./ rules/ b .js ` :
168+
169+ ` ` ` javascript
170+ module .exports = function (webot ) {
171+ webot .set (' rule_a' , function (info , next ) {
172+ // ...
173+ });
174+ webot .set (' rule_a_1' , ' some reply' );
175+ };
176+ ` ` `
177+
178+ or use single Rule defination:
179+
180+ ` ` `
181+ module .exports = {
182+ pattern: / some pattern/ ,
183+ handler : function (info , next ) {
184+ // ...
185+ },
186+ };
187+ ` ` `
188+
189+
156190### webot.dialog(file1, _[file2, ...]_)
157191
158192增加对话规则
@@ -195,7 +229,7 @@ In your `app.js`:
195229` ` ` javascript
196230require (' js-yaml' );
197231
198- webot .dialog (__dirname__ + ' ./rules/abc.yaml' );
232+ webot .dialog (' ./rules/abc.yaml' );
199233` ` `
200234
201235In ` rules/ abc .yaml ` :
You can’t perform that action at this time.
0 commit comments