Cleaned up imports

This commit is contained in:
Alex Corn 2019-02-14 00:29:21 -05:00
parent 103e941501
commit 0cb0d22433
13 changed files with 78 additions and 66 deletions

View File

@ -1,4 +1,4 @@
var SteamCommunity = require('../index.js');
const SteamCommunity = require('../index.js');
module.exports = CConfirmation;

View File

@ -1,5 +1,6 @@
var SteamCommunity = require('../index.js');
var Cheerio = require('cheerio');
const Cheerio = require('cheerio');
const SteamCommunity = require('../index.js');
SteamCommunity.prototype.getMarketItem = function(appid, hashName, currency, callback) {
if (typeof currency == "function") {

View File

@ -1,5 +1,6 @@
var SteamCommunity = require('../index.js');
var Cheerio = require('cheerio');
const Cheerio = require('cheerio');
const SteamCommunity = require('../index.js');
SteamCommunity.prototype.marketSearch = function(options, callback) {
var qs = {};

View File

@ -1,7 +1,8 @@
var SteamCommunity = require('../index.js');
var Helpers = require('../components/helpers.js');
var SteamID = require('steamid');
var xml2js = require('xml2js');
const SteamID = require('steamid');
const XML2JS = require('xml2js');
const Helpers = require('../components/helpers.js');
const SteamCommunity = require('../index.js');
SteamCommunity.prototype.getSteamGroup = function(id, callback) {
if(typeof id !== 'string' && !Helpers.isSteamID(id)) {
@ -19,7 +20,7 @@ SteamCommunity.prototype.getSteamGroup = function(id, callback) {
return;
}
xml2js.parseString(body, function(err, result) {
XML2JS.parseString(body, function(err, result) {
if(err) {
callback(err);
return;

View File

@ -1,7 +1,8 @@
var SteamCommunity = require('../index.js');
var Helpers = require('../components/helpers.js');
var SteamID = require('steamid');
var xml2js = require('xml2js');
const SteamID = require('steamid');
const XML2JS = require('xml2js');
const Helpers = require('../components/helpers.js');
const SteamCommunity = require('../index.js');
SteamCommunity.prototype.getSteamUser = function(id, callback) {
if(typeof id !== 'string' && !Helpers.isSteamID(id)) {
@ -19,7 +20,7 @@ SteamCommunity.prototype.getSteamUser = function(id, callback) {
return;
}
xml2js.parseString(body, function(err, result) {
XML2JS.parseString(body, function(err, result) {
if(err || (!result.response && !result.profile)) {
callback(err || new Error("No valid response"));
return;

View File

@ -1,5 +1,6 @@
var SteamCommunity = require('../index.js');
var SteamID = require('steamid');
const SteamID = require('steamid');
const SteamCommunity = require('../index.js');
SteamCommunity.ChatState = require('../resources/EChatState.js');
SteamCommunity.PersonaState = require('../resources/EPersonaState.js');
@ -9,13 +10,13 @@ SteamCommunity.prototype.chatLogon = function(interval, uiMode) {
if(this.chatState == SteamCommunity.ChatState.LoggingOn || this.chatState == SteamCommunity.ChatState.LoggedOn) {
return;
}
interval = interval || 500;
uiMode = uiMode || "web";
this.emit('debug', 'Requesting chat WebAPI token');
this.chatState = SteamCommunity.ChatState.LoggingOn;
var self = this;
this.getWebApiOauthToken(function(err, token) {
if(err) {
@ -32,7 +33,7 @@ SteamCommunity.prototype.chatLogon = function(interval, uiMode) {
self.emit('debug', "Cannot get oauth token: " + err.message);
return;
}
self.httpRequestPost({
"uri": "https://api.steampowered.com/ISteamWebUserPresenceOAuth/Logon/v1",
"form": {
@ -48,7 +49,7 @@ SteamCommunity.prototype.chatLogon = function(interval, uiMode) {
setTimeout(self.chatLogon.bind(self), 5000);
return;
}
if(body.error != 'OK') {
self.chatState = SteamCommunity.ChatState.LogOnFailed;
self.emit('chatLogOnFailed', new Error(body.error), false);
@ -56,7 +57,7 @@ SteamCommunity.prototype.chatLogon = function(interval, uiMode) {
setTimeout(self.chatLogon.bind(self), 5000);
return;
}
self._chat = {
"umqid": body.umqid,
"message": body.message,
@ -64,9 +65,9 @@ SteamCommunity.prototype.chatLogon = function(interval, uiMode) {
"interval": interval,
"uiMode": uiMode
};
self.chatFriends = {};
self.chatState = SteamCommunity.ChatState.LoggedOn;
self.emit('chatLoggedOn');
self._chatPoll();
@ -78,16 +79,16 @@ SteamCommunity.prototype.chatMessage = function(recipient, text, type, callback)
if(this.chatState != SteamCommunity.ChatState.LoggedOn) {
throw new Error("Chat must be logged on before messages can be sent");
}
if(typeof recipient === 'string') {
recipient = new SteamID(recipient);
}
if(typeof type === 'function') {
callback = type;
type = 'saytext';
}
type = type || 'saytext';
var self = this;
@ -105,12 +106,12 @@ SteamCommunity.prototype.chatMessage = function(recipient, text, type, callback)
if(!callback) {
return;
}
if (err) {
callback(err);
return;
}
if(body.error != 'OK') {
callback(new Error(body.error));
} else {
@ -143,7 +144,7 @@ SteamCommunity.prototype.chatLogoff = function() {
SteamCommunity.prototype._chatPoll = function() {
this.emit('debug', 'Doing chat poll');
var self = this;
this.httpRequestPost({
"uri": "https://api.steampowered.com/ISteamWebUserPresenceOAuth/Poll/v1",
@ -161,9 +162,9 @@ SteamCommunity.prototype._chatPoll = function() {
if (self.chatState == SteamCommunity.ChatState.Offline) {
return;
}
self._chat.timer = setTimeout(self._chatPoll.bind(self), self._chat.interval);
if(err || response.statusCode != 200) {
self.emit('debug', 'Error in chat poll: ' + (err ? err.message : "HTTP error " + response.statusCode));
if (err.message == "Not Logged On") {
@ -172,7 +173,7 @@ SteamCommunity.prototype._chatPoll = function() {
return;
}
if(!body || body.error != 'OK') {
self.emit('debug', 'Error in chat poll: ' + (body && body.error ? body.error : "Malformed response"));
if (body && body.error && body.error == "Not Logged On") {
@ -181,29 +182,29 @@ SteamCommunity.prototype._chatPoll = function() {
return;
}
self._chat.message = body.messagelast;
(body.messages || []).forEach(function(message) {
var sender = new SteamID();
sender.universe = SteamID.Universe.PUBLIC;
sender.type = SteamID.Type.INDIVIDUAL;
sender.instance = SteamID.Instance.DESKTOP;
sender.accountid = message.accountid_from;
switch(message.type) {
case 'personastate':
self._chatUpdatePersona(sender);
break;
case 'saytext':
self.emit('chatMessage', sender, message.text);
break;
case 'typing':
self.emit('chatTyping', sender);
break;
default:
self.emit('debug', 'Unhandled chat message type: ' + message.type);
}
@ -240,7 +241,7 @@ SteamCommunity.prototype._chatUpdatePersona = function(steamID) {
}, 2000);
return;
}
var persona = {
"steamID": steamID,
"personaName": body.m_strName,
@ -255,4 +256,4 @@ SteamCommunity.prototype._chatUpdatePersona = function(steamID) {
self.emit('chatPersonaState', steamID, persona);
self.chatFriends[steamID.getSteamID64()] = persona;
}, "steamcommunity");
};
};

View File

@ -1,8 +1,9 @@
var SteamCommunity = require('../index.js');
var Cheerio = require('cheerio');
var SteamTotp = require('steam-totp');
const Cheerio = require('cheerio');
const SteamTotp = require('steam-totp');
var CConfirmation = require('../classes/CConfirmation.js');
const SteamCommunity = require('../index.js');
const CConfirmation = require('../classes/CConfirmation.js');
/**
* Get a list of your account's currently outstanding confirmations.

View File

@ -1,9 +1,11 @@
var SteamCommunity = require('../index.js');
var SteamID = require('steamid');
var xml2js = require('xml2js');
var Cheerio = require('cheerio');
var Helpers = require('./helpers.js');
var EResult = SteamCommunity.EResult;
const Cheerio = require('cheerio');
const SteamID = require('steamid');
const XML2JS = require('xml2js');
const Helpers = require('./helpers.js');
const SteamCommunity = require('../index.js');
const EResult = SteamCommunity.EResult;
SteamCommunity.prototype.getGroupMembers = function(gid, callback, members, link, addresses, addressIdx) {
members = members || [];
@ -46,7 +48,7 @@ SteamCommunity.prototype.getGroupMembers = function(gid, callback, members, link
return;
}
xml2js.parseString(body, function(err, result) {
XML2JS.parseString(body, function(err, result) {
if (err) {
callback(err);
return;
@ -129,7 +131,7 @@ SteamCommunity.prototype.getAllGroupAnnouncements = function(gid, time, callback
return;
}
xml2js.parseString(body, function(err, results) {
XML2JS.parseString(body, function(err, results) {
if(err) {
return callback(err);
}
@ -398,7 +400,7 @@ SteamCommunity.prototype.setGroupPlayerOfTheWeek = function(gid, steamID, callba
return;
}
xml2js.parseString(body, function(err, results) {
XML2JS.parseString(body, function(err, results) {
if(err) {
callback(err);
return;
@ -634,7 +636,7 @@ SteamCommunity.prototype.respondToGroupJoinRequests = function(gid, steamIDs, ap
if (typeof gid === 'string') {
gid = new SteamID(gid);
}
var rgAccounts = (!Array.isArray(steamIDs) ? [steamIDs] : steamIDs).map(sid => sid.toString());
this.httpRequestPost({

View File

@ -1,4 +1,4 @@
var SteamCommunity = require('../index.js');
const SteamCommunity = require('../index.js');
SteamCommunity.prototype.httpRequest = function(uri, options, callback, source) {
if (typeof uri === 'object') {

View File

@ -1,5 +1,6 @@
var SteamCommunity = require('../index.js');
var Cheerio = require('cheerio');
const Cheerio = require('cheerio');
const SteamCommunity = require('../index.js');
/**
* Get a list of all apps on the market

View File

@ -1,7 +1,8 @@
var SteamTotp = require('steam-totp');
var SteamCommunity = require('../index.js');
const SteamTotp = require('steam-totp');
var ETwoFactorTokenType = {
const SteamCommunity = require('../index.js');
const ETwoFactorTokenType = {
"None": 0, // No token-based two-factor authentication
"ValveMobileApp": 1, // Tokens generated using Valve's special charset (5 digits, alphanumeric)
"ThirdParty": 2 // Tokens generated using literally everyone else's standard charset (6 digits, numeric). This is disabled.

View File

@ -1,4 +1,4 @@
var SteamCommunity = require('../index.js');
const SteamCommunity = require('../index.js');
SteamCommunity.prototype.getWebApiKey = function(domain, callback) {
var self = this;
@ -14,7 +14,7 @@ SteamCommunity.prototype.getWebApiKey = function(domain, callback) {
if(body.match(/<h2>Access Denied<\/h2>/)) {
return callback(new Error("Access Denied"));
}
if(body.match(/You must have a validated email address to create a Steam Web API key./)) {
return callback(new Error("You must have a validated email address to create a Steam Web API key."));
}

View File

@ -1,19 +1,21 @@
require('@doctormckay/stats-reporter').setup(require('./package.json'));
const EventEmitter = require('events').EventEmitter;
const hex2b64 = require('node-bignumber').hex2b64;
const Request = require('request');
const RSA = require('node-bignumber').Key;
const SteamID = require('steamid');
const Util = require('util');
const USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36";
require('util').inherits(SteamCommunity, require('events').EventEmitter);
Util.inherits(SteamCommunity, EventEmitter);
module.exports = SteamCommunity;
SteamCommunity.SteamID = SteamID;
SteamCommunity.ConfirmationType = require('./resources/EConfirmationType.js');
SteamCommunity.EResult = require('./resources/EResult.js')
SteamCommunity.EResult = require('./resources/EResult.js');
function SteamCommunity(options) {