This repository has been archived by the owner on Jun 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmite-script(old).js
54 lines (43 loc) · 2.72 KB
/
smite-script(old).js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
var fs = require('fs'),
md5 = require('MD5'),
request = require('request'),
parser = require('JSONStream'), // Remember to put .parse(what to parse) here when this is called
moment = require('moment'),
utcTime = moment().utc().format("YYYYMMDDHHmmss"),
baseUri = 'http://api.smitegame.com/smiteapi.svc/';
// Creates a Session Signature that will be used for
// every call to the API
function createSession(devId, authKey) {
var hash = md5(devId + "createsession" + authKey + utcTime)
request(baseUri + 'createsessionJson/' + devId + '/' + hash + '/' + utcTime).pipe(parser.parse('session_id')).pipe(fs.createWriteStream('session.txt'));
}
function getGods(devId, authKey, sessionId){
var hash = md5(devId + "getgods" + authKey + utcTime);
request(baseUri + "getgodsjson/" + devId + '/' + hash + '/' + sessionId + '/' + utcTime + '/' + 1).pipe(parser.parse("*")).pipe(parser.stringify()).pipe(fs.createWriteStream('gods.json'));
}
function getItems(devId, authKey, sessionId){
var hash = md5(devId + "getitems" + authKey + utcTime)
request(baseUri + "getitemsjson/" + devId + '/' + hash + '/' + sessionId + '/' + utcTime + '/' + 1).pipe(parser.parse("*")).pipe(parser.stringify()).pipe(fs.createWriteStream('items.json'));
}
function getPlayer(devId, authKey, sessionId, playerName){
var hash = md5(devId + "getplayer" + authKey + utcTime)
request(baseUri + "getplayerjson/" + devId + '/' + hash + '/' + sessionId + '/' + utcTime + '/' + playerName).pipe(parser.parse("*")).pipe(parser.stringify()).pipe(fs.createWriteStream('player.json'));
}
function getFriends(devId, authKey, sessionId, playerName){
var hash = md5(devId + "getfriends" + authKey + utcTime)
request(baseUri + "getfriendsjson/" + devId + '/' + hash + '/' + sessionId + '/' + utcTime + '/' + playerName).pipe(parser.parse("*")).pipe(parser.stringify()).pipe(fs.createWriteStream('friends.json'));
}
function getGodRank(devId, authKey, sessionId, playerName) {
var hash = md5(devId + "getgodrank" + authKey + utcTime)
request(baseUri + "getgodrankjson/" + devId + '/' + hash + '/' + sessionId + '/' + utcTime + '/' + playerName).pipe(parser.parse("*")).pipe(parser.stringify()).pipe(fs.createWriteStream('godrank.json'));
}
function getTopMatches(devId, authKey, sessionId) {
var hash = md5(devId + "gettopmatches" + authKey + utcTime);
request(baseUri + "gettopmatchesjson/" + devId + '/' + hash + '/' + sessionId + '/' + utcTime).pipe(parser.parse("*")).pipe(parser.stringify()).pipe(fs.createWriteStream('topmatches.json'));
}
exports.createSession = createSession;
exports.getItems = getItems;
exports.getGods = getGods;
exports.getPlayer = getPlayer;
exports.getFriends = getFriends;
exports.getGodRank = getGodRank;