Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Init Commit
- Loading branch information
0 parents
commit abd45e8
Showing
250 changed files
with
122,285 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules/ | ||
static/semantic/src | ||
static/semantic/tasks | ||
static/semantic/gulpfile.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2017 Yevgeniy Pinskiy | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: node index.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# GBF-Raiders | ||
A Raid Finder For Grand Blue Fantasy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
let express = require( 'express' ); | ||
let twitter = require( 'twitter' ); | ||
let st = require( 'st' ); | ||
let app = express(); | ||
let bodyParser = require( 'body-parser' ); | ||
let server = require( 'http' ).createServer( app ); | ||
let io = require( 'socket.io' ).listen( server ); | ||
let port = process.env.PORT || 8080; | ||
server.listen( port ); | ||
|
||
let client = new twitter( { | ||
consumer_key: process.env.consumer_key, | ||
consumer_secret: process.env.consumer_secret, | ||
access_token_key: process.env.access_token_key, | ||
access_token_secret: process.env.access_token_secret | ||
} ); | ||
|
||
let raidConfigs = require( './raids.json' ); | ||
|
||
let keywords = ""; | ||
|
||
for ( let i = 0; i < raidConfigs.length; i++ ) { | ||
keywords += raidConfigs[ i ].english + "," + raidConfigs[ i ].japanese; | ||
if ( i != raidConfigs.length - 1 ) { | ||
keywords += ','; | ||
} | ||
} | ||
|
||
client.stream( 'statuses/filter', { | ||
track: keywords | ||
}, function ( stream ) { | ||
stream.on( 'data', function ( event ) { | ||
let room = searchTextForRaids( event.text ); | ||
var testId = event.text.substr( event.text.indexOf( 'ID' ) + 3, 9 ); | ||
if ( testId.charAt( 0 ) == " " ) { | ||
testId = testId.substr( 1, 8 ); | ||
} else { | ||
testId = testId.substr( 0, 8 ); | ||
} | ||
io.to( room ).emit( 'tweet', { | ||
id: testId, | ||
time: event.created_at, | ||
room: room | ||
} ); | ||
} ); | ||
|
||
stream.on( 'error', function ( error ) { | ||
console.log( error ); | ||
} ); | ||
} ); | ||
|
||
function searchTextForRaids( text ) { | ||
let result = ""; | ||
for ( let i = 0; i < raidConfigs.length; i++ ) { | ||
if ( text.indexOf( raidConfigs[ i ].english ) != -1 || text.indexOf( raidConfigs[ i ].japanese ) != -1 ) { | ||
result = raidConfigs[ i ].room; | ||
break; | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
app.set( 'json spaces', 0 ); | ||
app.use( bodyParser.json() ); | ||
app.use( bodyParser.urlencoded( { | ||
extended: true | ||
} ) ); | ||
|
||
app.use( function ( req, res, next ) { | ||
res.header( 'Access-Control-Allow-Origin', '*' ); | ||
res.header( 'Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE' ); | ||
res.header( 'Access-Control-Allow-Headers', 'Content-Type' ); | ||
next(); | ||
} ); | ||
|
||
app.get( '/getraids', function ( req, res ) { | ||
res.send( raidConfigs ); | ||
} ); | ||
|
||
app.use( st( { | ||
path: __dirname + '/static', | ||
url: '/', | ||
index: '/index.html', | ||
gzip: true, | ||
cache: { | ||
content: { | ||
max: 1024 * 1024, //1024 * 1024 * 64, // how much memory to use on caching contents (bytes * kilo * mega) | ||
maxAge: 1000 * 60 * 60 * 12 //1000 * 60 * 60 * 24 * 3, // how long to cache contents for (milliseconds * seconds * minutes * hours * days) | ||
} | ||
}, | ||
passthrough: false | ||
} ) ); | ||
|
||
io.sockets.on( 'connection', function ( socket ) { | ||
socket.on( 'subscribe', | ||
function ( data ) { | ||
socket.join( data.room ); | ||
} ); | ||
|
||
socket.on( 'unsubscribe', | ||
function ( data ) { | ||
socket.leave( data.room ); | ||
} ); | ||
|
||
} ); | ||
console.log( "Starting GBF Raiders on port " + port + "." ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "gbf-raider", | ||
"version": "1.0.0", | ||
"description": "Find Raids In GBF", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"start": "node index.js" | ||
}, | ||
"author": "gene@pinskiy.us", | ||
"license": "ISC", | ||
"dependencies": { | ||
"body-parser": "^1.17.2", | ||
"express": "^4.15.3", | ||
"semantic-ui": "^2.2.10", | ||
"socket.io": "^2.0.1", | ||
"st": "^1.2.0", | ||
"twitter": "^1.7.0", | ||
"gulp": "^3.9.1" | ||
} | ||
} |
Oops, something went wrong.