@mkody/twitch-emoticons 2.5.0 → 2.6.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/.jsdoc.json +5 -0
- package/LICENSE +1 -0
- package/README.md +85 -13
- package/docs/BTTVEmote.html +87 -37
- package/docs/Channel.html +165 -42
- package/docs/Collection.html +42 -36
- package/docs/Emote.html +58 -25
- package/docs/EmoteFetcher.html +2694 -2075
- package/docs/EmoteParser.html +39 -20
- package/docs/FFZEmote.html +91 -37
- package/docs/SevenTV.html +1191 -0
- package/docs/SevenTVEmote.html +1318 -0
- package/docs/TwitchEmote.html +85 -37
- package/docs/index.html +201 -132
- package/docs/scripts/collapse.js +19 -0
- package/docs/scripts/commonNav.js +28 -0
- package/docs/scripts/search.js +16 -0
- package/docs/struct_BTTVEmote.js.html +5 -2
- package/docs/struct_Channel.js.html +21 -10
- package/docs/struct_Emote.js.html +6 -3
- package/docs/struct_EmoteFetcher.js.html +168 -109
- package/docs/struct_EmoteParser.js.html +5 -2
- package/docs/struct_FFZEmote.js.html +5 -2
- package/docs/struct_SevenTVEmote.js.html +135 -0
- package/docs/struct_TwitchEmote.js.html +5 -2
- package/docs/styles/jsdoc.css +13 -2
- package/docs/styles/prettify.css +1 -0
- package/docs/util_Collection.js.html +5 -2
- package/package.json +15 -13
- package/src/index.js +4 -3
- package/src/struct/Channel.js +16 -8
- package/src/struct/Emote.js +1 -1
- package/src/struct/EmoteFetcher.js +96 -40
- package/src/struct/SevenTVEmote.js +63 -0
- package/src/util/Constants.js +5 -1
- package/test/index.js +39 -3
- package/typings/index.d.ts +35 -18
- package/typings/test.ts +0 -24
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
|
|
5
|
+
<meta charset="utf-8">
|
|
6
|
+
<title>struct/SevenTVEmote.js - Documentation</title>
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
<script src="scripts/prettify/prettify.js"></script>
|
|
10
|
+
<script src="scripts/prettify/lang-css.js"></script>
|
|
11
|
+
<!--[if lt IE 9]>
|
|
12
|
+
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
13
|
+
<![endif]-->
|
|
14
|
+
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
|
15
|
+
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
|
16
|
+
<script src="scripts/nav.js" defer></script>
|
|
17
|
+
|
|
18
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
19
|
+
</head>
|
|
20
|
+
<body>
|
|
21
|
+
|
|
22
|
+
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
|
23
|
+
<label for="nav-trigger" class="navicon-button x">
|
|
24
|
+
<div class="navicon"></div>
|
|
25
|
+
</label>
|
|
26
|
+
|
|
27
|
+
<label for="nav-trigger" class="overlay"></label>
|
|
28
|
+
|
|
29
|
+
<nav >
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="BTTVEmote.html">BTTVEmote</a><ul class='methods'><li data-type='method'><a href="BTTVEmote.html#.toLink#toLink">toLink</a></li><li data-type='method'><a href="BTTVEmote.html#.toString#toString">toString</a></li></ul></li><li><a href="Channel.html">Channel</a><ul class='methods'><li data-type='method'><a href="Channel.html#.fetchBTTVEmotes#fetchBTTVEmotes">fetchBTTVEmotes</a></li><li data-type='method'><a href="Channel.html#.fetchFFZEmotes#fetchFFZEmotes">fetchFFZEmotes</a></li><li data-type='method'><a href="Channel.html#.fetchSevenTVEmotes#fetchSevenTVEmotes">fetchSevenTVEmotes</a></li></ul></li><li><a href="Collection.html">Collection</a><ul class='methods'><li data-type='method'><a href="Collection.html#.filter#filter">filter</a></li><li data-type='method'><a href="Collection.html#.find#find">find</a></li><li data-type='method'><a href="Collection.html#.map#map">map</a></li></ul></li><li><a href="Emote.html">Emote</a><ul class='methods'><li data-type='method'><a href="Emote.html#.toString#toString">toString</a></li></ul></li><li><a href="EmoteFetcher.html">EmoteFetcher</a><ul class='methods'><li data-type='method'><a href="EmoteFetcher.html#._cacheBTTVEmote#_cacheBTTVEmote">_cacheBTTVEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#._cacheFFZEmote#_cacheFFZEmote">_cacheFFZEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#._cacheSevenTVEmote#_cacheSevenTVEmote">_cacheSevenTVEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#._cacheTwitchEmote#_cacheTwitchEmote">_cacheTwitchEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#._getRawBTTVEmotes#_getRawBTTVEmotes">_getRawBTTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#._getRawFFZEmotes#_getRawFFZEmotes">_getRawFFZEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#._getRawSevenTVEmotes#_getRawSevenTVEmotes">_getRawSevenTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#._getRawTwitchEmotes#_getRawTwitchEmotes">_getRawTwitchEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#.fetchBTTVEmotes#fetchBTTVEmotes">fetchBTTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#.fetchFFZEmotes#fetchFFZEmotes">fetchFFZEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#.fetchSevenTVEmotes#fetchSevenTVEmotes">fetchSevenTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#.fetchTwitchEmotes#fetchTwitchEmotes">fetchTwitchEmotes</a></li></ul></li><li><a href="EmoteParser.html">EmoteParser</a><ul class='methods'><li data-type='method'><a href="EmoteParser.html#.parse#parse">parse</a></li></ul></li><li><a href="FFZEmote.html">FFZEmote</a><ul class='methods'><li data-type='method'><a href="FFZEmote.html#.toLink#toLink">toLink</a></li><li data-type='method'><a href="FFZEmote.html#.toString#toString">toString</a></li></ul></li><li><a href="SevenTVEmote.html">SevenTVEmote</a><ul class='methods'><li data-type='method'><a href="SevenTVEmote.html#.toLink#toLink">toLink</a></li><li data-type='method'><a href="SevenTVEmote.html#.toString#toString">toString</a></li></ul></li><li><a href="TwitchEmote.html">TwitchEmote</a><ul class='methods'><li data-type='method'><a href="TwitchEmote.html#.toLink#toLink">toLink</a></li><li data-type='method'><a href="TwitchEmote.html#.toString#toString">toString</a></li></ul></li></ul>
|
|
33
|
+
|
|
34
|
+
</nav>
|
|
35
|
+
|
|
36
|
+
<div id="main">
|
|
37
|
+
|
|
38
|
+
<h1 class="page-title">struct/SevenTVEmote.js</h1>
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
<section>
|
|
47
|
+
<article>
|
|
48
|
+
<pre class="prettyprint source linenums"><code>const Emote = require('./Emote');
|
|
49
|
+
const Constants = require('../util/Constants');
|
|
50
|
+
|
|
51
|
+
/** @extends Emote */
|
|
52
|
+
class SevenTVEmote extends Emote {
|
|
53
|
+
/**
|
|
54
|
+
* A 7TV emote.
|
|
55
|
+
* @param {Channel} channel - Channel this emote belongs to.
|
|
56
|
+
* @param {string} id - ID of the emote.
|
|
57
|
+
* @param {data} data - The raw emote data.
|
|
58
|
+
*/
|
|
59
|
+
constructor(channel, id, data) {
|
|
60
|
+
super(channel, id, data);
|
|
61
|
+
this.type = '7tv';
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The channel of this emote's creator.
|
|
66
|
+
* Not guaranteed to contain the emote, or be cached.
|
|
67
|
+
* @readonly
|
|
68
|
+
* @type {?Channel}
|
|
69
|
+
*/
|
|
70
|
+
get owner() {
|
|
71
|
+
return this.fetcher.channels.get(this.ownerName);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
_setup(data) {
|
|
75
|
+
super._setup(data);
|
|
76
|
+
this.code = data.name;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The name of the emote creator's channel.
|
|
80
|
+
* @type {string}
|
|
81
|
+
*/
|
|
82
|
+
this.ownerName = data.owner.display_name;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Available image sizes.
|
|
86
|
+
* @type {string[]}
|
|
87
|
+
*/
|
|
88
|
+
this.sizes = data.host.files
|
|
89
|
+
.filter(el => el.format === this.channel.format.toUpperCase())
|
|
90
|
+
.map(el => el.name);
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The image type of the emote.
|
|
94
|
+
* @type {string}
|
|
95
|
+
*/
|
|
96
|
+
this.imageType = this.channel.format;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Gets the image link of the emote.
|
|
101
|
+
* @param {number} size - The size of the image.
|
|
102
|
+
* @returns {string}
|
|
103
|
+
*/
|
|
104
|
+
toLink(size = 0) {
|
|
105
|
+
size = this.sizes[size];
|
|
106
|
+
return Constants.SEVENTV.CDN(this.id, size); // eslint-disable-line new-cap
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
module.exports = SevenTVEmote;
|
|
111
|
+
</code></pre>
|
|
112
|
+
</article>
|
|
113
|
+
</section>
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
</div>
|
|
121
|
+
|
|
122
|
+
<br class="clear">
|
|
123
|
+
|
|
124
|
+
<footer>
|
|
125
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
126
|
+
</footer>
|
|
127
|
+
|
|
128
|
+
<script>prettyPrint();</script>
|
|
129
|
+
<script src="scripts/polyfill.js"></script>
|
|
130
|
+
<script src="scripts/linenumber.js"></script>
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
</body>
|
|
135
|
+
</html>
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
|
15
15
|
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
|
16
16
|
<script src="scripts/nav.js" defer></script>
|
|
17
|
+
|
|
17
18
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
18
19
|
</head>
|
|
19
20
|
<body>
|
|
@@ -27,7 +28,9 @@
|
|
|
27
28
|
|
|
28
29
|
<nav >
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
|
|
32
|
+
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="BTTVEmote.html">BTTVEmote</a><ul class='methods'><li data-type='method'><a href="BTTVEmote.html#.toLink#toLink">toLink</a></li><li data-type='method'><a href="BTTVEmote.html#.toString#toString">toString</a></li></ul></li><li><a href="Channel.html">Channel</a><ul class='methods'><li data-type='method'><a href="Channel.html#.fetchBTTVEmotes#fetchBTTVEmotes">fetchBTTVEmotes</a></li><li data-type='method'><a href="Channel.html#.fetchFFZEmotes#fetchFFZEmotes">fetchFFZEmotes</a></li><li data-type='method'><a href="Channel.html#.fetchSevenTVEmotes#fetchSevenTVEmotes">fetchSevenTVEmotes</a></li></ul></li><li><a href="Collection.html">Collection</a><ul class='methods'><li data-type='method'><a href="Collection.html#.filter#filter">filter</a></li><li data-type='method'><a href="Collection.html#.find#find">find</a></li><li data-type='method'><a href="Collection.html#.map#map">map</a></li></ul></li><li><a href="Emote.html">Emote</a><ul class='methods'><li data-type='method'><a href="Emote.html#.toString#toString">toString</a></li></ul></li><li><a href="EmoteFetcher.html">EmoteFetcher</a><ul class='methods'><li data-type='method'><a href="EmoteFetcher.html#._cacheBTTVEmote#_cacheBTTVEmote">_cacheBTTVEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#._cacheFFZEmote#_cacheFFZEmote">_cacheFFZEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#._cacheSevenTVEmote#_cacheSevenTVEmote">_cacheSevenTVEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#._cacheTwitchEmote#_cacheTwitchEmote">_cacheTwitchEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#._getRawBTTVEmotes#_getRawBTTVEmotes">_getRawBTTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#._getRawFFZEmotes#_getRawFFZEmotes">_getRawFFZEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#._getRawSevenTVEmotes#_getRawSevenTVEmotes">_getRawSevenTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#._getRawTwitchEmotes#_getRawTwitchEmotes">_getRawTwitchEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#.fetchBTTVEmotes#fetchBTTVEmotes">fetchBTTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#.fetchFFZEmotes#fetchFFZEmotes">fetchFFZEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#.fetchSevenTVEmotes#fetchSevenTVEmotes">fetchSevenTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#.fetchTwitchEmotes#fetchTwitchEmotes">fetchTwitchEmotes</a></li></ul></li><li><a href="EmoteParser.html">EmoteParser</a><ul class='methods'><li data-type='method'><a href="EmoteParser.html#.parse#parse">parse</a></li></ul></li><li><a href="FFZEmote.html">FFZEmote</a><ul class='methods'><li data-type='method'><a href="FFZEmote.html#.toLink#toLink">toLink</a></li><li data-type='method'><a href="FFZEmote.html#.toString#toString">toString</a></li></ul></li><li><a href="SevenTVEmote.html">SevenTVEmote</a><ul class='methods'><li data-type='method'><a href="SevenTVEmote.html#.toLink#toLink">toLink</a></li><li data-type='method'><a href="SevenTVEmote.html#.toString#toString">toString</a></li></ul></li><li><a href="TwitchEmote.html">TwitchEmote</a><ul class='methods'><li data-type='method'><a href="TwitchEmote.html#.toLink#toLink">toLink</a></li><li data-type='method'><a href="TwitchEmote.html#.toString#toString">toString</a></li></ul></li></ul>
|
|
33
|
+
|
|
31
34
|
</nav>
|
|
32
35
|
|
|
33
36
|
<div id="main">
|
|
@@ -108,7 +111,7 @@ module.exports = TwitchEmote;
|
|
|
108
111
|
<br class="clear">
|
|
109
112
|
|
|
110
113
|
<footer>
|
|
111
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc
|
|
114
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
112
115
|
</footer>
|
|
113
116
|
|
|
114
117
|
<script>prettyPrint();</script>
|
package/docs/styles/jsdoc.css
CHANGED
|
@@ -162,12 +162,19 @@ h6 {
|
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
|
|
165
|
-
tt, code, kbd, samp {
|
|
165
|
+
tt, code, kbd, samp, pre {
|
|
166
166
|
font-family: Consolas, Monaco, 'Andale Mono', monospace;
|
|
167
167
|
background: #f4f4f4;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
tt, code, kbd, samp{
|
|
168
171
|
padding: 1px 5px;
|
|
169
172
|
}
|
|
170
173
|
|
|
174
|
+
pre {
|
|
175
|
+
padding-bottom: 1em;
|
|
176
|
+
}
|
|
177
|
+
|
|
171
178
|
.class-description {
|
|
172
179
|
font-size: 130%;
|
|
173
180
|
line-height: 140%;
|
|
@@ -242,6 +249,10 @@ nav h3 {
|
|
|
242
249
|
color: #000;
|
|
243
250
|
}
|
|
244
251
|
|
|
252
|
+
nav h3.collapsed_header {
|
|
253
|
+
cursor: pointer;
|
|
254
|
+
}
|
|
255
|
+
|
|
245
256
|
nav ul {
|
|
246
257
|
font-family: 'Lucida Grande', 'Lucida Sans Unicode', arial, sans-serif;
|
|
247
258
|
font-size: 100%;
|
|
@@ -762,4 +773,4 @@ html[data-search-mode] .level-hide {
|
|
|
762
773
|
font-weight: 300;
|
|
763
774
|
font-style: normal;
|
|
764
775
|
|
|
765
|
-
}
|
|
776
|
+
}
|
package/docs/styles/prettify.css
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
|
15
15
|
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
|
16
16
|
<script src="scripts/nav.js" defer></script>
|
|
17
|
+
|
|
17
18
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
18
19
|
</head>
|
|
19
20
|
<body>
|
|
@@ -27,7 +28,9 @@
|
|
|
27
28
|
|
|
28
29
|
<nav >
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
|
|
32
|
+
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="BTTVEmote.html">BTTVEmote</a><ul class='methods'><li data-type='method'><a href="BTTVEmote.html#.toLink#toLink">toLink</a></li><li data-type='method'><a href="BTTVEmote.html#.toString#toString">toString</a></li></ul></li><li><a href="Channel.html">Channel</a><ul class='methods'><li data-type='method'><a href="Channel.html#.fetchBTTVEmotes#fetchBTTVEmotes">fetchBTTVEmotes</a></li><li data-type='method'><a href="Channel.html#.fetchFFZEmotes#fetchFFZEmotes">fetchFFZEmotes</a></li><li data-type='method'><a href="Channel.html#.fetchSevenTVEmotes#fetchSevenTVEmotes">fetchSevenTVEmotes</a></li></ul></li><li><a href="Collection.html">Collection</a><ul class='methods'><li data-type='method'><a href="Collection.html#.filter#filter">filter</a></li><li data-type='method'><a href="Collection.html#.find#find">find</a></li><li data-type='method'><a href="Collection.html#.map#map">map</a></li></ul></li><li><a href="Emote.html">Emote</a><ul class='methods'><li data-type='method'><a href="Emote.html#.toString#toString">toString</a></li></ul></li><li><a href="EmoteFetcher.html">EmoteFetcher</a><ul class='methods'><li data-type='method'><a href="EmoteFetcher.html#._cacheBTTVEmote#_cacheBTTVEmote">_cacheBTTVEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#._cacheFFZEmote#_cacheFFZEmote">_cacheFFZEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#._cacheSevenTVEmote#_cacheSevenTVEmote">_cacheSevenTVEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#._cacheTwitchEmote#_cacheTwitchEmote">_cacheTwitchEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#._getRawBTTVEmotes#_getRawBTTVEmotes">_getRawBTTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#._getRawFFZEmotes#_getRawFFZEmotes">_getRawFFZEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#._getRawSevenTVEmotes#_getRawSevenTVEmotes">_getRawSevenTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#._getRawTwitchEmotes#_getRawTwitchEmotes">_getRawTwitchEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#.fetchBTTVEmotes#fetchBTTVEmotes">fetchBTTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#.fetchFFZEmotes#fetchFFZEmotes">fetchFFZEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#.fetchSevenTVEmotes#fetchSevenTVEmotes">fetchSevenTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#.fetchTwitchEmotes#fetchTwitchEmotes">fetchTwitchEmotes</a></li></ul></li><li><a href="EmoteParser.html">EmoteParser</a><ul class='methods'><li data-type='method'><a href="EmoteParser.html#.parse#parse">parse</a></li></ul></li><li><a href="FFZEmote.html">FFZEmote</a><ul class='methods'><li data-type='method'><a href="FFZEmote.html#.toLink#toLink">toLink</a></li><li data-type='method'><a href="FFZEmote.html#.toString#toString">toString</a></li></ul></li><li><a href="SevenTVEmote.html">SevenTVEmote</a><ul class='methods'><li data-type='method'><a href="SevenTVEmote.html#.toLink#toLink">toLink</a></li><li data-type='method'><a href="SevenTVEmote.html#.toString#toString">toString</a></li></ul></li><li><a href="TwitchEmote.html">TwitchEmote</a><ul class='methods'><li data-type='method'><a href="TwitchEmote.html#.toLink#toLink">toLink</a></li><li data-type='method'><a href="TwitchEmote.html#.toString#toString">toString</a></li></ul></li></ul>
|
|
33
|
+
|
|
31
34
|
</nav>
|
|
32
35
|
|
|
33
36
|
<div id="main">
|
|
@@ -134,7 +137,7 @@ module.exports = Collection;
|
|
|
134
137
|
<br class="clear">
|
|
135
138
|
|
|
136
139
|
<footer>
|
|
137
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc
|
|
140
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
138
141
|
</footer>
|
|
139
142
|
|
|
140
143
|
<script>prettyPrint();</script>
|
package/package.json
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mkody/twitch-emoticons",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"description": "Gets Twitch, BTTV and FFZ emotes as well as parsing text to emotes!",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"typings": "typings/index.d.ts",
|
|
7
7
|
"keywords": [
|
|
8
|
-
"
|
|
8
|
+
"7tv",
|
|
9
|
+
"bettertwitchtv",
|
|
9
10
|
"bttv",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"emoticon",
|
|
11
|
+
"emotes",
|
|
12
|
+
"emoticons",
|
|
13
13
|
"ffz",
|
|
14
|
+
"frankerfacez",
|
|
14
15
|
"parse",
|
|
15
|
-
"
|
|
16
|
+
"seventv",
|
|
17
|
+
"twitch-api",
|
|
16
18
|
"twitch"
|
|
17
19
|
],
|
|
18
20
|
"author": "MKody <gh@kdy.ch> (André Fernandes)",
|
|
@@ -23,17 +25,17 @@
|
|
|
23
25
|
],
|
|
24
26
|
"license": "MIT",
|
|
25
27
|
"dependencies": {
|
|
26
|
-
"@twurple/api": "^5.
|
|
27
|
-
"@twurple/auth": "^5.
|
|
28
|
-
"got": "^11.8.
|
|
28
|
+
"@twurple/api": "^5.2.7",
|
|
29
|
+
"@twurple/auth": "^5.2.7",
|
|
30
|
+
"got": "^11.8.6"
|
|
29
31
|
},
|
|
30
32
|
"devDependencies": {
|
|
31
|
-
"docdash": "^
|
|
32
|
-
"eslint": "^8.
|
|
33
|
-
"jsdoc": "^
|
|
33
|
+
"docdash": "^2.0.0",
|
|
34
|
+
"eslint": "^8.29.0",
|
|
35
|
+
"jsdoc": "^4.0.0"
|
|
34
36
|
},
|
|
35
37
|
"scripts": {
|
|
36
|
-
"docs": "jsdoc --configure .jsdoc.json --verbose
|
|
38
|
+
"docs": "jsdoc --configure .jsdoc.json --verbose",
|
|
37
39
|
"test": "node test/index.js",
|
|
38
40
|
"lint": "eslint ./src ./test"
|
|
39
41
|
},
|
package/src/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
BTTVEmote: require('./struct/BTTVEmote'),
|
|
3
3
|
Channel: require('./struct/Channel'),
|
|
4
|
+
Collection: require('./util/Collection'),
|
|
5
|
+
Constants: require('./util/Constants'),
|
|
4
6
|
Emote: require('./struct/Emote'),
|
|
5
7
|
EmoteFetcher: require('./struct/EmoteFetcher'),
|
|
6
8
|
EmoteParser: require('./struct/EmoteParser'),
|
|
7
9
|
FFZEmote: require('./struct/FFZEmote'),
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Constants: require('./util/Constants')
|
|
10
|
+
SevenTVEmote: require('./struct/SevenTVEmote'),
|
|
11
|
+
TwitchEmote: require('./struct/TwitchEmote')
|
|
11
12
|
};
|
package/src/struct/Channel.js
CHANGED
|
@@ -4,9 +4,9 @@ class Channel {
|
|
|
4
4
|
/**
|
|
5
5
|
* A Twitch channel.
|
|
6
6
|
* @param {EmoteFetcher} fetcher - The emote fetcher.
|
|
7
|
-
* @param {
|
|
7
|
+
* @param {int} id - ID of the channel.
|
|
8
8
|
*/
|
|
9
|
-
constructor(fetcher,
|
|
9
|
+
constructor(fetcher, id) {
|
|
10
10
|
/**
|
|
11
11
|
* The emote fetcher.
|
|
12
12
|
* @type {EmoteFetcher}
|
|
@@ -14,11 +14,11 @@ class Channel {
|
|
|
14
14
|
this.fetcher = fetcher;
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* The
|
|
18
|
-
* For the global channel, the
|
|
19
|
-
* @type {?
|
|
17
|
+
* The ID of this channel.
|
|
18
|
+
* For the global channel, the ID will be null.
|
|
19
|
+
* @type {?int}
|
|
20
20
|
*/
|
|
21
|
-
this.
|
|
21
|
+
this.channel_id = id;
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Cached emotes belonging to this channel.
|
|
@@ -32,7 +32,7 @@ class Channel {
|
|
|
32
32
|
* @returns {Promise<Collection<string, BTTVEmote>>}
|
|
33
33
|
*/
|
|
34
34
|
fetchBTTVEmotes() {
|
|
35
|
-
return this.fetcher.fetchBTTVEmotes(this.
|
|
35
|
+
return this.fetcher.fetchBTTVEmotes(this.id);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/**
|
|
@@ -40,7 +40,15 @@ class Channel {
|
|
|
40
40
|
* @returns {Promise<Collection<string, FFZEmote>>}
|
|
41
41
|
*/
|
|
42
42
|
fetchFFZEmotes() {
|
|
43
|
-
return this.fetcher.fetchFFZEmotes(this.
|
|
43
|
+
return this.fetcher.fetchFFZEmotes(this.id);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Fetches the 7TV emotes for this channel.
|
|
48
|
+
* @returns {Promise<Collection<string, SevenTVEmote>>}
|
|
49
|
+
*/
|
|
50
|
+
fetchSevenTVEmotes() {
|
|
51
|
+
return this.fetcher.fetchSevenTVEmotes(this.id);
|
|
44
52
|
}
|
|
45
53
|
}
|
|
46
54
|
|
package/src/struct/Emote.js
CHANGED
|
@@ -3,6 +3,8 @@ const Channel = require('./Channel');
|
|
|
3
3
|
const Collection = require('../util/Collection');
|
|
4
4
|
const Constants = require('../util/Constants');
|
|
5
5
|
const FFZEmote = require('./FFZEmote');
|
|
6
|
+
const SevenTVEmote = require('./SevenTVEmote');
|
|
7
|
+
|
|
6
8
|
const got = require('got');
|
|
7
9
|
const TwitchEmote = require('./TwitchEmote');
|
|
8
10
|
const { ApiClient } = require('@twurple/api');
|
|
@@ -44,7 +46,7 @@ class EmoteFetcher {
|
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
/**
|
|
47
|
-
* The global channel for
|
|
49
|
+
* The global channel for Twitch, BTTV and 7TV.
|
|
48
50
|
* @readonly
|
|
49
51
|
* @type {?Channel}
|
|
50
52
|
*/
|
|
@@ -55,7 +57,7 @@ class EmoteFetcher {
|
|
|
55
57
|
/**
|
|
56
58
|
* Gets the raw Twitch emotes data for a channel.
|
|
57
59
|
* @private
|
|
58
|
-
* @param {int} id -
|
|
60
|
+
* @param {int} id - ID of the channel.
|
|
59
61
|
* @returns {Promise<Object[]>}
|
|
60
62
|
*/
|
|
61
63
|
_getRawTwitchEmotes(id) {
|
|
@@ -73,15 +75,15 @@ class EmoteFetcher {
|
|
|
73
75
|
/**
|
|
74
76
|
* Converts and caches a raw twitch emote.
|
|
75
77
|
* @private
|
|
76
|
-
* @param {
|
|
78
|
+
* @param {int} channel_id - ID of the channel.
|
|
77
79
|
* @param {Object} data - Raw data.
|
|
78
80
|
* @returns {TwitchEmote}
|
|
79
81
|
*/
|
|
80
|
-
_cacheTwitchEmote(
|
|
81
|
-
let channel = this.channels.get(
|
|
82
|
+
_cacheTwitchEmote(channel_id, data) {
|
|
83
|
+
let channel = this.channels.get(channel_id);
|
|
82
84
|
if (!channel) {
|
|
83
|
-
channel = new Channel(this,
|
|
84
|
-
this.channels.set(
|
|
85
|
+
channel = new Channel(this, channel_id);
|
|
86
|
+
this.channels.set(channel_id, channel);
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
const emote = new TwitchEmote(channel, data.id, data);
|
|
@@ -113,15 +115,15 @@ class EmoteFetcher {
|
|
|
113
115
|
/**
|
|
114
116
|
* Converts and caches a raw BTTV emote.
|
|
115
117
|
* @private
|
|
116
|
-
* @param {
|
|
118
|
+
* @param {int} channel_id - ID of the channel.
|
|
117
119
|
* @param {Object} data - Raw data.
|
|
118
120
|
* @returns {BTTVEmote}
|
|
119
121
|
*/
|
|
120
|
-
_cacheBTTVEmote(
|
|
121
|
-
let channel = this.channels.get(
|
|
122
|
+
_cacheBTTVEmote(channel_id, data) {
|
|
123
|
+
let channel = this.channels.get(channel_id);
|
|
122
124
|
if (!channel) {
|
|
123
|
-
channel = new Channel(this,
|
|
124
|
-
this.channels.set(
|
|
125
|
+
channel = new Channel(this, channel_id);
|
|
126
|
+
this.channels.set(channel_id, channel);
|
|
125
127
|
}
|
|
126
128
|
|
|
127
129
|
const emote = new BTTVEmote(channel, data.id, data);
|
|
@@ -133,17 +135,11 @@ class EmoteFetcher {
|
|
|
133
135
|
/**
|
|
134
136
|
* Gets the raw FFZ emotes data for a channel.
|
|
135
137
|
* @private
|
|
136
|
-
* @param {
|
|
138
|
+
* @param {int} id - ID of the channel.
|
|
137
139
|
* @returns {Promise<Object[]>}
|
|
138
140
|
*/
|
|
139
141
|
_getRawFFZEmotes(id) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
if (typeof id === 'number') {
|
|
143
|
-
endpoint = Constants.FFZ.Channel(id); // eslint-disable-line new-cap
|
|
144
|
-
} else {
|
|
145
|
-
endpoint = Constants.FFZ.ChannelName(id); // eslint-disable-line new-cap
|
|
146
|
-
}
|
|
142
|
+
const endpoint = Constants.FFZ.Channel(id); // eslint-disable-line new-cap
|
|
147
143
|
|
|
148
144
|
return got(endpoint, options).then(req => {
|
|
149
145
|
const emotes = [];
|
|
@@ -159,15 +155,15 @@ class EmoteFetcher {
|
|
|
159
155
|
/**
|
|
160
156
|
* Converts and caches a raw FFZ emote.
|
|
161
157
|
* @private
|
|
162
|
-
* @param {
|
|
158
|
+
* @param {int} channel_id - ID of the channel.
|
|
163
159
|
* @param {Object} data - Raw data.
|
|
164
160
|
* @returns {FFZEmote}
|
|
165
161
|
*/
|
|
166
|
-
_cacheFFZEmote(
|
|
167
|
-
let channel = this.channels.get(
|
|
162
|
+
_cacheFFZEmote(channel_id, data) {
|
|
163
|
+
let channel = this.channels.get(channel_id);
|
|
168
164
|
if (!channel) {
|
|
169
|
-
channel = new Channel(this,
|
|
170
|
-
this.channels.set(
|
|
165
|
+
channel = new Channel(this, channel_id);
|
|
166
|
+
this.channels.set(channel_id, channel);
|
|
171
167
|
}
|
|
172
168
|
|
|
173
169
|
const emote = new FFZEmote(channel, data.id, data);
|
|
@@ -176,50 +172,110 @@ class EmoteFetcher {
|
|
|
176
172
|
return emote;
|
|
177
173
|
}
|
|
178
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Gets the raw 7TV emotes data for a channel.
|
|
177
|
+
* @private
|
|
178
|
+
* @param {int} [id=null] - ID of the channel.
|
|
179
|
+
* @returns {Promise<Object[]>}
|
|
180
|
+
*/
|
|
181
|
+
_getRawSevenTVEmotes(id) {
|
|
182
|
+
const endpoint = !id
|
|
183
|
+
? Constants.SEVENTV.Global
|
|
184
|
+
: Constants.SEVENTV.Channel(id); // eslint-disable-line new-cap
|
|
185
|
+
|
|
186
|
+
return got(endpoint, options).then(req => req.body);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Converts and caches a raw 7TV emote.
|
|
191
|
+
* @private
|
|
192
|
+
* @param {int} channel_id - ID of the channel.
|
|
193
|
+
* @param {Object} data - Raw data.
|
|
194
|
+
* @param {string} format - The type file format to use (webp/avif).
|
|
195
|
+
* @returns {SevenTVEmote}
|
|
196
|
+
*/
|
|
197
|
+
_cacheSevenTVEmote(channel_id, data, format) {
|
|
198
|
+
let channel = this.channels.get(channel_id);
|
|
199
|
+
if (!channel) {
|
|
200
|
+
channel = new Channel(this, channel_id);
|
|
201
|
+
channel.format = format;
|
|
202
|
+
this.channels.set(channel_id, channel);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const emote = new SevenTVEmote(channel, data.id, data);
|
|
206
|
+
this.emotes.set(emote.code, emote);
|
|
207
|
+
channel.emotes.set(emote.code, emote);
|
|
208
|
+
return emote;
|
|
209
|
+
}
|
|
210
|
+
|
|
179
211
|
/**
|
|
180
212
|
* Fetches the Twitch emotes for a channel.
|
|
181
213
|
* Use `null` for the global emotes channel.
|
|
182
|
-
* @param {int} [
|
|
214
|
+
* @param {int} [channel=null] - ID of the channel.
|
|
183
215
|
* @returns {Promise<Collection<string, TwitchEmote>>}
|
|
184
216
|
*/
|
|
185
|
-
fetchTwitchEmotes(
|
|
186
|
-
return this._getRawTwitchEmotes(
|
|
217
|
+
fetchTwitchEmotes(channel = null) {
|
|
218
|
+
return this._getRawTwitchEmotes(channel).then(rawEmotes => {
|
|
187
219
|
for (const emote of rawEmotes) {
|
|
188
|
-
this._cacheTwitchEmote(
|
|
220
|
+
this._cacheTwitchEmote(channel, { code: emote.name, id: emote.id });
|
|
189
221
|
}
|
|
190
222
|
|
|
191
|
-
return this.channels.get(
|
|
223
|
+
return this.channels.get(channel).emotes.filter(e => e.type === 'twitch');
|
|
192
224
|
});
|
|
193
225
|
}
|
|
194
226
|
|
|
195
227
|
/**
|
|
196
228
|
* Fetches the BTTV emotes for a channel.
|
|
197
229
|
* Use `null` for the global emotes channel.
|
|
198
|
-
* @param {
|
|
230
|
+
* @param {int} [channel=null] - ID of the channel.
|
|
199
231
|
* @returns {Promise<Collection<string, BTTVEmote>>}
|
|
200
232
|
*/
|
|
201
|
-
fetchBTTVEmotes(
|
|
202
|
-
return this._getRawBTTVEmotes(
|
|
233
|
+
fetchBTTVEmotes(channel = null) {
|
|
234
|
+
return this._getRawBTTVEmotes(channel).then(rawEmotes => {
|
|
203
235
|
for (const data of rawEmotes) {
|
|
204
|
-
this._cacheBTTVEmote(
|
|
236
|
+
this._cacheBTTVEmote(channel, data);
|
|
205
237
|
}
|
|
206
238
|
|
|
207
|
-
return this.channels.get(
|
|
239
|
+
return this.channels.get(channel).emotes.filter(e => e.type === 'bttv');
|
|
208
240
|
});
|
|
209
241
|
}
|
|
210
242
|
|
|
211
243
|
/**
|
|
212
244
|
* Fetches the FFZ emotes for a channel.
|
|
213
|
-
* @param {
|
|
245
|
+
* @param {int} channel - ID of the channel.
|
|
214
246
|
* @returns {Promise<Collection<string, FFZEmote>>}
|
|
215
247
|
*/
|
|
216
|
-
fetchFFZEmotes(
|
|
217
|
-
return this._getRawFFZEmotes(
|
|
248
|
+
fetchFFZEmotes(channel) {
|
|
249
|
+
return this._getRawFFZEmotes(channel).then(rawEmotes => {
|
|
218
250
|
for (const data of rawEmotes) {
|
|
219
|
-
this._cacheFFZEmote(
|
|
251
|
+
this._cacheFFZEmote(channel, data);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return this.channels.get(channel).emotes.filter(e => e.type === 'ffz');
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Fetches the 7TV emotes for a channel.
|
|
260
|
+
* @param {int} [channel=null] - ID of the channel.
|
|
261
|
+
* @param {('webp'|'avif')} [format='webp'] - The type file format to use (webp/avif).
|
|
262
|
+
* @returns {Promise<Collection<string, SevenTVEmote>>}
|
|
263
|
+
*/
|
|
264
|
+
fetchSevenTVEmotes(channel = null, format = 'webp') {
|
|
265
|
+
return this._getRawSevenTVEmotes(channel).then(rawEmotes => {
|
|
266
|
+
if ('emotes' in rawEmotes) {
|
|
267
|
+
// From an emote set (like "global")
|
|
268
|
+
for (const data of rawEmotes.emotes) {
|
|
269
|
+
this._cacheSevenTVEmote(channel, data.data, format);
|
|
270
|
+
}
|
|
271
|
+
} else {
|
|
272
|
+
// From users
|
|
273
|
+
for (const data of rawEmotes.emote_set.emotes) {
|
|
274
|
+
this._cacheSevenTVEmote(channel, data.data, format);
|
|
275
|
+
}
|
|
220
276
|
}
|
|
221
277
|
|
|
222
|
-
return this.channels.get(
|
|
278
|
+
return this.channels.get(channel).emotes.filter(e => e.type === '7tv');
|
|
223
279
|
});
|
|
224
280
|
}
|
|
225
281
|
}
|