additional options for SteamCommunity constructor

This commit is contained in:
Mikhail Konovalov 2015-12-27 16:08:06 +03:00
parent 3bfe8c3713
commit 3167034b97

View File

@ -11,25 +11,35 @@ module.exports = SteamCommunity;
SteamCommunity.SteamID = SteamID;
function SteamCommunity(localAddress) {
function SteamCommunity(options) {
options = options || {};
this._jar = Request.jar();
this._captchaGid = -1;
this.chatState = SteamCommunity.ChatState.Offline;
var defaults = {
"jar": this._jar,
"timeout": 50000,
"timeout": options.timeout || 50000,
"headers": {
"User-Agent": USER_AGENT
"User-Agent": options.userAgent || USER_AGENT
}
};
if(localAddress) {
defaults.localAddress = localAddress;
if (typeof options == "string") {
options = {
localAddress: options
};
}
this._options = options;
if (options.localAddress) {
defaults.localAddress = options.localAddress;
}
this.request = Request.defaults(defaults);
this.request = options.request || Request.defaults();
this.request = this.request.defaults(defaults);
// English
this._jar.setCookie(Request.cookie('Steam_Language=english'), 'https://steamcommunity.com');