Skip to content

Commit f23b1c4

Browse files
committed
initial commit
0 parents  commit f23b1c4

File tree

6 files changed

+91
-0
lines changed

6 files changed

+91
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.idea/
2+
*.iml
3+
node_modules/

LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Edward Ceaser
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
wip
2+

extension.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use strict';
2+
3+
const POLL_INTERVAL = 30*1000;
4+
5+
function Followers(nodecg) {
6+
this.nodecg = nodecg;
7+
this.twitch = nodecg.extensions['lfg-twitchapi'];
8+
this.latestFollower = nodecg.Replicant("latestFollower", {defaultValue: null, persistent: false});
9+
10+
this._scheduleFollowers();
11+
}
12+
13+
Followers.prototype._scheduleFollowers = function() {
14+
this.twitch.get('/channels/{{username}}/follows', { limit: 1, direction: 'desc' }, (err, code, body) => {
15+
if (err) {
16+
this.nodecg.log.error(err);
17+
setTimeout(() => { this._scheduleFollowers() }, POLL_INTERVAL);
18+
return;
19+
}
20+
21+
if (code != 200) {
22+
this.nodecg.log.error("Unknown response code: "+code);
23+
setTimeout(() => { this._scheduleFollowers() }, POLL_INTERVAL);
24+
return;
25+
}
26+
27+
if (body.follows.length > 0) {
28+
this.latestFollower.value = body.follows[0].display_name;
29+
}
30+
31+
setTimeout(() => { this._scheduleFollowers() }, POLL_INTERVAL);
32+
});
33+
}
34+
35+
module.exports = function(api) {
36+
return new Followers(api);
37+
};

nodecg.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "bubu-followers",
3+
"version": "0.1.0",
4+
"nodecgDependency": "~0.6.0",
5+
"homepage": "https://github.com/eaceaser/bubu-followers",
6+
"authors": [
7+
"Ed Ceaser <[email protected]>"
8+
],
9+
"description": "Tracks TwitchTV channel followers for the currently authenticated TwitchAPI user.",
10+
"license": "MIT",
11+
"extension": {
12+
"path": "extension.js"
13+
},
14+
"bundleDependencies": [ "lfg-twitchapi" ]
15+
}

package.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "bubu-followers",
3+
"version": "0.1.0",
4+
"homepage": "https://github.com/eaceaser/bubu-followers",
5+
"description": "Tracks TwitchTV channel followers. Currently runs in the dashboard.",
6+
"main": "extension.js",
7+
"author": "Ed Ceaser <[email protected]>",
8+
"license": "MIT",
9+
"dependencies": {
10+
"node-localstorage": "^0.6.0"
11+
}
12+
}

0 commit comments

Comments
 (0)