mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2025-01-21 11:52:23 +08:00
Merge pull request #55 from Mikxail/constructor-additional-options
additional options for SteamCommunity constructor
This commit is contained in:
commit
5c2666e0f4
24
index.js
24
index.js
@ -11,25 +11,35 @@ module.exports = SteamCommunity;
|
|||||||
|
|
||||||
SteamCommunity.SteamID = SteamID;
|
SteamCommunity.SteamID = SteamID;
|
||||||
|
|
||||||
function SteamCommunity(localAddress) {
|
function SteamCommunity(options) {
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
this._jar = Request.jar();
|
this._jar = Request.jar();
|
||||||
this._captchaGid = -1;
|
this._captchaGid = -1;
|
||||||
this.chatState = SteamCommunity.ChatState.Offline;
|
this.chatState = SteamCommunity.ChatState.Offline;
|
||||||
|
|
||||||
var defaults = {
|
var defaults = {
|
||||||
"jar": this._jar,
|
"jar": this._jar,
|
||||||
"timeout": 50000,
|
"timeout": options.timeout || 50000,
|
||||||
"headers": {
|
"headers": {
|
||||||
"User-Agent": USER_AGENT
|
"User-Agent": options.userAgent || USER_AGENT
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if(localAddress) {
|
if (typeof options == "string") {
|
||||||
defaults.localAddress = localAddress;
|
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
|
// English
|
||||||
this._jar.setCookie(Request.cookie('Steam_Language=english'), 'https://steamcommunity.com');
|
this._jar.setCookie(Request.cookie('Steam_Language=english'), 'https://steamcommunity.com');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user