RobotSpec
メッセージ受信イベントの正規表現の省略や、受信したテキストメッセージ内容の取得を容易に行うことができるdaab開発の為のパッケージ
Require
node6+
Usage
・メッセージ内容の簡易取得
scripts/app.js
const RobotSpec = ; module { const robot2 = robot; robot2; robot2; robot2; robot2; };
・メソッドのキャッシュと呼び出し
scripts/app.js
const RobotSpec = ; module { const robot2 = robot; const spec = robot2spec; robot2; robot2; robot2; robot; robot2; robot2; };
・メソッドの初期化を行う(constructorの実行)
initialize
const robot2 = robot;const spec = robot2spec;
robot2.spec
キャッシュしたメソッドの利用
scripts/app.js
const robot2 = robot;const spec = robot2spec; specscenariomethod;// orrobot2;
別のモジュールではもう一度呼び出して使用することも可能
const spec = ; specscenariomethod;
コンポーネント設定
ディレクトリ構造
scripts/app.jssrc├── components.js
コアメソッドのキャッシュ
src/components.js
'use strict'; const components = robot config // scenario scenario: './scenario/common' task: './scenario/task'; moduleexports = components;
cache method
メソッドのキャッシュ
ディレクトリ構造
scripts/app.jssrc├── scenario│ ├── common│ │ ├── index.js // *│ │ ├── join-home.js│ │ ├── select-action-admin.js│ │ ├── select-receive.js│ │ ├── stamp-receive.js│ │ ├── text-action-admin.js│ │ └── text-receive.js
scenario/common/index.js
'use strict'; { components; } moduleexports = Common;
クラス
'use strict'; { thisspec = spec; } { return thisspecapiSchedule; } moduleexports = Schedules;
メソッド
scenario/common/join-home.js
'use strict'; const joinHome = { return { return messages; };}; moduleexports = joinHome;
クラス、メソッド共にモジュールから読み込む方法でも可能
(再掲)
const spec = ; specscenariomethod;
クラス、メソッドのキャッシュ
scripts/app.js
メソッドのディレクトリ設定
robot;
opts
の設定を変更することで、各設置ディレクトリの変更が可能です。
opts
デフォルト
opts = root: 'src/' config: 'src/config' components: 'src/components';
config.js
は定数を定義し、グローバル利用できます。
利用しない場合は、false
を設定します。
opts = root: 'src/' config: false components: 'src/components';
config.js
を利用し、components.js
(メソッドキャッシュ)を利用しない場合は、
下記のように、components
にfalse
を設定します。
opts = root: 'src/' config: 'src/config' components: false;
または、components
のみ設定します。
opts = components: false;
グローバル定数
src/config.js
const g = {};
g.ADMIN_USER = 'xxxxxxxx';
g.ADMIN_PASS = 'xxxxxxxx';
module.exports = g;