@mkody/twitch-emoticons 2.7.0 → 2.7.1

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.
Files changed (43) hide show
  1. package/.eslintrc.json +143 -143
  2. package/.github/codeql/codeql-config.yml +4 -4
  3. package/.github/workflows/codeql.yml +50 -50
  4. package/.github/workflows/eslint.yml +50 -50
  5. package/.github/workflows/release.yml +22 -0
  6. package/.github/workflows/yarn-test.yml +17 -17
  7. package/.jsdoc.json +39 -39
  8. package/.nvmrc +1 -0
  9. package/LICENSE +22 -22
  10. package/docs/BTTVEmote.html +1319 -1319
  11. package/docs/Channel.html +823 -823
  12. package/docs/Collection.html +797 -797
  13. package/docs/Emote.html +801 -801
  14. package/docs/EmoteFetcher.html +2946 -2946
  15. package/docs/EmoteParser.html +811 -811
  16. package/docs/FFZEmote.html +1473 -1473
  17. package/docs/SevenTV.html +1190 -1190
  18. package/docs/SevenTVEmote.html +1395 -1395
  19. package/docs/TwitchEmote.html +1315 -1315
  20. package/docs/index.html +206 -206
  21. package/docs/struct_BTTVEmote.js.html +132 -132
  22. package/docs/struct_Channel.js.html +127 -127
  23. package/docs/struct_Emote.js.html +138 -138
  24. package/docs/struct_EmoteFetcher.js.html +395 -399
  25. package/docs/struct_EmoteParser.js.html +153 -153
  26. package/docs/struct_FFZEmote.js.html +146 -146
  27. package/docs/struct_SevenTVEmote.js.html +141 -141
  28. package/docs/struct_TwitchEmote.js.html +130 -130
  29. package/docs/util_Collection.js.html +150 -150
  30. package/package.json +57 -57
  31. package/src/index.js +12 -12
  32. package/src/struct/BTTVEmote.js +60 -60
  33. package/src/struct/Channel.js +55 -55
  34. package/src/struct/Emote.js +66 -66
  35. package/src/struct/EmoteFetcher.js +323 -327
  36. package/src/struct/EmoteParser.js +81 -81
  37. package/src/struct/FFZEmote.js +74 -74
  38. package/src/struct/SevenTVEmote.js +69 -69
  39. package/src/struct/TwitchEmote.js +58 -58
  40. package/src/util/Collection.js +78 -78
  41. package/src/util/Constants.js +31 -31
  42. package/test/index.js +174 -174
  43. package/typings/index.d.ts +98 -98
@@ -1,78 +1,78 @@
1
- /**
2
- * An extended Map with utility methods.
3
- * @class Collection
4
- */
5
- class Collection extends Map {
6
- /**
7
- * Finds first matching value by property or function.
8
- * Same as `Array#find`.
9
- * @param {string|Function} propOrFunc - Property or function to test.
10
- * @param {any} [value] - Value to find.
11
- * @returns {any}
12
- */
13
- find(propOrFunc, value) {
14
- if (typeof propOrFunc === 'string') {
15
- if (typeof value === 'undefined') return null;
16
- for (const item of this.values()) {
17
- if (item[propOrFunc] === value) return item;
18
- }
19
-
20
- return null;
21
- }
22
-
23
- if (typeof propOrFunc === 'function') {
24
- let i = 0;
25
- for (const item of this.values()) {
26
- if (propOrFunc(item, i, this)) return item;
27
- i++;
28
- }
29
-
30
- return null;
31
- }
32
-
33
- return null;
34
- }
35
-
36
- /**
37
- * Filters cache by function.
38
- * Same as `Array#filter`.
39
- * @param {Function} func - Function to test.
40
- * @param {any} [thisArg] - The context for the function.
41
- * @returns {Collection}
42
- */
43
- filter(func, thisArg) {
44
- if (thisArg) func = func.bind(thisArg);
45
-
46
- const results = new this.constructor();
47
-
48
- let i = 0;
49
- for (const [key, item] of this) {
50
- if (func(item, i, this)) results.set(key, item);
51
- i++;
52
- }
53
-
54
- return results;
55
- }
56
-
57
- /**
58
- * Maps cache by function.
59
- * Same as `Array#map`.
60
- * @param {Function} func - Function to use.
61
- * @param {any} [thisArg] - The context for the function.
62
- * @returns {any[]}
63
- */
64
- map(func, thisArg) {
65
- if (thisArg) func = func.bind(thisArg);
66
-
67
- const array = new Array(this.size);
68
- let i = 0;
69
- for (const item of this.values()) {
70
- array[i] = func(item, i, this);
71
- i++;
72
- }
73
-
74
- return array;
75
- }
76
- }
77
-
78
- module.exports = Collection;
1
+ /**
2
+ * An extended Map with utility methods.
3
+ * @class Collection
4
+ */
5
+ class Collection extends Map {
6
+ /**
7
+ * Finds first matching value by property or function.
8
+ * Same as `Array#find`.
9
+ * @param {string|Function} propOrFunc - Property or function to test.
10
+ * @param {any} [value] - Value to find.
11
+ * @returns {any}
12
+ */
13
+ find(propOrFunc, value) {
14
+ if (typeof propOrFunc === 'string') {
15
+ if (typeof value === 'undefined') return null;
16
+ for (const item of this.values()) {
17
+ if (item[propOrFunc] === value) return item;
18
+ }
19
+
20
+ return null;
21
+ }
22
+
23
+ if (typeof propOrFunc === 'function') {
24
+ let i = 0;
25
+ for (const item of this.values()) {
26
+ if (propOrFunc(item, i, this)) return item;
27
+ i++;
28
+ }
29
+
30
+ return null;
31
+ }
32
+
33
+ return null;
34
+ }
35
+
36
+ /**
37
+ * Filters cache by function.
38
+ * Same as `Array#filter`.
39
+ * @param {Function} func - Function to test.
40
+ * @param {any} [thisArg] - The context for the function.
41
+ * @returns {Collection}
42
+ */
43
+ filter(func, thisArg) {
44
+ if (thisArg) func = func.bind(thisArg);
45
+
46
+ const results = new this.constructor();
47
+
48
+ let i = 0;
49
+ for (const [key, item] of this) {
50
+ if (func(item, i, this)) results.set(key, item);
51
+ i++;
52
+ }
53
+
54
+ return results;
55
+ }
56
+
57
+ /**
58
+ * Maps cache by function.
59
+ * Same as `Array#map`.
60
+ * @param {Function} func - Function to use.
61
+ * @param {any} [thisArg] - The context for the function.
62
+ * @returns {any[]}
63
+ */
64
+ map(func, thisArg) {
65
+ if (thisArg) func = func.bind(thisArg);
66
+
67
+ const array = new Array(this.size);
68
+ let i = 0;
69
+ for (const item of this.values()) {
70
+ array[i] = func(item, i, this);
71
+ i++;
72
+ }
73
+
74
+ return array;
75
+ }
76
+ }
77
+
78
+ module.exports = Collection;
@@ -1,31 +1,31 @@
1
- module.exports = {
2
- Twitch: {
3
- CDN: (id, size) => `https://static-cdn.jtvnw.net/emoticons/v2/${id}/default/dark/${size + 1}.0`
4
- },
5
- BTTV: {
6
- Global: 'https://api.betterttv.net/3/cached/emotes/global',
7
- Channel: id => `https://api.betterttv.net/3/cached/users/twitch/${id}`,
8
- CDN: (id, size) => `https://cdn.betterttv.net/emote/${id}/${size + 1}x.webp`
9
- },
10
- SevenTV: {
11
- Global: 'https://7tv.io/v3/emote-sets/global',
12
- Channel: id => `https://7tv.io/v3/users/twitch/${id}`,
13
- CDN: (id, size) => `https://cdn.7tv.app/emote/${id}/${size}`
14
- },
15
- FFZ: {
16
- sets: {
17
- Global: 3,
18
- Modifiers: 1532818
19
- },
20
- Set: id => `https://api.frankerfacez.com/v1/set/${id}`,
21
- Channel: id => `https://api.frankerfacez.com/v1/room/id/${id}`,
22
- CDN: (id, size) => `https://cdn.frankerfacez.com/emote/${id}/${size}`,
23
- CDNAnimated: (id, size) => `https://cdn.frankerfacez.com/emote/${id}/animated/${size}.webp`
24
- },
25
- Templates: {
26
- html: '<img alt="{name}" title="{name}" class="twitch-emote twitch-emote-{size}" src="{link}">',
27
- markdown: '![{name}]({link} "{name}")',
28
- bbcode: '[img]{link}[/img]',
29
- plain: '{link}'
30
- }
31
- };
1
+ module.exports = {
2
+ Twitch: {
3
+ CDN: (id, size) => `https://static-cdn.jtvnw.net/emoticons/v2/${id}/default/dark/${size + 1}.0`
4
+ },
5
+ BTTV: {
6
+ Global: 'https://api.betterttv.net/3/cached/emotes/global',
7
+ Channel: id => `https://api.betterttv.net/3/cached/users/twitch/${id}`,
8
+ CDN: (id, size) => `https://cdn.betterttv.net/emote/${id}/${size + 1}x.webp`
9
+ },
10
+ SevenTV: {
11
+ Global: 'https://7tv.io/v3/emote-sets/global',
12
+ Channel: id => `https://7tv.io/v3/users/twitch/${id}`,
13
+ CDN: (id, size) => `https://cdn.7tv.app/emote/${id}/${size}`
14
+ },
15
+ FFZ: {
16
+ sets: {
17
+ Global: 3,
18
+ Modifiers: 1532818
19
+ },
20
+ Set: id => `https://api.frankerfacez.com/v1/set/${id}`,
21
+ Channel: id => `https://api.frankerfacez.com/v1/room/id/${id}`,
22
+ CDN: (id, size) => `https://cdn.frankerfacez.com/emote/${id}/${size}`,
23
+ CDNAnimated: (id, size) => `https://cdn.frankerfacez.com/emote/${id}/animated/${size}.webp`
24
+ },
25
+ Templates: {
26
+ html: '<img alt="{name}" title="{name}" class="twitch-emote twitch-emote-{size}" src="{link}">',
27
+ markdown: '![{name}]({link} "{name}")',
28
+ bbcode: '[img]{link}[/img]',
29
+ plain: '{link}'
30
+ }
31
+ };
package/test/index.js CHANGED
@@ -1,174 +1,174 @@
1
- /* eslint-disable no-console */
2
-
3
- const assert = require('assert');
4
- const { env } = require('process');
5
- const { EmoteFetcher, EmoteParser } = require('../src/index.js');
6
-
7
- /**
8
- * If environement variables are set, test Twitch fetching and parsing.
9
- *
10
- * Tests:
11
- * - Fetch emotes
12
- * - Twitch Global
13
- * - Twitch Channel (twitchplayspokemon)
14
- * - Link to Kappa
15
- * - Parse to Markdown
16
- * - Twitch Global emote (CoolCat)
17
- * - Twitch Channel emote (tppD)
18
- */
19
- if (env.TWITCH_ID !== undefined && env.TWITCH_SECRET !== undefined) {
20
- const twitchFetcher = new EmoteFetcher(env.TWITCH_ID, env.TWITCH_SECRET);
21
- const twitchParser = new EmoteParser(twitchFetcher, {
22
- type: 'markdown',
23
- match: /:(.+?):/g
24
- });
25
-
26
- Promise.all([
27
- twitchFetcher.fetchTwitchEmotes(),
28
- twitchFetcher.fetchTwitchEmotes(56648155)
29
- ]).then(() => {
30
- const kappa = twitchFetcher.emotes.get('Kappa');
31
- assert.strictEqual(kappa.toLink(2), 'https://static-cdn.jtvnw.net/emoticons/v2/25/default/dark/3.0');
32
-
33
- const text = twitchParser.parse(':CoolCat:\n:tppD:');
34
- assert.strictEqual(text, [
35
- '![CoolCat](https://static-cdn.jtvnw.net/emoticons/v2/58127/default/dark/1.0 "CoolCat")',
36
- '![tppD](https://static-cdn.jtvnw.net/emoticons/v2/307609315/default/dark/1.0 "tppD")'
37
- ].join('\n'));
38
- }).then(() => {
39
- console.log('Twitch emotes test was successful.');
40
- }).catch(err => {
41
- console.error('Twitch emotes test failed!');
42
- console.error(err);
43
- });
44
- } else {
45
- console.log('Notice: Twitch client id/secret missing.');
46
- }
47
-
48
- /*
49
- * Code should throw if we try to fetch Twitch emotes without a Client ID and Secret
50
- */
51
- const twitchFaultyFetcher = new EmoteFetcher();
52
-
53
- try {
54
- assert.throws(() => {
55
- twitchFaultyFetcher.fetchTwitchEmotes();
56
- }, new Error('Client id or client secret not provided.'));
57
- console.log('Twitch emotes test (without API keys) was successful.');
58
- } catch (err) {
59
- console.error('Twitch emotes test (without API keys) failed!');
60
- console.error(err);
61
- }
62
-
63
- /**
64
- * Test BetterTTV fetching and parsing.
65
- *
66
- * Tests:
67
- * - Fetch emotes
68
- * - BTTV Global
69
- * - BTTV Channel (twitchplayspokemon)
70
- * - Parse to Markdown
71
- * - BTTV Global emote (SourPls)
72
- * - BTTV Channel emote (tppUrn)
73
- * - BTTV Shared emote (MODS)
74
- */
75
- const bttvFetcher = new EmoteFetcher();
76
- const bttvParser = new EmoteParser(bttvFetcher, {
77
- type: 'markdown',
78
- match: /:(.+?):/g
79
- });
80
-
81
- Promise.all([
82
- bttvFetcher.fetchBTTVEmotes(),
83
- bttvFetcher.fetchBTTVEmotes(56648155)
84
- ]).then(() => {
85
- const text = bttvParser.parse(':SourPls:\n:tppUrn:\n:MODS:');
86
- assert.strictEqual(text, [
87
- '![SourPls](https://cdn.betterttv.net/emote/566ca38765dbbdab32ec0560/1x.webp "SourPls")',
88
- '![tppUrn](https://cdn.betterttv.net/emote/5f5f7d5f68d9d86c020e8672/1x.webp "tppUrn")',
89
- '![MODS](https://cdn.betterttv.net/emote/5f2c4f9e65fe924464ef6d61/1x.webp "MODS")'
90
- ].join('\n'));
91
- }).then(() => {
92
- console.log('BTTV emotes test was successful.');
93
- }).catch(err => {
94
- console.error('BTTV emotes test failed!');
95
- console.error(err);
96
- });
97
-
98
-
99
- /**
100
- * Test FrankerFaceZ fetching and parsing.
101
- *
102
- * Tests:
103
- * - Fetch emotes
104
- * - FFZ Global
105
- * - FFZ Channel (0kody)
106
- * - FFZ Channel (shizuka_natsume)
107
- * - Parse to Markdown
108
- * - FFZ Global emote (CatBag)
109
- * - FFZ Channel emote (5Head)
110
- * - FFZ Channel animated emote (MikuSway)
111
- * - FFZ Channel emote (SanaeSip)
112
- * - FFZ modifier (ffzHyper)
113
- */
114
- const ffzFetcher = new EmoteFetcher();
115
- const ffzParser = new EmoteParser(ffzFetcher, {
116
- type: 'markdown',
117
- match: /:(.+?):/g
118
- });
119
-
120
- Promise.all([
121
- ffzFetcher.fetchFFZEmotes(),
122
- ffzFetcher.fetchFFZEmotes(44317909),
123
- ffzFetcher.fetchFFZEmotes(13638332)
124
- ]).then(() => {
125
- const text = ffzParser.parse(':CatBag:\n:5Head:\n:MikuSway:\n:SanaeSip: :ffzHyper:');
126
- assert.strictEqual(text, [
127
- '![CatBag](https://cdn.frankerfacez.com/emote/25927/1 "CatBag")',
128
- '![5Head](https://cdn.frankerfacez.com/emote/239504/1 "5Head")',
129
- '![MikuSway](https://cdn.frankerfacez.com/emote/723102/animated/1.webp "MikuSway")',
130
- // Note the trailing space as ffZHyper is removed but not the space before
131
- '![SanaeSip](https://cdn.frankerfacez.com/emote/305078/1 "SanaeSip") '
132
- ].join('\n'));
133
- }).then(() => {
134
- console.log('FFZ emotes test was successful.');
135
- }).catch(err => {
136
- console.error('FFZ emotes test failed!');
137
- console.error(err);
138
- });
139
-
140
- /**
141
- * Test 7TV fetching and parsing.
142
- *
143
- * Tests:
144
- * - Fetch emotes
145
- * - 7TV Global (in AVIF format)
146
- * - 7TV Channel (0kody)
147
- * - Parse to Markdown
148
- * - 7TV Global emote (EZ)
149
- * - 7TV Global emote (Clap)
150
- * - 7TV Channel emote (modCheck)
151
- */
152
- const sevenFetcher = new EmoteFetcher();
153
- const sevenParser = new EmoteParser(sevenFetcher, {
154
- type: 'markdown',
155
- match: /:(.+?):/g
156
- });
157
-
158
- Promise.all([
159
- sevenFetcher.fetchSevenTVEmotes(null, 'avif'),
160
- sevenFetcher.fetchSevenTVEmotes(44317909)
161
- ]).then(() => {
162
- const text = sevenParser.parse(':EZ:\n:Clap:\n:modCheck:');
163
- assert.strictEqual(text, [
164
- '![EZ](https://cdn.7tv.app/emote/63071b80942ffb69e13d700f/1x.avif "EZ")',
165
- '![Clap](https://cdn.7tv.app/emote/62fc0a0c4a75fd54bd3520a9/1x.avif "Clap")',
166
- '![modCheck](https://cdn.7tv.app/emote/60abf171870d317bef23d399/1x.webp "modCheck")'
167
- ].join('\n'));
168
- }).then(() => {
169
- console.log('7TV emotes test was successful.');
170
- }).catch(err => {
171
- console.error('7TV emotes test failed!');
172
- console.error('(Note that they might be different during certain events like Halloween.)');
173
- console.error(err);
174
- });
1
+ /* eslint-disable no-console */
2
+
3
+ const assert = require('assert');
4
+ const { env } = require('process');
5
+ const { EmoteFetcher, EmoteParser } = require('../src/index.js');
6
+
7
+ /**
8
+ * If environement variables are set, test Twitch fetching and parsing.
9
+ *
10
+ * Tests:
11
+ * - Fetch emotes
12
+ * - Twitch Global
13
+ * - Twitch Channel (twitchplayspokemon)
14
+ * - Link to Kappa
15
+ * - Parse to Markdown
16
+ * - Twitch Global emote (CoolCat)
17
+ * - Twitch Channel emote (tppD)
18
+ */
19
+ if (env.TWITCH_ID !== undefined && env.TWITCH_SECRET !== undefined) {
20
+ const twitchFetcher = new EmoteFetcher(env.TWITCH_ID, env.TWITCH_SECRET);
21
+ const twitchParser = new EmoteParser(twitchFetcher, {
22
+ type: 'markdown',
23
+ match: /:(.+?):/g
24
+ });
25
+
26
+ Promise.all([
27
+ twitchFetcher.fetchTwitchEmotes(),
28
+ twitchFetcher.fetchTwitchEmotes(56648155)
29
+ ]).then(() => {
30
+ const kappa = twitchFetcher.emotes.get('Kappa');
31
+ assert.strictEqual(kappa.toLink(2), 'https://static-cdn.jtvnw.net/emoticons/v2/25/default/dark/3.0');
32
+
33
+ const text = twitchParser.parse(':CoolCat:\n:tppD:');
34
+ assert.strictEqual(text, [
35
+ '![CoolCat](https://static-cdn.jtvnw.net/emoticons/v2/58127/default/dark/1.0 "CoolCat")',
36
+ '![tppD](https://static-cdn.jtvnw.net/emoticons/v2/307609315/default/dark/1.0 "tppD")'
37
+ ].join('\n'));
38
+ }).then(() => {
39
+ console.log('Twitch emotes test was successful.');
40
+ }).catch(err => {
41
+ console.error('Twitch emotes test failed!');
42
+ console.error(err);
43
+ });
44
+ } else {
45
+ console.log('Notice: Twitch client id/secret missing.');
46
+ }
47
+
48
+ /*
49
+ * Code should throw if we try to fetch Twitch emotes without a Client ID and Secret
50
+ */
51
+ const twitchFaultyFetcher = new EmoteFetcher();
52
+
53
+ try {
54
+ assert.throws(() => {
55
+ twitchFaultyFetcher.fetchTwitchEmotes();
56
+ }, new Error('Client id or client secret not provided.'));
57
+ console.log('Twitch emotes test (without API keys) was successful.');
58
+ } catch (err) {
59
+ console.error('Twitch emotes test (without API keys) failed!');
60
+ console.error(err);
61
+ }
62
+
63
+ /**
64
+ * Test BetterTTV fetching and parsing.
65
+ *
66
+ * Tests:
67
+ * - Fetch emotes
68
+ * - BTTV Global
69
+ * - BTTV Channel (twitchplayspokemon)
70
+ * - Parse to Markdown
71
+ * - BTTV Global emote (SourPls)
72
+ * - BTTV Channel emote (tppUrn)
73
+ * - BTTV Shared emote (MODS)
74
+ */
75
+ const bttvFetcher = new EmoteFetcher();
76
+ const bttvParser = new EmoteParser(bttvFetcher, {
77
+ type: 'markdown',
78
+ match: /:(.+?):/g
79
+ });
80
+
81
+ Promise.all([
82
+ bttvFetcher.fetchBTTVEmotes(),
83
+ bttvFetcher.fetchBTTVEmotes(56648155)
84
+ ]).then(() => {
85
+ const text = bttvParser.parse(':SourPls:\n:tppUrn:\n:MODS:');
86
+ assert.strictEqual(text, [
87
+ '![SourPls](https://cdn.betterttv.net/emote/566ca38765dbbdab32ec0560/1x.webp "SourPls")',
88
+ '![tppUrn](https://cdn.betterttv.net/emote/5f5f7d5f68d9d86c020e8672/1x.webp "tppUrn")',
89
+ '![MODS](https://cdn.betterttv.net/emote/5f2c4f9e65fe924464ef6d61/1x.webp "MODS")'
90
+ ].join('\n'));
91
+ }).then(() => {
92
+ console.log('BTTV emotes test was successful.');
93
+ }).catch(err => {
94
+ console.error('BTTV emotes test failed!');
95
+ console.error(err);
96
+ });
97
+
98
+
99
+ /**
100
+ * Test FrankerFaceZ fetching and parsing.
101
+ *
102
+ * Tests:
103
+ * - Fetch emotes
104
+ * - FFZ Global
105
+ * - FFZ Channel (0kody)
106
+ * - FFZ Channel (shizuka_natsume)
107
+ * - Parse to Markdown
108
+ * - FFZ Global emote (CatBag)
109
+ * - FFZ Channel emote (5Head)
110
+ * - FFZ Channel animated emote (MikuSway)
111
+ * - FFZ Channel emote (SanaeSip)
112
+ * - FFZ modifier (ffzHyper)
113
+ */
114
+ const ffzFetcher = new EmoteFetcher();
115
+ const ffzParser = new EmoteParser(ffzFetcher, {
116
+ type: 'markdown',
117
+ match: /:(.+?):/g
118
+ });
119
+
120
+ Promise.all([
121
+ ffzFetcher.fetchFFZEmotes(),
122
+ ffzFetcher.fetchFFZEmotes(44317909),
123
+ ffzFetcher.fetchFFZEmotes(13638332)
124
+ ]).then(() => {
125
+ const text = ffzParser.parse(':CatBag:\n:5Head:\n:MikuSway:\n:SanaeSip: :ffzHyper:');
126
+ assert.strictEqual(text, [
127
+ '![CatBag](https://cdn.frankerfacez.com/emote/25927/1 "CatBag")',
128
+ '![5Head](https://cdn.frankerfacez.com/emote/239504/1 "5Head")',
129
+ '![MikuSway](https://cdn.frankerfacez.com/emote/723102/animated/1.webp "MikuSway")',
130
+ // Note the trailing space as ffZHyper is removed but not the space before
131
+ '![SanaeSip](https://cdn.frankerfacez.com/emote/305078/1 "SanaeSip") '
132
+ ].join('\n'));
133
+ }).then(() => {
134
+ console.log('FFZ emotes test was successful.');
135
+ }).catch(err => {
136
+ console.error('FFZ emotes test failed!');
137
+ console.error(err);
138
+ });
139
+
140
+ /**
141
+ * Test 7TV fetching and parsing.
142
+ *
143
+ * Tests:
144
+ * - Fetch emotes
145
+ * - 7TV Global (in AVIF format)
146
+ * - 7TV Channel (0kody)
147
+ * - Parse to Markdown
148
+ * - 7TV Global emote (EZ)
149
+ * - 7TV Global emote (Clap)
150
+ * - 7TV Channel emote (modCheck)
151
+ */
152
+ const sevenFetcher = new EmoteFetcher();
153
+ const sevenParser = new EmoteParser(sevenFetcher, {
154
+ type: 'markdown',
155
+ match: /:(.+?):/g
156
+ });
157
+
158
+ Promise.all([
159
+ sevenFetcher.fetchSevenTVEmotes(null, 'avif'),
160
+ sevenFetcher.fetchSevenTVEmotes(44317909)
161
+ ]).then(() => {
162
+ const text = sevenParser.parse(':EZ:\n:Clap:\n:modCheck:');
163
+ assert.strictEqual(text, [
164
+ '![EZ](https://cdn.7tv.app/emote/63071b80942ffb69e13d700f/1x.avif "EZ")',
165
+ '![Clap](https://cdn.7tv.app/emote/62fc0a0c4a75fd54bd3520a9/1x.avif "Clap")',
166
+ '![modCheck](https://cdn.7tv.app/emote/60abf171870d317bef23d399/1x.webp "modCheck")'
167
+ ].join('\n'));
168
+ }).then(() => {
169
+ console.log('7TV emotes test was successful.');
170
+ }).catch(err => {
171
+ console.error('7TV emotes test failed!');
172
+ console.error('(Note that they might be different during certain events like Halloween.)');
173
+ console.error(err);
174
+ });