@lotus-tree/fg-notation 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dev/img/games/gg/rc.png +0 -0
- package/dev/index.js +13 -9
- package/lib/index.js +490 -486
- package/package.json +7 -5
- package/src/index.js +7 -2
package/README.md
CHANGED
@@ -46,7 +46,7 @@ Follow instructions on how to add to a Louts-Tree bot on [this link](https://git
|
|
46
46
|
|
47
47
|
## Credits
|
48
48
|
|
49
|
-
[Infil's Fighting Game Glossary](https://glossary.infil.net)
|
49
|
+
[Infil's Fighting Game Glossary](https://glossary.infil.net)
|
50
50
|
|
51
51
|
[MagicianStuff's Fighthing Game notations emotes](https://twitter.com/MagicianStuff/status/1477931054484893697)
|
52
52
|
|
@@ -58,6 +58,7 @@ Follow instructions on how to add to a Louts-Tree bot on [this link](https://git
|
|
58
58
|
|
59
59
|
- Added "rc" as a valid input for Guilty Gear
|
60
60
|
- More descriptive message when "fgglossary" finds multiple matching terms
|
61
|
+
- Being a dark sea
|
61
62
|
|
62
63
|
### 1.1.0
|
63
64
|
|
Binary file
|
package/dev/index.js
CHANGED
@@ -23,7 +23,9 @@ var _glob = _interopRequireDefault(require("glob"));
|
|
23
23
|
|
24
24
|
var _sequelize = require("sequelize");
|
25
25
|
|
26
|
-
var
|
26
|
+
var _bent = _interopRequireDefault(require("bent"));
|
27
|
+
|
28
|
+
var getJSON = (0, _bent["default"])('json');
|
27
29
|
|
28
30
|
var imgPath = _path["default"].join(__dirname, 'img');
|
29
31
|
|
@@ -45,13 +47,11 @@ function _getGlossary() {
|
|
45
47
|
while (1) {
|
46
48
|
switch (_context6.prev = _context6.next) {
|
47
49
|
case 0:
|
48
|
-
_context6.
|
49
|
-
|
50
|
-
return (0, _requestPromise["default"])('https://glossary.infil.net/json/glossary.json');
|
50
|
+
_context6.next = 2;
|
51
|
+
return getJSON('https://glossary.infil.net/json/glossary.json');
|
51
52
|
|
52
|
-
case
|
53
|
-
|
54
|
-
result = _context6.t0.parse.call(_context6.t0, _context6.t1);
|
53
|
+
case 2:
|
54
|
+
result = _context6.sent;
|
55
55
|
tempG = {};
|
56
56
|
tempT = [];
|
57
57
|
result.forEach(function (i) {
|
@@ -62,7 +62,7 @@ function _getGlossary() {
|
|
62
62
|
glossary = tempG;
|
63
63
|
terms = tempT;
|
64
64
|
|
65
|
-
case
|
65
|
+
case 8:
|
66
66
|
case "end":
|
67
67
|
return _context6.stop();
|
68
68
|
}
|
@@ -158,6 +158,10 @@ var builtin = {
|
|
158
158
|
};
|
159
159
|
var _default = {
|
160
160
|
name: 'fg-notation',
|
161
|
+
about: {
|
162
|
+
name: 'FG Notation',
|
163
|
+
value: '[Instructions and source code](https://lotus.chitowarlock.com/fgnotation)\n[Infil\'s Fighting Game Glossary](https://glossary.infil.net)\n[MagicianStuff\'s Fighthing Game notations emotes](https://twitter.com/MagicianStuff/status/1477931054484893697)'
|
164
|
+
},
|
161
165
|
intents: ['GUILD_MESSAGES'],
|
162
166
|
partials: ['MESSAGE'],
|
163
167
|
preload: function preload(sequelize) {
|
@@ -465,7 +469,7 @@ var _default = {
|
|
465
469
|
return _context5.abrupt("return", message.reply("```".concat(glossary[result[0]].def, "```Source: <").concat(url, ">")));
|
466
470
|
|
467
471
|
case 12:
|
468
|
-
message.reply(url);
|
472
|
+
message.reply("Multiple terms found: ".concat(url));
|
469
473
|
|
470
474
|
case 13:
|
471
475
|
case "end":
|
package/lib/index.js
CHANGED
@@ -1,487 +1,491 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
6
|
-
value: true
|
7
|
-
});
|
8
|
-
exports["default"] = void 0;
|
9
|
-
|
10
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
11
|
-
|
12
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
13
|
-
|
14
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
15
|
-
|
16
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
17
|
-
|
18
|
-
var _sharp = _interopRequireDefault(require("sharp"));
|
19
|
-
|
20
|
-
var _path = _interopRequireDefault(require("path"));
|
21
|
-
|
22
|
-
var _glob = _interopRequireDefault(require("glob"));
|
23
|
-
|
24
|
-
var _sequelize = require("sequelize");
|
25
|
-
|
26
|
-
var
|
27
|
-
|
28
|
-
var
|
29
|
-
|
30
|
-
var
|
31
|
-
|
32
|
-
var
|
33
|
-
var
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
result = _context6.
|
55
|
-
tempG = {};
|
56
|
-
tempT = [];
|
57
|
-
result.forEach(function (i) {
|
58
|
-
var term = i.term.toLowerCase();
|
59
|
-
tempG[term] = i;
|
60
|
-
tempT.push(term);
|
61
|
-
});
|
62
|
-
glossary = tempG;
|
63
|
-
terms = tempT;
|
64
|
-
|
65
|
-
case
|
66
|
-
case "end":
|
67
|
-
return _context6.stop();
|
68
|
-
}
|
69
|
-
}
|
70
|
-
}, _callee6);
|
71
|
-
}));
|
72
|
-
return _getGlossary.apply(this, arguments);
|
73
|
-
}
|
74
|
-
|
75
|
-
_glob["default"].sync(_path["default"].join(imgPath, 'basic/**'), {
|
76
|
-
nodir: true
|
77
|
-
}).forEach(function (p) {
|
78
|
-
var input = p.split('/').pop().replace('.png', '');
|
79
|
-
basicInputs.set(input, p);
|
80
|
-
});
|
81
|
-
|
82
|
-
basicInputs.set('>>', _path["default"].join(imgPath, 'basic/doubleforward.png'));
|
83
|
-
|
84
|
-
_glob["default"].sync(_path["default"].join(imgPath, 'games/**'), {
|
85
|
-
nodir: true
|
86
|
-
}).forEach(function (p) {
|
87
|
-
var _path$parse = _path["default"].parse(_path["default"].relative(_path["default"].join(imgPath, 'games'), p)),
|
88
|
-
dir = _path$parse.dir,
|
89
|
-
name = _path$parse.name;
|
90
|
-
|
91
|
-
if (!gameInputs.has(dir)) gameInputs.set(dir, new Map());
|
92
|
-
gameInputs.get(dir).set(name, p);
|
93
|
-
});
|
94
|
-
|
95
|
-
function solveInput(inputs, input) {
|
96
|
-
if (inputs.has(input)) return [input];
|
97
|
-
|
98
|
-
for (var i = 0; i < input.length; i++) {
|
99
|
-
var s1 = input.slice(0, 0 - i);
|
100
|
-
if (inputs.has(s1)) return [s1].concat((0, _toConsumableArray2["default"])(solveInput(inputs, input.slice(0 - i))));
|
101
|
-
}
|
102
|
-
|
103
|
-
throw new Error("Cannot find \"".concat(input, "\" as a recognizable input"));
|
104
|
-
}
|
105
|
-
|
106
|
-
function sendInput(_x, _x2, _x3, _x4) {
|
107
|
-
return _sendInput.apply(this, arguments);
|
108
|
-
}
|
109
|
-
|
110
|
-
function _sendInput() {
|
111
|
-
_sendInput = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7(inputs, result, message, caption) {
|
112
|
-
var canvas;
|
113
|
-
return _regenerator["default"].wrap(function _callee7$(_context7) {
|
114
|
-
while (1) {
|
115
|
-
switch (_context7.prev = _context7.next) {
|
116
|
-
case 0:
|
117
|
-
_context7.next = 2;
|
118
|
-
return (0, _sharp["default"])({
|
119
|
-
create: {
|
120
|
-
width: 152 * result.length,
|
121
|
-
height: 152,
|
122
|
-
channels: 4,
|
123
|
-
background: 'transparent'
|
124
|
-
}
|
125
|
-
}).composite(result.map(function (it, index) {
|
126
|
-
return {
|
127
|
-
input: inputs.get(it),
|
128
|
-
left: index * 152,
|
129
|
-
top: 0,
|
130
|
-
width: 152,
|
131
|
-
height: 152
|
132
|
-
};
|
133
|
-
})).png().toBuffer();
|
134
|
-
|
135
|
-
case 2:
|
136
|
-
canvas = _context7.sent;
|
137
|
-
return _context7.abrupt("return", message.reply({
|
138
|
-
content: caption,
|
139
|
-
files: [canvas]
|
140
|
-
}));
|
141
|
-
|
142
|
-
case 4:
|
143
|
-
case "end":
|
144
|
-
return _context7.stop();
|
145
|
-
}
|
146
|
-
}
|
147
|
-
}, _callee7);
|
148
|
-
}));
|
149
|
-
return _sendInput.apply(this, arguments);
|
150
|
-
}
|
151
|
-
|
152
|
-
var builtin = {
|
153
|
-
37: {
|
154
|
-
game: 'sf',
|
155
|
-
caption: '***LETS GO JUSTIN!***',
|
156
|
-
input: '6 6 6 6 6 6 6 >> 6 6 6 6 6 6 6 >> 8 6 j. hk >> 2 mk >> 623 mp >> 236 236 lk'
|
157
|
-
}
|
158
|
-
};
|
159
|
-
var _default = {
|
160
|
-
name: 'fg-notation',
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
type: _sequelize.DataTypes.STRING,
|
171
|
-
primaryKey: true
|
172
|
-
},
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
}
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
case
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
}
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
return
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
_context4.
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
case
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
}
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
case
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
}
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
6
|
+
value: true
|
7
|
+
});
|
8
|
+
exports["default"] = void 0;
|
9
|
+
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
11
|
+
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
13
|
+
|
14
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
15
|
+
|
16
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
17
|
+
|
18
|
+
var _sharp = _interopRequireDefault(require("sharp"));
|
19
|
+
|
20
|
+
var _path = _interopRequireDefault(require("path"));
|
21
|
+
|
22
|
+
var _glob = _interopRequireDefault(require("glob"));
|
23
|
+
|
24
|
+
var _sequelize = require("sequelize");
|
25
|
+
|
26
|
+
var _bent = _interopRequireDefault(require("bent"));
|
27
|
+
|
28
|
+
var getJSON = (0, _bent["default"])('json');
|
29
|
+
|
30
|
+
var imgPath = _path["default"].join(__dirname, 'img');
|
31
|
+
|
32
|
+
var basicInputs = new Map();
|
33
|
+
var gameInputs = new Map();
|
34
|
+
var glossary = {};
|
35
|
+
var terms = [];
|
36
|
+
getGlossary();
|
37
|
+
setInterval(getGlossary, 5 * 60 * 1000);
|
38
|
+
|
39
|
+
function getGlossary() {
|
40
|
+
return _getGlossary.apply(this, arguments);
|
41
|
+
}
|
42
|
+
|
43
|
+
function _getGlossary() {
|
44
|
+
_getGlossary = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
|
45
|
+
var result, tempG, tempT;
|
46
|
+
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
47
|
+
while (1) {
|
48
|
+
switch (_context6.prev = _context6.next) {
|
49
|
+
case 0:
|
50
|
+
_context6.next = 2;
|
51
|
+
return getJSON('https://glossary.infil.net/json/glossary.json');
|
52
|
+
|
53
|
+
case 2:
|
54
|
+
result = _context6.sent;
|
55
|
+
tempG = {};
|
56
|
+
tempT = [];
|
57
|
+
result.forEach(function (i) {
|
58
|
+
var term = i.term.toLowerCase();
|
59
|
+
tempG[term] = i;
|
60
|
+
tempT.push(term);
|
61
|
+
});
|
62
|
+
glossary = tempG;
|
63
|
+
terms = tempT;
|
64
|
+
|
65
|
+
case 8:
|
66
|
+
case "end":
|
67
|
+
return _context6.stop();
|
68
|
+
}
|
69
|
+
}
|
70
|
+
}, _callee6);
|
71
|
+
}));
|
72
|
+
return _getGlossary.apply(this, arguments);
|
73
|
+
}
|
74
|
+
|
75
|
+
_glob["default"].sync(_path["default"].join(imgPath, 'basic/**'), {
|
76
|
+
nodir: true
|
77
|
+
}).forEach(function (p) {
|
78
|
+
var input = p.split('/').pop().replace('.png', '');
|
79
|
+
basicInputs.set(input, p);
|
80
|
+
});
|
81
|
+
|
82
|
+
basicInputs.set('>>', _path["default"].join(imgPath, 'basic/doubleforward.png'));
|
83
|
+
|
84
|
+
_glob["default"].sync(_path["default"].join(imgPath, 'games/**'), {
|
85
|
+
nodir: true
|
86
|
+
}).forEach(function (p) {
|
87
|
+
var _path$parse = _path["default"].parse(_path["default"].relative(_path["default"].join(imgPath, 'games'), p)),
|
88
|
+
dir = _path$parse.dir,
|
89
|
+
name = _path$parse.name;
|
90
|
+
|
91
|
+
if (!gameInputs.has(dir)) gameInputs.set(dir, new Map());
|
92
|
+
gameInputs.get(dir).set(name, p);
|
93
|
+
});
|
94
|
+
|
95
|
+
function solveInput(inputs, input) {
|
96
|
+
if (inputs.has(input)) return [input];
|
97
|
+
|
98
|
+
for (var i = 0; i < input.length; i++) {
|
99
|
+
var s1 = input.slice(0, 0 - i);
|
100
|
+
if (inputs.has(s1)) return [s1].concat((0, _toConsumableArray2["default"])(solveInput(inputs, input.slice(0 - i))));
|
101
|
+
}
|
102
|
+
|
103
|
+
throw new Error("Cannot find \"".concat(input, "\" as a recognizable input"));
|
104
|
+
}
|
105
|
+
|
106
|
+
function sendInput(_x, _x2, _x3, _x4) {
|
107
|
+
return _sendInput.apply(this, arguments);
|
108
|
+
}
|
109
|
+
|
110
|
+
function _sendInput() {
|
111
|
+
_sendInput = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7(inputs, result, message, caption) {
|
112
|
+
var canvas;
|
113
|
+
return _regenerator["default"].wrap(function _callee7$(_context7) {
|
114
|
+
while (1) {
|
115
|
+
switch (_context7.prev = _context7.next) {
|
116
|
+
case 0:
|
117
|
+
_context7.next = 2;
|
118
|
+
return (0, _sharp["default"])({
|
119
|
+
create: {
|
120
|
+
width: 152 * result.length,
|
121
|
+
height: 152,
|
122
|
+
channels: 4,
|
123
|
+
background: 'transparent'
|
124
|
+
}
|
125
|
+
}).composite(result.map(function (it, index) {
|
126
|
+
return {
|
127
|
+
input: inputs.get(it),
|
128
|
+
left: index * 152,
|
129
|
+
top: 0,
|
130
|
+
width: 152,
|
131
|
+
height: 152
|
132
|
+
};
|
133
|
+
})).png().toBuffer();
|
134
|
+
|
135
|
+
case 2:
|
136
|
+
canvas = _context7.sent;
|
137
|
+
return _context7.abrupt("return", message.reply({
|
138
|
+
content: caption,
|
139
|
+
files: [canvas]
|
140
|
+
}));
|
141
|
+
|
142
|
+
case 4:
|
143
|
+
case "end":
|
144
|
+
return _context7.stop();
|
145
|
+
}
|
146
|
+
}
|
147
|
+
}, _callee7);
|
148
|
+
}));
|
149
|
+
return _sendInput.apply(this, arguments);
|
150
|
+
}
|
151
|
+
|
152
|
+
var builtin = {
|
153
|
+
37: {
|
154
|
+
game: 'sf',
|
155
|
+
caption: '***LETS GO JUSTIN!***',
|
156
|
+
input: '6 6 6 6 6 6 6 >> 6 6 6 6 6 6 6 >> 8 6 j. hk >> 2 mk >> 623 mp >> 236 236 lk'
|
157
|
+
}
|
158
|
+
};
|
159
|
+
var _default = {
|
160
|
+
name: 'fg-notation',
|
161
|
+
about: {
|
162
|
+
name: 'FG Notation',
|
163
|
+
value: '[Instructions and source code](https://lotus.chitowarlock.com/fgnotation)\n[Infil\'s Fighting Game Glossary](https://glossary.infil.net)\n[MagicianStuff\'s Fighthing Game notations emotes](https://twitter.com/MagicianStuff/status/1477931054484893697)'
|
164
|
+
},
|
165
|
+
intents: ['GUILD_MESSAGES'],
|
166
|
+
partials: ['MESSAGE'],
|
167
|
+
preload: function preload(sequelize) {
|
168
|
+
sequelize.define('fginput', {
|
169
|
+
guild: {
|
170
|
+
type: _sequelize.DataTypes.STRING,
|
171
|
+
primaryKey: true
|
172
|
+
},
|
173
|
+
name: {
|
174
|
+
type: _sequelize.DataTypes.STRING,
|
175
|
+
primaryKey: true
|
176
|
+
},
|
177
|
+
createdBy: _sequelize.DataTypes.STRING,
|
178
|
+
game: _sequelize.DataTypes.STRING,
|
179
|
+
caption: _sequelize.DataTypes.STRING,
|
180
|
+
input: _sequelize.DataTypes.STRING
|
181
|
+
});
|
182
|
+
},
|
183
|
+
events: {
|
184
|
+
messageCreate: function messageCreate(global, message) {
|
185
|
+
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
186
|
+
var client, config, sequelize, guildId, prefix, name, row, inputs;
|
187
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
188
|
+
while (1) {
|
189
|
+
switch (_context.prev = _context.next) {
|
190
|
+
case 0:
|
191
|
+
client = global.client, config = global.config, sequelize = global.sequelize;
|
192
|
+
|
193
|
+
if (!(message.author.id === client.user.id || !message.member)) {
|
194
|
+
_context.next = 3;
|
195
|
+
break;
|
196
|
+
}
|
197
|
+
|
198
|
+
return _context.abrupt("return");
|
199
|
+
|
200
|
+
case 3:
|
201
|
+
guildId = message.guildId;
|
202
|
+
prefix = config[guildId].prefix;
|
203
|
+
|
204
|
+
if (!message.content.startsWith(prefix)) {
|
205
|
+
_context.next = 14;
|
206
|
+
break;
|
207
|
+
}
|
208
|
+
|
209
|
+
name = message.content.split(' ').pop().replace(prefix, '');
|
210
|
+
_context.t0 = builtin[name];
|
211
|
+
|
212
|
+
if (_context.t0) {
|
213
|
+
_context.next = 12;
|
214
|
+
break;
|
215
|
+
}
|
216
|
+
|
217
|
+
_context.next = 11;
|
218
|
+
return sequelize.models.fginput.findOne({
|
219
|
+
where: {
|
220
|
+
guild: message.guild.id,
|
221
|
+
name: name
|
222
|
+
}
|
223
|
+
});
|
224
|
+
|
225
|
+
case 11:
|
226
|
+
_context.t0 = _context.sent;
|
227
|
+
|
228
|
+
case 12:
|
229
|
+
row = _context.t0;
|
230
|
+
|
231
|
+
if (row) {
|
232
|
+
inputs = new Map([].concat((0, _toConsumableArray2["default"])(basicInputs), (0, _toConsumableArray2["default"])(gameInputs.get(row.game))));
|
233
|
+
sendInput(inputs, row.input.split(' '), message, row.caption);
|
234
|
+
}
|
235
|
+
|
236
|
+
case 14:
|
237
|
+
case "end":
|
238
|
+
return _context.stop();
|
239
|
+
}
|
240
|
+
}
|
241
|
+
}, _callee);
|
242
|
+
}))();
|
243
|
+
}
|
244
|
+
},
|
245
|
+
commands: {
|
246
|
+
fgi: {
|
247
|
+
usage: 'fgi [game] [inputs]',
|
248
|
+
desc: 'Converts a list of inputs into an image',
|
249
|
+
example: 'fgi sf 236P 214K',
|
250
|
+
execute: function () {
|
251
|
+
var _execute = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(_ref, _ref2) {
|
252
|
+
var param, message, _param, game, i1, inputs, result;
|
253
|
+
|
254
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
255
|
+
while (1) {
|
256
|
+
switch (_context2.prev = _context2.next) {
|
257
|
+
case 0:
|
258
|
+
param = _ref.param;
|
259
|
+
message = _ref2.message;
|
260
|
+
_param = (0, _slicedToArray2["default"])(param, 3), game = _param[1], i1 = _param[2];
|
261
|
+
|
262
|
+
if (!(!game || !i1)) {
|
263
|
+
_context2.next = 5;
|
264
|
+
break;
|
265
|
+
}
|
266
|
+
|
267
|
+
return _context2.abrupt("return", message.reply('Missing arguments. Example: >fgi sf 236P 214K'));
|
268
|
+
|
269
|
+
case 5:
|
270
|
+
if (gameInputs.has(game)) {
|
271
|
+
_context2.next = 7;
|
272
|
+
break;
|
273
|
+
}
|
274
|
+
|
275
|
+
return _context2.abrupt("return", message.reply("\"".concat(game, "\" is not a valid game. Available games: ").concat(Array.from(gameInputs.keys()).join(' '))));
|
276
|
+
|
277
|
+
case 7:
|
278
|
+
inputs = new Map([].concat((0, _toConsumableArray2["default"])(basicInputs), (0, _toConsumableArray2["default"])(gameInputs.get(game))));
|
279
|
+
result = param.slice(2).map(function (i) {
|
280
|
+
return solveInput(inputs, i.toLowerCase());
|
281
|
+
}).flat();
|
282
|
+
sendInput(inputs, result, message);
|
283
|
+
|
284
|
+
case 10:
|
285
|
+
case "end":
|
286
|
+
return _context2.stop();
|
287
|
+
}
|
288
|
+
}
|
289
|
+
}, _callee2);
|
290
|
+
}));
|
291
|
+
|
292
|
+
function execute(_x5, _x6) {
|
293
|
+
return _execute.apply(this, arguments);
|
294
|
+
}
|
295
|
+
|
296
|
+
return execute;
|
297
|
+
}()
|
298
|
+
},
|
299
|
+
fgsave: {
|
300
|
+
usage: 'fgsave [game] [name] [inputs]',
|
301
|
+
desc: 'Saves a list of inputs into a command',
|
302
|
+
example: 'fgi sf testName 236P 214K',
|
303
|
+
execute: function () {
|
304
|
+
var _execute2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(_ref3, _ref4) {
|
305
|
+
var param, sequelize, message, _param2, game, name, i1, inputs, input;
|
306
|
+
|
307
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
308
|
+
while (1) {
|
309
|
+
switch (_context3.prev = _context3.next) {
|
310
|
+
case 0:
|
311
|
+
param = _ref3.param, sequelize = _ref3.sequelize;
|
312
|
+
message = _ref4.message;
|
313
|
+
_param2 = (0, _slicedToArray2["default"])(param, 4), game = _param2[1], name = _param2[2], i1 = _param2[3];
|
314
|
+
|
315
|
+
if (!(!game || !name || !i1)) {
|
316
|
+
_context3.next = 5;
|
317
|
+
break;
|
318
|
+
}
|
319
|
+
|
320
|
+
return _context3.abrupt("return", message.reply('Missing arguments. Example: >fgi sf testName 236P 214K'));
|
321
|
+
|
322
|
+
case 5:
|
323
|
+
if (gameInputs.has(game)) {
|
324
|
+
_context3.next = 7;
|
325
|
+
break;
|
326
|
+
}
|
327
|
+
|
328
|
+
return _context3.abrupt("return", message.reply("\"".concat(game, "\" is not a valid game. Available games: ").concat(Array.from(gameInputs.keys()).join(' '))));
|
329
|
+
|
330
|
+
case 7:
|
331
|
+
inputs = new Map([].concat((0, _toConsumableArray2["default"])(basicInputs), (0, _toConsumableArray2["default"])(gameInputs.get(game))));
|
332
|
+
input = param.slice(3).map(function (i) {
|
333
|
+
return solveInput(inputs, i.toLowerCase());
|
334
|
+
}).flat().join(' ');
|
335
|
+
_context3.next = 11;
|
336
|
+
return sequelize.models.fginput.create({
|
337
|
+
guild: message.guild.id,
|
338
|
+
name: name,
|
339
|
+
createdBy: message.author.id,
|
340
|
+
game: game,
|
341
|
+
input: input
|
342
|
+
});
|
343
|
+
|
344
|
+
case 11:
|
345
|
+
message.channel.send("Saved command \"".concat(input, "\" as \"").concat(name, "\""));
|
346
|
+
|
347
|
+
case 12:
|
348
|
+
case "end":
|
349
|
+
return _context3.stop();
|
350
|
+
}
|
351
|
+
}
|
352
|
+
}, _callee3);
|
353
|
+
}));
|
354
|
+
|
355
|
+
function execute(_x7, _x8) {
|
356
|
+
return _execute2.apply(this, arguments);
|
357
|
+
}
|
358
|
+
|
359
|
+
return execute;
|
360
|
+
}()
|
361
|
+
},
|
362
|
+
fgcaption: {
|
363
|
+
usage: 'fgcaption [name] [caption]',
|
364
|
+
desc: 'Adds a caption to a saved input command',
|
365
|
+
example: 'fgcaption testName This is a caption',
|
366
|
+
execute: function () {
|
367
|
+
var _execute3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(_ref5, _ref6) {
|
368
|
+
var param, sequelize, message, _param3, name, i1, row;
|
369
|
+
|
370
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
371
|
+
while (1) {
|
372
|
+
switch (_context4.prev = _context4.next) {
|
373
|
+
case 0:
|
374
|
+
param = _ref5.param, sequelize = _ref5.sequelize;
|
375
|
+
message = _ref6.message;
|
376
|
+
_param3 = (0, _slicedToArray2["default"])(param, 3), name = _param3[1], i1 = _param3[2];
|
377
|
+
|
378
|
+
if (!(!name || !i1)) {
|
379
|
+
_context4.next = 5;
|
380
|
+
break;
|
381
|
+
}
|
382
|
+
|
383
|
+
return _context4.abrupt("return", message.reply('Missing arguments. Example: >fgi testName This is a caption'));
|
384
|
+
|
385
|
+
case 5:
|
386
|
+
_context4.next = 7;
|
387
|
+
return sequelize.models.fginput.findOne({
|
388
|
+
where: {
|
389
|
+
guild: message.guild.id,
|
390
|
+
name: name
|
391
|
+
}
|
392
|
+
});
|
393
|
+
|
394
|
+
case 7:
|
395
|
+
row = _context4.sent;
|
396
|
+
|
397
|
+
if (row) {
|
398
|
+
_context4.next = 10;
|
399
|
+
break;
|
400
|
+
}
|
401
|
+
|
402
|
+
return _context4.abrupt("return", message.reply("\"".concat(name, "\" is not a saved input list")));
|
403
|
+
|
404
|
+
case 10:
|
405
|
+
row.caption = param.slice(2).join(' ');
|
406
|
+
_context4.next = 13;
|
407
|
+
return row.save();
|
408
|
+
|
409
|
+
case 13:
|
410
|
+
message.channel.send("Saved caption for input list \"".concat(name, "\""));
|
411
|
+
|
412
|
+
case 14:
|
413
|
+
case "end":
|
414
|
+
return _context4.stop();
|
415
|
+
}
|
416
|
+
}
|
417
|
+
}, _callee4);
|
418
|
+
}));
|
419
|
+
|
420
|
+
function execute(_x9, _x10) {
|
421
|
+
return _execute3.apply(this, arguments);
|
422
|
+
}
|
423
|
+
|
424
|
+
return execute;
|
425
|
+
}()
|
426
|
+
},
|
427
|
+
fgglossary: {
|
428
|
+
usage: 'fgglossary [search term]',
|
429
|
+
desc: 'Searches for a term on Infil\'s Glossary',
|
430
|
+
example: 'fgglossary mexican uppercut',
|
431
|
+
execute: function () {
|
432
|
+
var _execute4 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(_ref7, _ref8) {
|
433
|
+
var param, sequelize, message, params, search, result, url;
|
434
|
+
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
435
|
+
while (1) {
|
436
|
+
switch (_context5.prev = _context5.next) {
|
437
|
+
case 0:
|
438
|
+
param = _ref7.param, sequelize = _ref7.sequelize;
|
439
|
+
message = _ref8.message;
|
440
|
+
params = param.slice(1);
|
441
|
+
|
442
|
+
if (!(params.length === 0)) {
|
443
|
+
_context5.next = 5;
|
444
|
+
break;
|
445
|
+
}
|
446
|
+
|
447
|
+
return _context5.abrupt("return", message.reply('Missing search term. Example: >fgglossary mexican uppercut'));
|
448
|
+
|
449
|
+
case 5:
|
450
|
+
search = params.join(' ').toLowerCase();
|
451
|
+
result = terms.filter(function (i) {
|
452
|
+
return i.includes(search);
|
453
|
+
});
|
454
|
+
url = "https://glossary.infil.net/?t=".concat(params.join('%20').toLowerCase());
|
455
|
+
|
456
|
+
if (!(result.length === 0)) {
|
457
|
+
_context5.next = 10;
|
458
|
+
break;
|
459
|
+
}
|
460
|
+
|
461
|
+
return _context5.abrupt("return", message.reply("Term \"".concat(search, "\" not found")));
|
462
|
+
|
463
|
+
case 10:
|
464
|
+
if (!(result.length === 1)) {
|
465
|
+
_context5.next = 12;
|
466
|
+
break;
|
467
|
+
}
|
468
|
+
|
469
|
+
return _context5.abrupt("return", message.reply("```".concat(glossary[result[0]].def, "```Source: <").concat(url, ">")));
|
470
|
+
|
471
|
+
case 12:
|
472
|
+
message.reply("Multiple terms found: ".concat(url));
|
473
|
+
|
474
|
+
case 13:
|
475
|
+
case "end":
|
476
|
+
return _context5.stop();
|
477
|
+
}
|
478
|
+
}
|
479
|
+
}, _callee5);
|
480
|
+
}));
|
481
|
+
|
482
|
+
function execute(_x11, _x12) {
|
483
|
+
return _execute4.apply(this, arguments);
|
484
|
+
}
|
485
|
+
|
486
|
+
return execute;
|
487
|
+
}()
|
488
|
+
}
|
489
|
+
}
|
490
|
+
};
|
487
491
|
exports["default"] = _default;
|
package/package.json
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lotus-tree/fg-notation",
|
3
|
-
"version": "1.1.
|
3
|
+
"version": "1.1.3",
|
4
4
|
"main": "lib/index.js",
|
5
5
|
"module": "src/index.js",
|
6
6
|
"scripts": {
|
7
|
-
"run-babel"
|
8
|
-
"build": "yarn run run-babel --
|
9
|
-
"dev": "yarn run run-babel --
|
7
|
+
"run-babel": "babel --delete-dir-on-start --copy-files src",
|
8
|
+
"build": "yarn run run-babel --out-dir lib",
|
9
|
+
"dev": "yarn run run-babel --watch --out-dir dev",
|
10
|
+
"prepublishOnly": "yarn build"
|
10
11
|
},
|
11
12
|
"dependencies": {
|
13
|
+
"@lotus-tree/command-handler": "^2.0.0",
|
14
|
+
"bent": "^7.3.12",
|
12
15
|
"glob": "^7.2.0",
|
13
|
-
"request-promise": "^4.2.6",
|
14
16
|
"sharp": "^0.29.3"
|
15
17
|
},
|
16
18
|
"devDependencies": {
|
package/src/index.js
CHANGED
@@ -2,8 +2,9 @@ import sharp from 'sharp'
|
|
2
2
|
import path from 'path'
|
3
3
|
import glob from 'glob'
|
4
4
|
import { DataTypes } from 'sequelize'
|
5
|
-
import
|
5
|
+
import bent from 'bent'
|
6
6
|
|
7
|
+
const getJSON = bent('json')
|
7
8
|
const imgPath = path.join(__dirname, 'img')
|
8
9
|
const basicInputs = new Map()
|
9
10
|
const gameInputs = new Map()
|
@@ -15,7 +16,7 @@ getGlossary()
|
|
15
16
|
setInterval(getGlossary, 5 * 60 * 1000)
|
16
17
|
|
17
18
|
async function getGlossary () {
|
18
|
-
const result =
|
19
|
+
const result = await getJSON('https://glossary.infil.net/json/glossary.json')
|
19
20
|
const tempG = {}
|
20
21
|
const tempT = []
|
21
22
|
|
@@ -77,6 +78,10 @@ const builtin = {
|
|
77
78
|
|
78
79
|
export default {
|
79
80
|
name: 'fg-notation',
|
81
|
+
about: {
|
82
|
+
name: 'FG Notation',
|
83
|
+
value: '[Instructions and source code](https://lotus.chitowarlock.com/fgnotation)\n[Infil\'s Fighting Game Glossary](https://glossary.infil.net)\n[MagicianStuff\'s Fighthing Game notations emotes](https://twitter.com/MagicianStuff/status/1477931054484893697)'
|
84
|
+
},
|
80
85
|
intents: ['GUILD_MESSAGES'],
|
81
86
|
partials: ['MESSAGE'],
|
82
87
|
|