@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 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): for the rich and awesome glossary
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 _requestPromise = _interopRequireDefault(require("request-promise"));
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.t0 = JSON;
49
- _context6.next = 3;
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 3:
53
- _context6.t1 = _context6.sent;
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 10:
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 _requestPromise = _interopRequireDefault(require("request-promise"));
27
-
28
- var imgPath = _path["default"].join(__dirname, 'img');
29
-
30
- var basicInputs = new Map();
31
- var gameInputs = new Map();
32
- var glossary = {};
33
- var terms = [];
34
- getGlossary();
35
- setInterval(getGlossary, 5 * 60 * 1000);
36
-
37
- function getGlossary() {
38
- return _getGlossary.apply(this, arguments);
39
- }
40
-
41
- function _getGlossary() {
42
- _getGlossary = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
43
- var result, tempG, tempT;
44
- return _regenerator["default"].wrap(function _callee6$(_context6) {
45
- while (1) {
46
- switch (_context6.prev = _context6.next) {
47
- case 0:
48
- _context6.t0 = JSON;
49
- _context6.next = 3;
50
- return (0, _requestPromise["default"])('https://glossary.infil.net/json/glossary.json');
51
-
52
- case 3:
53
- _context6.t1 = _context6.sent;
54
- result = _context6.t0.parse.call(_context6.t0, _context6.t1);
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 10:
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
- intents: ['GUILD_MESSAGES'],
162
- partials: ['MESSAGE'],
163
- preload: function preload(sequelize) {
164
- sequelize.define('fginput', {
165
- guild: {
166
- type: _sequelize.DataTypes.STRING,
167
- primaryKey: true
168
- },
169
- name: {
170
- type: _sequelize.DataTypes.STRING,
171
- primaryKey: true
172
- },
173
- createdBy: _sequelize.DataTypes.STRING,
174
- game: _sequelize.DataTypes.STRING,
175
- caption: _sequelize.DataTypes.STRING,
176
- input: _sequelize.DataTypes.STRING
177
- });
178
- },
179
- events: {
180
- messageCreate: function messageCreate(global, message) {
181
- return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
182
- var client, config, sequelize, guildId, prefix, name, row, inputs;
183
- return _regenerator["default"].wrap(function _callee$(_context) {
184
- while (1) {
185
- switch (_context.prev = _context.next) {
186
- case 0:
187
- client = global.client, config = global.config, sequelize = global.sequelize;
188
-
189
- if (!(message.author.id === client.user.id || !message.member)) {
190
- _context.next = 3;
191
- break;
192
- }
193
-
194
- return _context.abrupt("return");
195
-
196
- case 3:
197
- guildId = message.guildId;
198
- prefix = config[guildId].prefix;
199
-
200
- if (!message.content.startsWith(prefix)) {
201
- _context.next = 14;
202
- break;
203
- }
204
-
205
- name = message.content.split(' ').pop().replace(prefix, '');
206
- _context.t0 = builtin[name];
207
-
208
- if (_context.t0) {
209
- _context.next = 12;
210
- break;
211
- }
212
-
213
- _context.next = 11;
214
- return sequelize.models.fginput.findOne({
215
- where: {
216
- guild: message.guild.id,
217
- name: name
218
- }
219
- });
220
-
221
- case 11:
222
- _context.t0 = _context.sent;
223
-
224
- case 12:
225
- row = _context.t0;
226
-
227
- if (row) {
228
- inputs = new Map([].concat((0, _toConsumableArray2["default"])(basicInputs), (0, _toConsumableArray2["default"])(gameInputs.get(row.game))));
229
- sendInput(inputs, row.input.split(' '), message, row.caption);
230
- }
231
-
232
- case 14:
233
- case "end":
234
- return _context.stop();
235
- }
236
- }
237
- }, _callee);
238
- }))();
239
- }
240
- },
241
- commands: {
242
- fgi: {
243
- usage: 'fgi [game] [inputs]',
244
- desc: 'Converts a list of inputs into an image',
245
- example: 'fgi sf 236P 214K',
246
- execute: function () {
247
- var _execute = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(_ref, _ref2) {
248
- var param, message, _param, game, i1, inputs, result;
249
-
250
- return _regenerator["default"].wrap(function _callee2$(_context2) {
251
- while (1) {
252
- switch (_context2.prev = _context2.next) {
253
- case 0:
254
- param = _ref.param;
255
- message = _ref2.message;
256
- _param = (0, _slicedToArray2["default"])(param, 3), game = _param[1], i1 = _param[2];
257
-
258
- if (!(!game || !i1)) {
259
- _context2.next = 5;
260
- break;
261
- }
262
-
263
- return _context2.abrupt("return", message.reply('Missing arguments. Example: >fgi sf 236P 214K'));
264
-
265
- case 5:
266
- if (gameInputs.has(game)) {
267
- _context2.next = 7;
268
- break;
269
- }
270
-
271
- return _context2.abrupt("return", message.reply("\"".concat(game, "\" is not a valid game. Available games: ").concat(Array.from(gameInputs.keys()).join(' '))));
272
-
273
- case 7:
274
- inputs = new Map([].concat((0, _toConsumableArray2["default"])(basicInputs), (0, _toConsumableArray2["default"])(gameInputs.get(game))));
275
- result = param.slice(2).map(function (i) {
276
- return solveInput(inputs, i.toLowerCase());
277
- }).flat();
278
- sendInput(inputs, result, message);
279
-
280
- case 10:
281
- case "end":
282
- return _context2.stop();
283
- }
284
- }
285
- }, _callee2);
286
- }));
287
-
288
- function execute(_x5, _x6) {
289
- return _execute.apply(this, arguments);
290
- }
291
-
292
- return execute;
293
- }()
294
- },
295
- fgsave: {
296
- usage: 'fgsave [game] [name] [inputs]',
297
- desc: 'Saves a list of inputs into a command',
298
- example: 'fgi sf testName 236P 214K',
299
- execute: function () {
300
- var _execute2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(_ref3, _ref4) {
301
- var param, sequelize, message, _param2, game, name, i1, inputs, input;
302
-
303
- return _regenerator["default"].wrap(function _callee3$(_context3) {
304
- while (1) {
305
- switch (_context3.prev = _context3.next) {
306
- case 0:
307
- param = _ref3.param, sequelize = _ref3.sequelize;
308
- message = _ref4.message;
309
- _param2 = (0, _slicedToArray2["default"])(param, 4), game = _param2[1], name = _param2[2], i1 = _param2[3];
310
-
311
- if (!(!game || !name || !i1)) {
312
- _context3.next = 5;
313
- break;
314
- }
315
-
316
- return _context3.abrupt("return", message.reply('Missing arguments. Example: >fgi sf testName 236P 214K'));
317
-
318
- case 5:
319
- if (gameInputs.has(game)) {
320
- _context3.next = 7;
321
- break;
322
- }
323
-
324
- return _context3.abrupt("return", message.reply("\"".concat(game, "\" is not a valid game. Available games: ").concat(Array.from(gameInputs.keys()).join(' '))));
325
-
326
- case 7:
327
- inputs = new Map([].concat((0, _toConsumableArray2["default"])(basicInputs), (0, _toConsumableArray2["default"])(gameInputs.get(game))));
328
- input = param.slice(3).map(function (i) {
329
- return solveInput(inputs, i.toLowerCase());
330
- }).flat().join(' ');
331
- _context3.next = 11;
332
- return sequelize.models.fginput.create({
333
- guild: message.guild.id,
334
- name: name,
335
- createdBy: message.author.id,
336
- game: game,
337
- input: input
338
- });
339
-
340
- case 11:
341
- message.channel.send("Saved command \"".concat(input, "\" as \"").concat(name, "\""));
342
-
343
- case 12:
344
- case "end":
345
- return _context3.stop();
346
- }
347
- }
348
- }, _callee3);
349
- }));
350
-
351
- function execute(_x7, _x8) {
352
- return _execute2.apply(this, arguments);
353
- }
354
-
355
- return execute;
356
- }()
357
- },
358
- fgcaption: {
359
- usage: 'fgcaption [name] [caption]',
360
- desc: 'Adds a caption to a saved input command',
361
- example: 'fgcaption testName This is a caption',
362
- execute: function () {
363
- var _execute3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(_ref5, _ref6) {
364
- var param, sequelize, message, _param3, name, i1, row;
365
-
366
- return _regenerator["default"].wrap(function _callee4$(_context4) {
367
- while (1) {
368
- switch (_context4.prev = _context4.next) {
369
- case 0:
370
- param = _ref5.param, sequelize = _ref5.sequelize;
371
- message = _ref6.message;
372
- _param3 = (0, _slicedToArray2["default"])(param, 3), name = _param3[1], i1 = _param3[2];
373
-
374
- if (!(!name || !i1)) {
375
- _context4.next = 5;
376
- break;
377
- }
378
-
379
- return _context4.abrupt("return", message.reply('Missing arguments. Example: >fgi testName This is a caption'));
380
-
381
- case 5:
382
- _context4.next = 7;
383
- return sequelize.models.fginput.findOne({
384
- where: {
385
- guild: message.guild.id,
386
- name: name
387
- }
388
- });
389
-
390
- case 7:
391
- row = _context4.sent;
392
-
393
- if (row) {
394
- _context4.next = 10;
395
- break;
396
- }
397
-
398
- return _context4.abrupt("return", message.reply("\"".concat(name, "\" is not a saved input list")));
399
-
400
- case 10:
401
- row.caption = param.slice(2).join(' ');
402
- _context4.next = 13;
403
- return row.save();
404
-
405
- case 13:
406
- message.channel.send("Saved caption for input list \"".concat(name, "\""));
407
-
408
- case 14:
409
- case "end":
410
- return _context4.stop();
411
- }
412
- }
413
- }, _callee4);
414
- }));
415
-
416
- function execute(_x9, _x10) {
417
- return _execute3.apply(this, arguments);
418
- }
419
-
420
- return execute;
421
- }()
422
- },
423
- fgglossary: {
424
- usage: 'fgglossary [search term]',
425
- desc: 'Searches for a term on Infil\'s Glossary',
426
- example: 'fgglossary mexican uppercut',
427
- execute: function () {
428
- var _execute4 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(_ref7, _ref8) {
429
- var param, sequelize, message, params, search, result, url;
430
- return _regenerator["default"].wrap(function _callee5$(_context5) {
431
- while (1) {
432
- switch (_context5.prev = _context5.next) {
433
- case 0:
434
- param = _ref7.param, sequelize = _ref7.sequelize;
435
- message = _ref8.message;
436
- params = param.slice(1);
437
-
438
- if (!(params.length === 0)) {
439
- _context5.next = 5;
440
- break;
441
- }
442
-
443
- return _context5.abrupt("return", message.reply('Missing search term. Example: >fgglossary mexican uppercut'));
444
-
445
- case 5:
446
- search = params.join(' ').toLowerCase();
447
- result = terms.filter(function (i) {
448
- return i.includes(search);
449
- });
450
- url = "https://glossary.infil.net/?t=".concat(params.join('%20').toLowerCase());
451
-
452
- if (!(result.length === 0)) {
453
- _context5.next = 10;
454
- break;
455
- }
456
-
457
- return _context5.abrupt("return", message.reply("Term \"".concat(search, "\" not found")));
458
-
459
- case 10:
460
- if (!(result.length === 1)) {
461
- _context5.next = 12;
462
- break;
463
- }
464
-
465
- return _context5.abrupt("return", message.reply("```".concat(glossary[result[0]].def, "```Source: <").concat(url, ">")));
466
-
467
- case 12:
468
- message.reply("Multiple terms found: ".concat(url));
469
-
470
- case 13:
471
- case "end":
472
- return _context5.stop();
473
- }
474
- }
475
- }, _callee5);
476
- }));
477
-
478
- function execute(_x11, _x12) {
479
- return _execute4.apply(this, arguments);
480
- }
481
-
482
- return execute;
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.2",
3
+ "version": "1.1.3",
4
4
  "main": "lib/index.js",
5
5
  "module": "src/index.js",
6
6
  "scripts": {
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"
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 rp from 'request-promise'
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 = JSON.parse(await rp('https://glossary.infil.net/json/glossary.json'))
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