This repository has been archived by the owner on Jul 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 69
/
inventory.js
51 lines (43 loc) · 1.61 KB
/
inventory.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
'use strict';
/*
This example script shows how to work with the getInventory() API call and the
splitInventory() function.
*/
const pogobuf = require('pogobuf'),
POGOProtos = require('node-pogo-protos');
// Note: To avoid getting softbanned, change these coordinates to something close to where you
// last used your account
const lat = 37.7876146,
lng = -122.3884353;
let client;
// Login to Google and get a login token
new pogobuf.GoogleLogin().login('your-username@gmail.com', 'your-google-password')
.then(token => {
// Initialize the client
client = new pogobuf.Client({
authType: 'google',
authToken: token
});
client.setPosition(lat, lng);
// Uncomment the following if you want to see request/response information on the console
// client.on('request', console.dir);
// client.on('response', console.dir);
// Perform the initial request
return client.init();
})
.then(() => {
// Get full inventory
return client.getInventory(0);
})
.then(inventory => {
if (!inventory.success) throw Error('success=false in inventory response');
// Split inventory into individual arrays and log them on the console
inventory = pogobuf.Utils.splitInventory(inventory);
console.log('Full inventory:', inventory);
console.log('Items:');
inventory.items.forEach(item => {
console.log(item.count + 'x ' +
pogobuf.Utils.getEnumKeyByValue(POGOProtos.Inventory.Item.ItemId, item.item_id));
});
})
.catch(console.error);