mehdown 2.59.0 → 2.60.0
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/.claude/settings.local.json +11 -0
- package/README.md +1 -2
- package/eslint.config.js +49 -0
- package/lib/index.js +3 -70
- package/package.json +8 -9
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# mehdown
|
|
2
2
|
|
|
3
|
-
[](https://github.com/stores-com/mehdown/actions?query=workflow%3Abuild+branch%3Amain)
|
|
4
4
|
[](https://coveralls.io/github/mediocre/mehdown?branch=main)
|
|
5
5
|
|
|
6
6
|
The Markdown parser used on the forums at meh.com.
|
|
@@ -45,7 +45,6 @@ The Markdown parser used on the forums at meh.com.
|
|
|
45
45
|
- `/8ball question` - Ask the Magic 8-Ball a question
|
|
46
46
|
- `/coinflip heads or tails` - Flip a coin
|
|
47
47
|
- `/concerned` - ಠ_ಠ
|
|
48
|
-
- `/cowsay text or --help` - [ASCII cow with a message](https://en.wikipedia.org/wiki/Cowsay)
|
|
49
48
|
- `/eightball question` - Ask the Magic 8-Ball a question
|
|
50
49
|
- `/emojify text` - Swap out words with emoji
|
|
51
50
|
- `/flip text` - uʍop ǝpısdn ʇxǝʇ dıʃℲ
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const globals = require('globals');
|
|
2
|
+
const js = require('@eslint/js');
|
|
3
|
+
|
|
4
|
+
module.exports = [
|
|
5
|
+
{
|
|
6
|
+
ignores: [
|
|
7
|
+
'node_modules/*',
|
|
8
|
+
'lib/index-1.0.js'
|
|
9
|
+
]
|
|
10
|
+
},
|
|
11
|
+
js.configs.recommended,
|
|
12
|
+
{
|
|
13
|
+
languageOptions: {
|
|
14
|
+
ecmaVersion: 2020,
|
|
15
|
+
sourceType: 'module',
|
|
16
|
+
parserOptions: {
|
|
17
|
+
ecmaFeatures: {
|
|
18
|
+
jsx: true
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
globals: {
|
|
22
|
+
...globals.es2020,
|
|
23
|
+
...globals.mocha,
|
|
24
|
+
...globals.node,
|
|
25
|
+
//added for 'fetch()' access
|
|
26
|
+
...globals.serviceworker
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
rules: {
|
|
30
|
+
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
|
|
31
|
+
'comma-dangle': ['error', 'never'],
|
|
32
|
+
'dot-notation': 'error',
|
|
33
|
+
'no-array-constructor': 'error',
|
|
34
|
+
'no-console': 'error',
|
|
35
|
+
'no-fallthrough': 'off',
|
|
36
|
+
'no-inline-comments': 'warn',
|
|
37
|
+
'no-trailing-spaces': 'error',
|
|
38
|
+
'no-unused-vars': ['error', { caughtErrors: 'none' }],
|
|
39
|
+
'object-curly-spacing': ['error', 'always'],
|
|
40
|
+
quotes: ['error', 'single'],
|
|
41
|
+
semi: ['error', 'always'],
|
|
42
|
+
'space-before-function-paren': ['error', {
|
|
43
|
+
anonymous: 'never',
|
|
44
|
+
named: 'never',
|
|
45
|
+
asyncArrow: 'always'
|
|
46
|
+
}]
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
];
|
package/lib/index.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
const url = require('url');
|
|
2
2
|
|
|
3
3
|
const async = require('async');
|
|
4
|
-
const cowsay = require('mehdown-cowsay');
|
|
5
4
|
const flip = require('flip');
|
|
6
5
|
const probeImageSize = require('probe-image-size');
|
|
7
6
|
const lolspeak = require('lolspeak');
|
|
8
7
|
const MarkdownIt = require('markdown-it');
|
|
9
8
|
const natural = require('natural');
|
|
10
|
-
const parseArgs = require('minimist');
|
|
11
9
|
const relToAbs = require('rel-to-abs');
|
|
12
10
|
const request = require('request');
|
|
13
11
|
const roll = require('roll');
|
|
14
|
-
const shellQuote = require('shell-quote');
|
|
15
12
|
const textify = require('textify');
|
|
16
13
|
const youtubeSearch = require('youtube-search');
|
|
17
14
|
|
|
@@ -26,67 +23,6 @@ for (var key in emoji) {
|
|
|
26
23
|
_emoji.stemmedKeywords = _emoji.keywords.map(k => natural.PorterStemmer.stem(k.toLowerCase()));
|
|
27
24
|
}
|
|
28
25
|
|
|
29
|
-
function _cowsay(command, args, callback) {
|
|
30
|
-
// This command requires arguments.
|
|
31
|
-
if (!args) {
|
|
32
|
-
return callback();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
var argv = parseArgs(shellQuote.parse(args), {
|
|
36
|
-
alias: { h: 'help' },
|
|
37
|
-
boolean: ['b', 'd', 'g', 'p', 's', 't', 'w', 'y', 'h', 'l']
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
argv._ = argv._.filter(a => typeof a === 'string');
|
|
41
|
-
|
|
42
|
-
if (argv.h) {
|
|
43
|
-
var help = `Usage: /${command} [-e eye_string] [-f cowfile] [-h] [-l] [-T tongue_string] [-bdgpstwy] "text"\n\n`;
|
|
44
|
-
help += 'If any arguments are left over after all switches have been processed, they become the cow′s message.\n\n';
|
|
45
|
-
help += 'If the command is invoked as /cowthink then the cow will think its message instead of saying it.\n\n';
|
|
46
|
-
help += 'Options:\n';
|
|
47
|
-
help += ' -b "Borg", uses == for the cow′s eyes.\n';
|
|
48
|
-
help += ' -d "Dead", uses XX, plus a descending U to represent an extruded tongue.\n';
|
|
49
|
-
help += ' -g "Greedy", uses $$ for the cow′s eyes.\n';
|
|
50
|
-
help += ' -p "Paranoid", uses @@ for the cow′s eyes.\n';
|
|
51
|
-
help += ' -s "Stoned", uses ** to represent bloodshot eyes, plus a descending U to represent an extruded tongue.\n';
|
|
52
|
-
help += ' -t "Tired", uses -- for the cow′s eyes.\n';
|
|
53
|
-
help += ' -w "Wired", uses OO for the cow′s eyes.\n';
|
|
54
|
-
help += ' -y "Youthful", uses .. to represent smaller eyes.\n';
|
|
55
|
-
help += ' -e Manually specifies the cow′s eye-type. [default: "oo"]\n';
|
|
56
|
-
help += ' -T Manually specifies the cow′s tongue shape. [default: " "]\n';
|
|
57
|
-
help += ' -h Display this help message.\n';
|
|
58
|
-
help += ' -f Specifies a cow picture file ("cowfile") to use. [default: "default"]\n';
|
|
59
|
-
help += ' -l List all cowfiles available.\n';
|
|
60
|
-
|
|
61
|
-
return callback(null, `/${command} ${args}\n~~~\n${help}\n~~~`);
|
|
62
|
-
} else if (argv.l) {
|
|
63
|
-
return cowsay.list(function(err, cows) {
|
|
64
|
-
if (err) {
|
|
65
|
-
return callback();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
callback(null, `/${command} ${args}\n~~~\n${cows.join(' ')}\n~~~`);
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Don't allow disabling word-wrapping
|
|
73
|
-
delete argv.n;
|
|
74
|
-
|
|
75
|
-
// A reply on mobile can only fit 32 characters
|
|
76
|
-
argv.W = 32;
|
|
77
|
-
|
|
78
|
-
var result;
|
|
79
|
-
|
|
80
|
-
try {
|
|
81
|
-
result = command === 'cowthink' ? cowsay.think(argv) : cowsay.say(argv);
|
|
82
|
-
result = `~~~\n${result}\n~~~`;
|
|
83
|
-
} catch(e) {
|
|
84
|
-
// eslint-disable-line
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
callback(null, result);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
26
|
function _eightball(command, args, callback) {
|
|
91
27
|
const responses = [
|
|
92
28
|
'It is certain',
|
|
@@ -169,12 +105,6 @@ const commands = {
|
|
|
169
105
|
concerned: function(args, callback) {
|
|
170
106
|
callback(null, 'ಠ_ಠ');
|
|
171
107
|
},
|
|
172
|
-
cowsay: function(args, callback) {
|
|
173
|
-
_cowsay('cowsay', args, callback);
|
|
174
|
-
},
|
|
175
|
-
cowthink: function(args, callback) {
|
|
176
|
-
_cowsay('cowthink', args, callback);
|
|
177
|
-
},
|
|
178
108
|
eightball: function(args, callback) {
|
|
179
109
|
_eightball('eightball', args, callback);
|
|
180
110
|
},
|
|
@@ -260,6 +190,7 @@ const commands = {
|
|
|
260
190
|
}
|
|
261
191
|
|
|
262
192
|
if (!process.env.GIPHY_API_KEY) {
|
|
193
|
+
//eslint-disable-next-line no-console
|
|
263
194
|
console.warn('GIPHY_API_KEY environment variable is not set');
|
|
264
195
|
return callback();
|
|
265
196
|
}
|
|
@@ -286,6 +217,7 @@ const commands = {
|
|
|
286
217
|
}
|
|
287
218
|
|
|
288
219
|
if (!process.env.GOOGLE_API_KEY) {
|
|
220
|
+
//eslint-disable-next-line no-console
|
|
289
221
|
console.warn('GOOGLE_API_KEY environment variable is not set');
|
|
290
222
|
return callback();
|
|
291
223
|
}
|
|
@@ -443,6 +375,7 @@ const commands = {
|
|
|
443
375
|
}
|
|
444
376
|
|
|
445
377
|
if (!process.env.GOOGLE_API_KEY) {
|
|
378
|
+
//eslint-disable-next-line no-console
|
|
446
379
|
console.warn('GOOGLE_API_KEY environment variable is not set');
|
|
447
380
|
return callback();
|
|
448
381
|
}
|
package/package.json
CHANGED
|
@@ -6,33 +6,32 @@
|
|
|
6
6
|
"lolspeak": "~1.4.0",
|
|
7
7
|
"markdown-it": "~14.1.0",
|
|
8
8
|
"markdown-it-collapsible": "~2.0.2",
|
|
9
|
-
"mehdown-cowsay": "~1.1.6",
|
|
10
|
-
"minimist": "~1.2.5",
|
|
11
9
|
"natural": "~5.2.4",
|
|
12
10
|
"probe-image-size": "~7.2.0",
|
|
13
11
|
"rel-to-abs": "~0.1.0",
|
|
14
12
|
"request": "~2.88.2",
|
|
15
13
|
"roll": "~1.3.1",
|
|
16
|
-
"shell-quote": "~1.8.0",
|
|
17
14
|
"slug": "~9.1.0",
|
|
18
15
|
"textify": "~0.0.12",
|
|
19
16
|
"youtube-search": "~1.1.4"
|
|
20
17
|
},
|
|
21
18
|
"description": "The Markdown parser used on the forums at meh.com.",
|
|
22
19
|
"devDependencies": {
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"nyc": "*"
|
|
20
|
+
"@eslint/js": "*",
|
|
21
|
+
"globals": "*"
|
|
26
22
|
},
|
|
27
23
|
"keywords": [
|
|
28
24
|
"markdown"
|
|
29
25
|
],
|
|
30
26
|
"main": "./lib",
|
|
31
27
|
"name": "mehdown",
|
|
32
|
-
"repository":
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/stores-com/mehdown.git"
|
|
31
|
+
},
|
|
33
32
|
"scripts": {
|
|
34
33
|
"coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls",
|
|
35
|
-
"test": "
|
|
34
|
+
"test": "node --test --test-concurrency=true --test-force-exit --test-reporter=spec"
|
|
36
35
|
},
|
|
37
|
-
"version": "2.
|
|
36
|
+
"version": "2.60.0"
|
|
38
37
|
}
|