質問編集履歴
4
コードを変更しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -41,44 +41,11 @@
|
|
41
41
|
if (history && history.continuous) {
|
42
42
|
if (history.text == "70%*2") {
|
43
43
|
reply_text = input_text + " の 軽減率70%×70%での実質HPは\n約 " + Math.floor(input_text / 0.09) + "です";
|
44
|
-
} else if (history.text == "50%*2") {
|
45
|
-
reply_text = input_text + " の 軽減率50%×50%での実質HPは\n約 " + Math.floor(input_text / 0.25) + "です";
|
46
|
-
} else if (history.text == "70%*50%") {
|
47
|
-
reply_text = input_text + " の 軽減率70%×50%での実質HPは\n約 " + Math.floor(input_text / 0.15) + "です";
|
48
|
-
} else if (history.text == "25%*2") {
|
49
|
-
reply_text = input_text + " の 軽減率25%×25%での実質HPは\n約 " + Math.floor(input_text / 0.5625) + "です";
|
50
|
-
} else if (history.text == "75%*2") {
|
51
|
-
reply_text = input_text + " の 軽減率75%×75%での実質HPは\n約 " + Math.floor(input_text / 0.0625) + "です";
|
52
|
-
} else if (history.text == "50%*2+30%*2") {
|
53
|
-
reply_text = input_text + " の 軽減率50%×50%×30%×30%での実質HPは\n約 " + Math.floor(input_text / 0.1225) + "です";
|
54
|
-
} else if (history.text == "50%*2+25%") {
|
55
|
-
reply_text = input_text + " の 軽減率50%×50%×25%での実質HPは\n約 " + Math.floor(input_text / 0.1875) + "です";
|
56
|
-
} else if (history.text == "25%+50%*2") {
|
57
|
-
reply_text = input_text + " の 軽減率25%×50%×50%での実質HPは\n約 " + Math.floor(input_text / 0.1875) + "です";
|
58
|
-
} else if (history.text == "35%*2") {
|
59
|
-
reply_text = input_text + " の 軽減率35%×35の実質HPは\n約 " + Math.floor(input_text / 0.4225) + "です";
|
60
|
-
}
|
61
|
-
|
44
|
+
setLastUserHistory(userId, input_text, false);
|
62
45
|
}
|
63
46
|
else {
|
64
47
|
if (input_text == "70%*2") {
|
65
48
|
reply_text = "軽減率70%×70%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
66
|
-
} else if (input_text == "50%*2") {
|
67
|
-
reply_text = "軽減率50%×50%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
68
|
-
} else if (input_text == "70%*50%") {
|
69
|
-
reply_text = "軽減率70%×50%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
70
|
-
} else if (input_text == "25%*2") {
|
71
|
-
reply_text = "軽減率25%×25%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
72
|
-
}else if (input_text == "75%*2") {
|
73
|
-
reply_text = "軽減率75%×75%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
74
|
-
}else if (input_text == "50%*2+30%*2") {
|
75
|
-
reply_text = "軽減率50%×50%×30%×30%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
76
|
-
} else if (input_text == "35%*2") {
|
77
|
-
reply_text = "軽減率35%×35%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
78
|
-
}else if (input_text == "50%*2+25%") {
|
79
|
-
reply_text = "軽減率50%×50%×25%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
80
|
-
}else if (input_text == "25%+50%*2") {
|
81
|
-
reply_text = "軽減率50%×50%×25%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
82
49
|
}else if (input_text == "その他") {
|
83
50
|
UrlFetchApp.fetch('https://api.line.me/v2/bot/message/push', {
|
84
51
|
'headers': {
|
@@ -168,8 +135,8 @@
|
|
168
135
|
}
|
169
136
|
```
|
170
137
|
|
171
|
-
追記:
|
138
|
+
追記:再度修正しましたが、やはり別のところでエラーが出てしまいます。
|
172
|
-
エラー内容:SyntaxError: Unexpected
|
139
|
+
エラー内容:SyntaxError: Unexpected end of input(行 156、ファイル「コード.gs」)
|
173
140
|
```Javascript
|
174
141
|
function reply_message(e) {
|
175
142
|
var input_text = e.message.text;
|
@@ -195,7 +162,11 @@
|
|
195
162
|
} else if (history.text == "25%+50%*2") {
|
196
163
|
reply_text = input_text + " の 軽減率25%×50%×50%での実質HPは\n約 " + Math.floor(input_text / 0.1875) + "です";
|
197
164
|
} else if (history.text == "35%*2") {
|
198
|
-
reply_text = input_text + " の 軽減率35%×35の実質HPは\n約 " + Math.floor(input_text / 0.4225) + "です";
|
165
|
+
reply_text = input_text + " の 軽減率35%×35%の実質HPは\n約 " + Math.floor(input_text / 0.4225) + "です";
|
166
|
+
} else if (history.text == "35%*25%") {
|
167
|
+
reply_text = input_text + " の 軽減率35%×25%の実質HPは\n約 " + Math.floor(input_text / 0.4875) + "です";
|
168
|
+
} else if (history.text == "25%*35%") {
|
169
|
+
reply_text = input_text + " の 軽減率25%×35%の実質HPは\n約 " + Math.floor(input_text / 0.4875) + "です";
|
199
170
|
}
|
200
171
|
setLastUserHistory(userId, input_text, false);
|
201
172
|
}
|
@@ -216,31 +187,39 @@
|
|
216
187
|
reply_text = "軽減率35%×35%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
217
188
|
}else if (input_text == "50%*2+25%") {
|
218
189
|
reply_text = "軽減率50%×50%×25%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
219
|
-
}else if (input_text == "25%+50%*2") {
|
220
|
-
reply_text = "軽減率50%×50%×25%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
221
190
|
}else if (input_text == "その他") {
|
191
|
+
message = {
|
222
|
-
|
192
|
+
"type": "text",
|
223
|
-
|
193
|
+
"text": "その他の軽減率を設定してください",
|
224
|
-
|
194
|
+
"quickReply": {
|
225
|
-
|
195
|
+
"items": [
|
226
|
-
|
196
|
+
{
|
227
|
-
|
197
|
+
"type": "action",
|
228
|
-
|
198
|
+
"action": {
|
229
|
-
|
199
|
+
"type": "message",
|
230
|
-
|
200
|
+
"label": "A",
|
231
|
-
|
201
|
+
"text": "A"
|
202
|
+
}
|
203
|
+
},
|
204
|
+
{
|
205
|
+
"type": "action",
|
206
|
+
"action": {
|
207
|
+
"type": "message",
|
208
|
+
"label": "B",
|
209
|
+
"text": "B"
|
210
|
+
}
|
211
|
+
},
|
212
|
+
{
|
213
|
+
"type": "action",
|
214
|
+
"action": {
|
215
|
+
"type": "message",
|
216
|
+
"label": "C",
|
217
|
+
"text": "C"
|
218
|
+
}
|
219
|
+
}
|
220
|
+
]
|
221
|
+
}
|
232
222
|
}
|
233
|
-
},
|
234
|
-
{
|
235
|
-
"type": "action",
|
236
|
-
"action": {
|
237
|
-
"type": "postback",
|
238
|
-
"label": "50%×50%"
|
239
|
-
"text": "50%*2"
|
240
|
-
}
|
241
|
-
}
|
242
|
-
]
|
243
|
-
}
|
244
223
|
}if (reply_text) {
|
245
224
|
setLastUserHistory(userId, input_text, true);
|
246
225
|
} else {
|
3
コードを追記しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -166,4 +166,86 @@
|
|
166
166
|
const values = [new Date(), userId, text, continuous];
|
167
167
|
HistorySheet.appendRow(values);
|
168
168
|
}
|
169
|
+
```
|
170
|
+
|
171
|
+
追記:教えていただいた通りに実装しようと試みましたが、エラーが発生してしまいました。
|
172
|
+
エラー内容:SyntaxError: Unexpected token ':'(行 71、ファイル「コード.gs」)
|
173
|
+
```Javascript
|
174
|
+
function reply_message(e) {
|
175
|
+
var input_text = e.message.text;
|
176
|
+
var reply_text = "";
|
177
|
+
const userId = e.source.userId;
|
178
|
+
const history = getLastUserHistory(userId);
|
179
|
+
|
180
|
+
if (history && history.continuous) {
|
181
|
+
if (history.text == "70%*2") {
|
182
|
+
reply_text = input_text + " の 軽減率70%×70%での実質HPは\n約 " + Math.floor(input_text / 0.09) + "です";
|
183
|
+
} else if (history.text == "50%*2") {
|
184
|
+
reply_text = input_text + " の 軽減率50%×50%での実質HPは\n約 " + Math.floor(input_text / 0.25) + "です";
|
185
|
+
} else if (history.text == "70%*50%") {
|
186
|
+
reply_text = input_text + " の 軽減率70%×50%での実質HPは\n約 " + Math.floor(input_text / 0.15) + "です";
|
187
|
+
} else if (history.text == "25%*2") {
|
188
|
+
reply_text = input_text + " の 軽減率25%×25%での実質HPは\n約 " + Math.floor(input_text / 0.5625) + "です";
|
189
|
+
} else if (history.text == "75%*2") {
|
190
|
+
reply_text = input_text + " の 軽減率75%×75%での実質HPは\n約 " + Math.floor(input_text / 0.0625) + "です";
|
191
|
+
} else if (history.text == "50%*2+30%*2") {
|
192
|
+
reply_text = input_text + " の 軽減率50%×50%×30%×30%での実質HPは\n約 " + Math.floor(input_text / 0.1225) + "です";
|
193
|
+
} else if (history.text == "50%*2+25%") {
|
194
|
+
reply_text = input_text + " の 軽減率50%×50%×25%での実質HPは\n約 " + Math.floor(input_text / 0.1875) + "です";
|
195
|
+
} else if (history.text == "25%+50%*2") {
|
196
|
+
reply_text = input_text + " の 軽減率25%×50%×50%での実質HPは\n約 " + Math.floor(input_text / 0.1875) + "です";
|
197
|
+
} else if (history.text == "35%*2") {
|
198
|
+
reply_text = input_text + " の 軽減率35%×35の実質HPは\n約 " + Math.floor(input_text / 0.4225) + "です";
|
199
|
+
}
|
200
|
+
setLastUserHistory(userId, input_text, false);
|
201
|
+
}
|
202
|
+
else {
|
203
|
+
if (input_text == "70%*2") {
|
204
|
+
reply_text = "軽減率70%×70%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
205
|
+
} else if (input_text == "50%*2") {
|
206
|
+
reply_text = "軽減率50%×50%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
207
|
+
} else if (input_text == "70%*50%") {
|
208
|
+
reply_text = "軽減率70%×50%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
209
|
+
} else if (input_text == "25%*2") {
|
210
|
+
reply_text = "軽減率25%×25%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
211
|
+
}else if (input_text == "75%*2") {
|
212
|
+
reply_text = "軽減率75%×75%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
213
|
+
}else if (input_text == "50%*2+30%*2") {
|
214
|
+
reply_text = "軽減率50%×50%×30%×30%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
215
|
+
} else if (input_text == "35%*2") {
|
216
|
+
reply_text = "軽減率35%×35%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
217
|
+
}else if (input_text == "50%*2+25%") {
|
218
|
+
reply_text = "軽減率50%×50%×25%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
219
|
+
}else if (input_text == "25%+50%*2") {
|
220
|
+
reply_text = "軽減率50%×50%×25%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
221
|
+
}else if (input_text == "その他") {
|
222
|
+
"type": "text", // ①
|
223
|
+
"text": "その他の軽減率です。
|
224
|
+
"quickReply": {
|
225
|
+
"items": [
|
226
|
+
{
|
227
|
+
"type": "action",
|
228
|
+
"action": {
|
229
|
+
"type": "postback",
|
230
|
+
"label": "70%×70%"
|
231
|
+
"text": "70%*2"
|
232
|
+
}
|
233
|
+
},
|
234
|
+
{
|
235
|
+
"type": "action",
|
236
|
+
"action": {
|
237
|
+
"type": "postback",
|
238
|
+
"label": "50%×50%"
|
239
|
+
"text": "50%*2"
|
240
|
+
}
|
241
|
+
}
|
242
|
+
]
|
243
|
+
}
|
244
|
+
}if (reply_text) {
|
245
|
+
setLastUserHistory(userId, input_text, true);
|
246
|
+
} else {
|
247
|
+
setLastUserHistory(userId, input_text, false);
|
248
|
+
}
|
249
|
+
}
|
250
|
+
|
169
251
|
```
|
2
コードを記述しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -6,6 +6,10 @@
|
|
6
6
|
といったことが出来る様にしたいです。ご教授のほどよろしくお願いいたします。
|
7
7
|
|
8
8
|
追記:自分なりにクイックリプライ機能を搭載しようと思い、その他という文字が入力されたらクイックリプライを返す。という記述をしたのですが、その他と入力しても何も返ってきませんでした。
|
9
|
+
|
10
|
+
こちらを参考にさせていただきましたが、やはりできませんでした。
|
11
|
+
https://gist.github.com/arukayies/d2773ac02d363226e301503853166936
|
12
|
+
|
9
13
|
```Javascript
|
10
14
|
var ACCESS_TOKEN = "XXXXXX=";
|
11
15
|
var PUSH = "https://api.line.me/v2/bot/message/push";
|
@@ -76,15 +80,45 @@
|
|
76
80
|
}else if (input_text == "25%+50%*2") {
|
77
81
|
reply_text = "軽減率50%×50%×25%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
78
82
|
}else if (input_text == "その他") {
|
83
|
+
UrlFetchApp.fetch('https://api.line.me/v2/bot/message/push', {
|
84
|
+
'headers': {
|
85
|
+
'Content-Type': 'application/json',
|
86
|
+
'Authorization': 'Bearer ' + prop.TOKEN, // スクリプトプロパティにトークンは事前に追加しておく
|
87
|
+
},
|
88
|
+
'method': 'POST',
|
89
|
+
'payload': JSON.stringify({
|
90
|
+
"to": prop.DEBUGID, // スクリプトプロパティに送信先IDは事前に追加しておく
|
91
|
+
"messages": [
|
92
|
+
{
|
93
|
+
"type": "text",
|
94
|
+
"text": "選択してください!",
|
79
|
-
|
95
|
+
"quickReply": {
|
80
|
-
|
96
|
+
"items": [
|
97
|
+
{
|
98
|
+
"type": "action",
|
99
|
+
"imageUrl": "https://example.com/sushi.png",
|
100
|
+
"action": {
|
81
|
-
|
101
|
+
"type": "message",
|
82
|
-
|
102
|
+
"label": "A",
|
103
|
+
"text": "70%*2"
|
104
|
+
}
|
105
|
+
},
|
106
|
+
{
|
107
|
+
"type": "action",
|
83
|
-
|
108
|
+
"imageUrl": "https://example.com/sushi.png",
|
109
|
+
"action": {
|
110
|
+
"type": "message",
|
111
|
+
"label": "B",
|
84
|
-
|
112
|
+
"text": "50%*2"
|
113
|
+
}
|
114
|
+
}
|
115
|
+
]
|
116
|
+
}
|
117
|
+
}
|
85
|
-
|
118
|
+
],
|
119
|
+
"notificationDisabled": false // trueだとユーザーに通知されない
|
86
|
-
|
120
|
+
}),
|
87
|
-
|
121
|
+
});
|
88
122
|
}if (reply_text) {
|
89
123
|
setLastUserHistory(userId, input_text, true);
|
90
124
|
} else {
|
1
コードを記述しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -4,6 +4,8 @@
|
|
4
4
|
↓
|
5
5
|
・**10~12個の文字列一覧をクイックリプライにて表示**
|
6
6
|
といったことが出来る様にしたいです。ご教授のほどよろしくお願いいたします。
|
7
|
+
|
8
|
+
追記:自分なりにクイックリプライ機能を搭載しようと思い、その他という文字が入力されたらクイックリプライを返す。という記述をしたのですが、その他と入力しても何も返ってきませんでした。
|
7
9
|
```Javascript
|
8
10
|
var ACCESS_TOKEN = "XXXXXX=";
|
9
11
|
var PUSH = "https://api.line.me/v2/bot/message/push";
|
@@ -35,25 +37,55 @@
|
|
35
37
|
if (history && history.continuous) {
|
36
38
|
if (history.text == "70%*2") {
|
37
39
|
reply_text = input_text + " の 軽減率70%×70%での実質HPは\n約 " + Math.floor(input_text / 0.09) + "です";
|
38
|
-
} else if (history.text == "50%*
|
40
|
+
} else if (history.text == "50%*2") {
|
39
|
-
reply_text = input_text + " の 軽減率
|
41
|
+
reply_text = input_text + " の 軽減率50%×50%での実質HPは\n約 " + Math.floor(input_text / 0.25) + "です";
|
40
42
|
} else if (history.text == "70%*50%") {
|
41
43
|
reply_text = input_text + " の 軽減率70%×50%での実質HPは\n約 " + Math.floor(input_text / 0.15) + "です";
|
42
44
|
} else if (history.text == "25%*2") {
|
43
45
|
reply_text = input_text + " の 軽減率25%×25%での実質HPは\n約 " + Math.floor(input_text / 0.5625) + "です";
|
46
|
+
} else if (history.text == "75%*2") {
|
47
|
+
reply_text = input_text + " の 軽減率75%×75%での実質HPは\n約 " + Math.floor(input_text / 0.0625) + "です";
|
48
|
+
} else if (history.text == "50%*2+30%*2") {
|
49
|
+
reply_text = input_text + " の 軽減率50%×50%×30%×30%での実質HPは\n約 " + Math.floor(input_text / 0.1225) + "です";
|
50
|
+
} else if (history.text == "50%*2+25%") {
|
51
|
+
reply_text = input_text + " の 軽減率50%×50%×25%での実質HPは\n約 " + Math.floor(input_text / 0.1875) + "です";
|
52
|
+
} else if (history.text == "25%+50%*2") {
|
53
|
+
reply_text = input_text + " の 軽減率25%×50%×50%での実質HPは\n約 " + Math.floor(input_text / 0.1875) + "です";
|
54
|
+
} else if (history.text == "35%*2") {
|
55
|
+
reply_text = input_text + " の 軽減率35%×35の実質HPは\n約 " + Math.floor(input_text / 0.4225) + "です";
|
44
56
|
}
|
45
57
|
setLastUserHistory(userId, input_text, false);
|
46
58
|
}
|
47
59
|
else {
|
48
60
|
if (input_text == "70%*2") {
|
49
61
|
reply_text = "軽減率70%×70%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
50
|
-
} else if (input_text == "
|
62
|
+
} else if (input_text == "50%*2") {
|
51
63
|
reply_text = "軽減率50%×50%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
52
|
-
} else if (input_text == "
|
64
|
+
} else if (input_text == "70%*50%") {
|
53
65
|
reply_text = "軽減率70%×50%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
54
66
|
} else if (input_text == "25%*2") {
|
55
67
|
reply_text = "軽減率25%×25%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
68
|
+
}else if (input_text == "75%*2") {
|
69
|
+
reply_text = "軽減率75%×75%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
70
|
+
}else if (input_text == "50%*2+30%*2") {
|
71
|
+
reply_text = "軽減率50%×50%×30%×30%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
72
|
+
} else if (input_text == "35%*2") {
|
73
|
+
reply_text = "軽減率35%×35%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
74
|
+
}else if (input_text == "50%*2+25%") {
|
75
|
+
reply_text = "軽減率50%×50%×25%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
76
|
+
}else if (input_text == "25%+50%*2") {
|
77
|
+
reply_text = "軽減率50%×50%×25%で計算します。\n計算したいパーティーの最大HPを、半角英数字でカンマ区切りをせずに入力してください。";
|
78
|
+
}else if (input_text == "その他") {
|
79
|
+
line_bot_api.reply_message(
|
80
|
+
event.reply_token,
|
81
|
+
TextSendMessage(text="一覧から選んでね",
|
82
|
+
quick_reply=QuickReply(items=[
|
83
|
+
QuickReplyButton(action=MessageAction(label="70%×70%", text="70%*2")),
|
84
|
+
QuickReplyButton(action=MessageAction(label="50%×50%", text="50%*2")),
|
85
|
+
])
|
86
|
+
)
|
87
|
+
)
|
56
|
-
}
|
88
|
+
}if (reply_text) {
|
57
89
|
setLastUserHistory(userId, input_text, true);
|
58
90
|
} else {
|
59
91
|
setLastUserHistory(userId, input_text, false);
|