Skip to content

Instantly share code, notes, and snippets.

@sk-welldan
Created February 1, 2017 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sk-welldan/ab81cbaefb70d7950b338f4e8721e166 to your computer and use it in GitHub Desktop.
Save sk-welldan/ab81cbaefb70d7950b338f4e8721e166 to your computer and use it in GitHub Desktop.
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