forked from SSARCandy/MSAuto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sneak_shop.js
39 lines (33 loc) · 1.11 KB
/
sneak_shop.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
'use strict';
require('console-stamp')(console, 'yyyy/mm/dd HH:MM:ss');
const request = require('request-promise');
const zlib = require('zlib');
const bl = require('bl');
const api = require('./msaapi').api;
const msaapi = require('./msaapi');
const want2buy = [
30,31,32,33,39,50,55,65,79,
83,
72
];
request(msaapi.getRequestOptions(api.sneak.shop.update, {}))
.pipe(zlib.createGunzip())
.pipe(bl(function (err, data) {
data = JSON.parse(data.toString());
console.log('--------------START------------------');
if (data.response.error_code != 0) {
console.log(`ERROR when ${api.sneak.shop.update}`);
return;
}
//console.log(data)
let {info: {contents}} = data;
//console.log(contents)
for (let i=0; i<contents.length; i++) {
if (~want2buy.indexOf(contents[i].item_id)) {
console.log(`[BUY] item_id ${contents[i].item_id}`);
request(msaapi.getRequestOptions(`${api.sneak.shop.buy}?kpi1=${contents[i].item_id}&kpi2=5`, { 'content_idx': i }))
//.pipe(zlib.createGunzip())
//.pipe(bl(function (err, data) { }));
}
}
}));