Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
MESH + IFTTT + Slackで差入れボックスを作成する ref: http://qiita.com/sk-welldan/items/079a97fb9d5ee41d5c5d
properties.openCount = runtimeValues.openCount;
properties.singlePush = runtimeValues.sPushCount;
properties.doublePush = runtimeValues.count;
if ( runtimeValues.outputIndex == 3 ) {
//slackWebAPI
var apiURL = 'https://slack.com/api/chat.postMessage';
//APIを叩く際のパラメータ
//プロパティの値を渡す
var data = {
token : 'xxxxxx', //取得したトークン
channel : '#general', //どのチャンネルに
username : 'name', //送信するユーザー
text : '差し入れなくなりました!!' + runtimeValues.messageText
};
ajax({
url : apiURL,
data : data,
type : "GET",
timeout : 5000,
success : function ( data ) {
log("OK:" + runtimeValues.messageText);
}
});
}
return {
runtimeValues : runtimeValues,
resultType : "continue" //処理を継続
};
return {
// 変数を定義し初期化
runtimeValues : { outputIndex : -1
,openCount : properties.openCount
,count : properties.doublePush
,sPushCount : properties.singlePush
,messageText : ""}
}
runtimeValues.outputIndex = index;
switch ( index ){
case 0:
runtimeValues.openCount++;
break;
case 1:
runtimeValues.sPushCount++;
break;
case 2:
runtimeValues.count++;
break;
case 3:
var msgVal = {};
msgVal.msgtext = "\n ◆箱が空いた回数:" + runtimeValues.openCount + "\n"
+ " ◆ありがとうの回数:" + runtimeValues.sPushCount + "\n"
+ " ◆「美味しい」いただいた回数:"
+ runtimeValues.count;
runtimeValues.messageText = msgVal.msgtext;
runtimeValues.openCount = 0;
runtimeValues.sPushCount = 0;
runtimeValues.count = 0;
break;
}
return {
runtimeValues : runtimeValues,
resultType : "continue" //処理を継続
};
return {
// 変数を定義し初期化
runtimeValues : { outputIndex : -1
,openCount : properties.openCount
,count : properties.doublePush
,sPushCount : properties.singlePush
,messageText : ""}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment