-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdialog_trans.gs
49 lines (44 loc) · 1.23 KB
/
dialog_trans.gs
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
//menuから送金ボタンを押された際の処理
function sendTransDialog(trigger_id) {
// slack channel url (where to send the message)
var slackUrl = "https://slack.com/api/dialog.open";
//get slack access token from properties.
var slack_access_token = PropertiesService.getScriptProperties().getProperty('SLACK_ACCESS_TOKEN');
// message text
var messageData = {
"callback_id": "trigger_trans",
"title": "送金画面",
"submit_label": "送金",
"elements": [
{
"label": "送金価格",
"name": "transPrice",
"type": "text",
"placeholder": "0",
"subtype": "number"
},{
"label": "送金相手",
"name": "recvId",
"type": "select",
"data_source": "users"
}
]
}
// format for Slack
var options = {
method: 'post',
payload: {
"token": slack_access_token,
"trigger_id": trigger_id,
"dialog": JSON.stringify(messageData)
},
};
// post to Slack
return UrlFetchApp.fetch(slackUrl, options);
}
function trans(json) {
var sendId = json.user.id;
var price = parseInt(json.submission.transPrice);
var recvId = json.submission.recvId;
transMoney(recvId, sendId, price);
}