mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2026-08-31 03:47:59 +08:00
Compare commits
372 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b5cd59021 | ||
|
|
25adcb101b | ||
|
|
d7ecad670d | ||
|
|
8225ea5127 | ||
|
|
59bf4f1e92 | ||
|
|
a3468bf99b | ||
|
|
e299623452 | ||
|
|
29b31009ce | ||
|
|
d4d0d7da26 | ||
|
|
3c8488d441 | ||
|
|
3ea0995415 | ||
|
|
21c4ba3e27 | ||
|
|
4d4df7c2a5 | ||
|
|
aa0d4d32b7 | ||
|
|
444a6d238d | ||
|
|
98373708e5 | ||
|
|
0df2662053 | ||
|
|
a46ed17415 | ||
|
|
fbfff1398b | ||
|
|
224b7b85e0 | ||
|
|
22d34b1faf | ||
|
|
cfd932dc72 | ||
|
|
4710afa28b | ||
|
|
1180eb9d3f | ||
|
|
3ca85bedc2 | ||
|
|
e05efabcb9 | ||
|
|
6cd06c3adf | ||
|
|
d35e3c107c | ||
|
|
4e90811008 | ||
|
|
018d3de5a2 | ||
|
|
3949abe09f | ||
|
|
62394b9ffe | ||
|
|
ebac6c97ad | ||
|
|
a0ad33d5eb | ||
|
|
b7a3e51bfc | ||
|
|
bf13224cbf | ||
|
|
117374a4c5 | ||
|
|
aa84505132 | ||
|
|
bb97565f2a | ||
|
|
7462e4b767 | ||
|
|
adbf1d47a7 | ||
|
|
8c4fde720a | ||
|
|
458d7b6db1 | ||
|
|
411d74036f | ||
|
|
1b3117b8dc | ||
|
|
6eec88d196 | ||
|
|
3921ce17d0 | ||
|
|
4441d6f6e0 | ||
|
|
870de6817e | ||
|
|
d5dbb230df | ||
|
|
5e9c06bdc4 | ||
|
|
8d163d0d85 | ||
|
|
051d376508 | ||
|
|
913dff68ef | ||
|
|
754847ee88 | ||
|
|
645e03b89c | ||
|
|
aa302bc09e | ||
|
|
1c0f8d4bca | ||
|
|
a7bd694f4b | ||
|
|
9e380e71f5 | ||
|
|
e97e63fe6d | ||
|
|
f6c7c74ab6 | ||
|
|
8846082f60 | ||
|
|
eb609b5c42 | ||
|
|
238a36de0f | ||
|
|
c38111b61a | ||
|
|
0eb27a15d2 | ||
|
|
0ab3a94493 | ||
|
|
7c2ec65b8c | ||
|
|
8e761ffe6c | ||
|
|
06f04887fd | ||
|
|
e5f986a8bf | ||
|
|
5da6e40ebb | ||
|
|
0b8dd57a40 | ||
|
|
6f8456882a | ||
|
|
0b57b47ecb | ||
|
|
b5f50a6614 | ||
|
|
4257140c15 | ||
|
|
724badd175 | ||
|
|
a9455b0ff6 | ||
|
|
b3dfdd47d8 | ||
|
|
1efac6bc70 | ||
|
|
eacb85c711 | ||
|
|
8eab34bf18 | ||
|
|
b45e8d97ed | ||
|
|
6abb14a9bc | ||
|
|
6049d7a259 | ||
|
|
e0320b27d7 | ||
|
|
7986a87b3f | ||
|
|
cf7e5f8995 | ||
|
|
a03dad9507 | ||
|
|
7da7ecfc56 | ||
|
|
6bf3f26f2f | ||
|
|
dc2e5d09a7 | ||
|
|
d716e8a494 | ||
|
|
458a179852 | ||
|
|
f5d76527ba | ||
|
|
5875f47ebc | ||
|
|
d7095aa7c5 | ||
|
|
03e0a1bdac | ||
|
|
a51973c9b9 | ||
|
|
96d87ee8e6 | ||
|
|
7beef548dc | ||
|
|
6d9ebabb17 | ||
|
|
5d5d8548af | ||
|
|
b5142ad0cc | ||
|
|
3045a5d0cc | ||
|
|
2dcb123761 | ||
|
|
bd29d598b1 | ||
|
|
7e39715427 | ||
|
|
a97edfd492 | ||
|
|
68b1f21655 | ||
|
|
b4772baf39 | ||
|
|
47dc22ca0d | ||
|
|
3bba7025d4 | ||
|
|
e2f94cb1e7 | ||
|
|
acbd71666b | ||
|
|
3c35026a32 | ||
|
|
aca375d9da | ||
|
|
91285ba1c7 | ||
|
|
758b749487 | ||
|
|
a9b16cef1e | ||
|
|
c6ab392c37 | ||
|
|
4542793175 | ||
|
|
d18a0244ec | ||
|
|
b1c772d9b9 | ||
|
|
530bbcb9eb | ||
|
|
f7ebe68bd8 | ||
|
|
e2dae00af2 | ||
|
|
bbd80d4154 | ||
|
|
c180557f52 | ||
|
|
b3174b9f0b | ||
|
|
12f1ddf6a0 | ||
|
|
db3aa4ace8 | ||
|
|
f1b742dff4 | ||
|
|
444649ee8c | ||
|
|
b9ec1ccfb5 | ||
|
|
0c7c030f78 | ||
|
|
e5f1f14aad | ||
|
|
0f72ea7d93 | ||
|
|
d1906a2c83 | ||
|
|
3964af7ade | ||
|
|
5a5c5373aa | ||
|
|
ec60e1b73e | ||
|
|
a22a75d4e1 | ||
|
|
313753bb05 | ||
|
|
459fe4d8b1 | ||
|
|
489c0441a5 | ||
|
|
d91e74d02a | ||
|
|
d120d09970 | ||
|
|
84ce979a78 | ||
|
|
88b0495386 | ||
|
|
d367e8eae4 | ||
|
|
9a3cf927c0 | ||
|
|
56cdfff672 | ||
|
|
35e6dd16e7 | ||
|
|
d0af8584c1 | ||
|
|
f1afcd1962 | ||
|
|
513b0bff1c | ||
|
|
ab037b1931 | ||
|
|
06df0ecd42 | ||
|
|
b789e13a70 | ||
|
|
95a36b00c1 | ||
|
|
41c87501c4 | ||
|
|
4f3ddcc787 | ||
|
|
d10fa9983d | ||
|
|
666226731e | ||
|
|
d096f47cac | ||
|
|
a8eedb3067 | ||
|
|
ed12a54e81 | ||
|
|
eb341314ef | ||
|
|
33cd9474ab | ||
|
|
e8a43734be | ||
|
|
8a27147f5c | ||
|
|
d00d07f828 | ||
|
|
471c11d406 | ||
|
|
dd3a9254aa | ||
|
|
71a3893636 | ||
|
|
5928c3b76a | ||
|
|
1b60712b8b | ||
|
|
335a955abd | ||
|
|
6d534df8ba | ||
|
|
9022a9a45e | ||
|
|
ce4d7ae026 | ||
|
|
b863377c87 | ||
|
|
20785ee92b | ||
|
|
3afb393f58 | ||
|
|
79543187f0 | ||
|
|
3139aec463 | ||
|
|
bb917af86e | ||
|
|
17f51b9caa | ||
|
|
dd638df118 | ||
|
|
b937a05442 | ||
|
|
9c34d18cd9 | ||
|
|
02e3798124 | ||
|
|
5d9922cc33 | ||
|
|
153011e1c9 | ||
|
|
575c196cb7 | ||
|
|
47a24d19cf | ||
|
|
0eac19b71c | ||
|
|
ca73ecc786 | ||
|
|
e8733613d7 | ||
|
|
89a1df67ec | ||
|
|
3ba0a8592e | ||
|
|
57fa7a679f | ||
|
|
446e315183 | ||
|
|
c6a9b74471 | ||
|
|
018e18cb5d | ||
|
|
303ce10e73 | ||
|
|
60e0e63a92 | ||
|
|
17e5b94782 | ||
|
|
beaf012846 | ||
|
|
38c20a342c | ||
|
|
a406cfbfe2 | ||
|
|
c970eee9d3 | ||
|
|
38e3eefb33 | ||
|
|
a2e26459d9 | ||
|
|
c1b04ee743 | ||
|
|
542eb8d47e | ||
|
|
9081528f72 | ||
|
|
8be8e395b6 | ||
|
|
4b7ea80fcf | ||
|
|
7f945afbca | ||
|
|
3b241ba24f | ||
|
|
fddd74cf24 | ||
|
|
9a3138aa35 | ||
|
|
839d8b51e3 | ||
|
|
ddf0221489 | ||
|
|
64aaca66be | ||
|
|
aac26212d7 | ||
|
|
d8d99a804f | ||
|
|
f47afae1ea | ||
|
|
8d90aac203 | ||
|
|
f1bfd8b3af | ||
|
|
579fc04c1c | ||
|
|
58927dc937 | ||
|
|
018cacac59 | ||
|
|
26effb27fe | ||
|
|
5880e922ab | ||
|
|
fe007811a5 | ||
|
|
7b882c8439 | ||
|
|
6c4cb9e62f | ||
|
|
2300081d43 | ||
|
|
0f20f918be | ||
|
|
b761b8108b | ||
|
|
46e16cc0b6 | ||
|
|
237d3786a2 | ||
|
|
1884ceb7d9 | ||
|
|
893c4df06b | ||
|
|
593ed6b9ef | ||
|
|
840e9548ed | ||
|
|
dee6b7964b | ||
|
|
2fc434d475 | ||
|
|
42ebbda00d | ||
|
|
eed791acbd | ||
|
|
54b83016af | ||
|
|
1032b1f832 | ||
|
|
fce2560abe | ||
|
|
0069bb36ef | ||
|
|
1028c4193f | ||
|
|
991b11e0f4 | ||
|
|
72c01468da | ||
|
|
eecd682033 | ||
|
|
574a3127cb | ||
|
|
55027f7b1f | ||
|
|
70ffc5559d | ||
|
|
f4be134f71 | ||
|
|
7792969cae | ||
|
|
57a3532860 | ||
|
|
facf335f0e | ||
|
|
1c3817b797 | ||
|
|
74efd50f72 | ||
|
|
87e3665b01 | ||
|
|
0b94419de4 | ||
|
|
defbd347cc | ||
|
|
7efc1f2fd0 | ||
|
|
05c2da89da | ||
|
|
b83c40419c | ||
|
|
fb0097499d | ||
|
|
c2983e3bcd | ||
|
|
80b3cc52d2 | ||
|
|
fa59b188a5 | ||
|
|
e446cc3cd8 | ||
|
|
722ca6689b | ||
|
|
1276c71e4e | ||
|
|
a51bd21153 | ||
|
|
f1bbfc4901 | ||
|
|
eb8d094bf1 | ||
|
|
b1cca95ec0 | ||
|
|
27ef78cc4b | ||
|
|
4223d88fd1 | ||
|
|
ac02f6cb49 | ||
|
|
d84601e256 | ||
|
|
4152865f5e | ||
|
|
7627e6a3a0 | ||
|
|
bbcf0eb72f | ||
|
|
d51b6582e2 | ||
|
|
bbd339b88b | ||
|
|
fcaaa38085 | ||
|
|
26f27e2698 | ||
|
|
6d8d0c5fbb | ||
|
|
08c9ab6809 | ||
|
|
c150425ee5 | ||
|
|
eae78aab93 | ||
|
|
5c2666e0f4 | ||
|
|
c64b6c7e99 | ||
|
|
318f9ab2b4 | ||
|
|
5c2894a7d4 | ||
|
|
3167034b97 | ||
|
|
3bfe8c3713 | ||
|
|
0c4e026701 | ||
|
|
c246011fe2 | ||
|
|
c290e16dc5 | ||
|
|
f8852ba6c4 | ||
|
|
52ee65d9da | ||
|
|
42e04b123a | ||
|
|
1f69d1fc04 | ||
|
|
e4b5e763eb | ||
|
|
6feb607366 | ||
|
|
cc64d9883a | ||
|
|
d4a92b4dea | ||
|
|
e2849719c1 | ||
|
|
c9541d093c | ||
|
|
339d5dc1e4 | ||
|
|
2a7a03d35e | ||
|
|
ff1c3279c8 | ||
|
|
9175a44828 | ||
|
|
deeeb633cf | ||
|
|
a50bd35a54 | ||
|
|
5bf51a2e3e | ||
|
|
448b32b9c6 | ||
|
|
01428e6007 | ||
|
|
43d1147fd7 | ||
|
|
479cc47bf5 | ||
|
|
01217a3659 | ||
|
|
0e34bceb1f | ||
|
|
c4ea8eeb41 | ||
|
|
0f83fe8c64 | ||
|
|
5624611421 | ||
|
|
49d2bb4252 | ||
|
|
b54ccff7c8 | ||
|
|
b82f7ca045 | ||
|
|
2526539266 | ||
|
|
fc75036974 | ||
|
|
ee1e819812 | ||
|
|
fceea0737d | ||
|
|
f3ac556922 | ||
|
|
2e02c14455 | ||
|
|
8f580fc231 | ||
|
|
6f596b5b16 | ||
|
|
1249e28d83 | ||
|
|
85bcaa70be | ||
|
|
2a5419513c | ||
|
|
deec5c52a4 | ||
|
|
2399a5b783 | ||
|
|
efea8c6265 | ||
|
|
2be414b20c | ||
|
|
25ebb4c5a3 | ||
|
|
ac87fd3a40 | ||
|
|
c67e2e04f1 | ||
|
|
83eeb0f190 | ||
|
|
e09cf24fbf | ||
|
|
9d2b5ade67 | ||
|
|
be4e5c9449 | ||
|
|
5926197f23 | ||
|
|
2d86f81142 | ||
|
|
f37bff4a57 | ||
|
|
c700b7663b | ||
|
|
c26e548c64 | ||
|
|
658d8fb708 | ||
|
|
cd68841d1d | ||
|
|
5853968661 |
13
.editorconfig
Normal file
13
.editorconfig
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 4
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
insert_final_newline = false
|
||||||
|
trim_trailing_whitespace = false
|
||||||
52
.gitignore
vendored
52
.gitignore
vendored
@@ -1,3 +1,53 @@
|
|||||||
node_modules/*
|
node_modules/*
|
||||||
test.js
|
test.js
|
||||||
.idea/
|
|
||||||
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
||||||
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
|
|
||||||
|
# User-specific stuff:
|
||||||
|
.idea/**/workspace.xml
|
||||||
|
.idea/**/tasks.xml
|
||||||
|
.idea/dictionaries
|
||||||
|
.idea/httpRequests/
|
||||||
|
|
||||||
|
# Sensitive or high-churn files:
|
||||||
|
.idea/**/dataSources/
|
||||||
|
.idea/**/dataSources.ids
|
||||||
|
.idea/**/dataSources.local.xml
|
||||||
|
.idea/**/sqlDataSources.xml
|
||||||
|
.idea/**/dynamic.xml
|
||||||
|
.idea/**/uiDesigner.xml
|
||||||
|
|
||||||
|
# Gradle:
|
||||||
|
.idea/**/gradle.xml
|
||||||
|
.idea/**/libraries
|
||||||
|
|
||||||
|
# CMake
|
||||||
|
cmake-build-debug/
|
||||||
|
cmake-build-release/
|
||||||
|
|
||||||
|
# Mongo Explorer plugin:
|
||||||
|
.idea/**/mongoSettings.xml
|
||||||
|
|
||||||
|
## File-based project format:
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
## Plugin-specific files:
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
out/
|
||||||
|
|
||||||
|
# mpeltonen/sbt-idea plugin
|
||||||
|
.idea_modules/
|
||||||
|
|
||||||
|
# JIRA plugin
|
||||||
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
|
# Cursive Clojure plugin
|
||||||
|
.idea/replstate.xml
|
||||||
|
|
||||||
|
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||||
|
com_crashlytics_export_strings.xml
|
||||||
|
crashlytics.properties
|
||||||
|
crashlytics-build.properties
|
||||||
|
fabric.properties
|
||||||
|
|||||||
1
.idea/.name
generated
Normal file
1
.idea/.name
generated
Normal file
@@ -0,0 +1 @@
|
|||||||
|
node-steamcommunity
|
||||||
13
.idea/codeStyleSettings.xml
generated
Normal file
13
.idea/codeStyleSettings.xml
generated
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectCodeStyleSettingsManager">
|
||||||
|
<option name="PER_PROJECT_SETTINGS">
|
||||||
|
<value>
|
||||||
|
<XML>
|
||||||
|
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
|
||||||
|
</XML>
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default (1)" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
18
.idea/codeStyles/Project.xml
generated
Normal file
18
.idea/codeStyles/Project.xml
generated
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<code_scheme name="Project" version="173">
|
||||||
|
<XML>
|
||||||
|
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
|
||||||
|
</XML>
|
||||||
|
<codeStyleSettings language="JSON">
|
||||||
|
<indentOptions>
|
||||||
|
<option name="USE_TAB_CHARACTER" value="true" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="JavaScript">
|
||||||
|
<indentOptions>
|
||||||
|
<option name="USE_TAB_CHARACTER" value="true" />
|
||||||
|
<option name="SMART_TABS" value="true" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
</code_scheme>
|
||||||
|
</component>
|
||||||
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<state>
|
||||||
|
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default (1)" />
|
||||||
|
</state>
|
||||||
|
</component>
|
||||||
3
.idea/copyright/profiles_settings.xml
generated
Normal file
3
.idea/copyright/profiles_settings.xml
generated
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<component name="CopyrightManager">
|
||||||
|
<settings default="" />
|
||||||
|
</component>
|
||||||
6
.idea/encodings.xml
generated
Normal file
6
.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding">
|
||||||
|
<file url="PROJECT" charset="UTF-8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
11
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
11
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="ES6ConvertRequireIntoImport" enabled="false" level="INFORMATION" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="ES6ConvertToForOf" enabled="false" level="INFORMATION" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="ES6ConvertVarToLetConst" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="JSEqualityComparisonWithCoercion" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="JSFunctionExpressionToArrowFunction" enabled="false" level="INFORMATION" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="JSStringConcatenationToES6Template" enabled="false" level="INFORMATION" enabled_by_default="false" />
|
||||||
|
</profile>
|
||||||
|
</component>
|
||||||
6
.idea/jsLibraryMappings.xml
generated
Normal file
6
.idea/jsLibraryMappings.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="JavaScriptLibraryMappings">
|
||||||
|
<includedPredefinedLibrary name="Node.js Core" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/misc.xml
generated
Normal file
6
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="JavaScriptSettings">
|
||||||
|
<option name="languageLevel" value="ES6" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/steamcommunity.iml" filepath="$PROJECT_DIR$/.idea/steamcommunity.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
8
.idea/node-steamcommunity.iml
generated
Normal file
8
.idea/node-steamcommunity.iml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="WEB_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
9
.idea/steamcommunity.iml
generated
Normal file
9
.idea/steamcommunity.iml
generated
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="WEB_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
4
.idea/watcherTasks.xml
generated
Normal file
4
.idea/watcherTasks.xml
generated
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectTasksOptions" suppressed-tasks="Babel" />
|
||||||
|
</project>
|
||||||
36
CONTRIBUTING.md
Normal file
36
CONTRIBUTING.md
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# Contributing to SteamCommunity
|
||||||
|
|
||||||
|
Thanks for your interest in making `SteamCommunity` better! I'd appreciate it if you read over this document quickly
|
||||||
|
before you submit your issue or pull request. It'll make things go much smoother.
|
||||||
|
|
||||||
|
# Issues
|
||||||
|
|
||||||
|
Submitting an issue?
|
||||||
|
|
||||||
|
- If you're **reporting a bug**, please include all relevant details.
|
||||||
|
- A descriptive title helps for one. Titles of just "Error" or "It doesn't work" really don't help.
|
||||||
|
- Please describe what you're trying to do, what actually happens, and what you can do to reproduce the problem.
|
||||||
|
- If you have an error message or a crash, please include the full text of the error message and the stack trace.
|
||||||
|
- Include the relevant snippet of your code. Wrap it in \`\`\`js /* code */ \`\`\` and GitHub [will format it nicely for you](https://help.github.com/articles/github-flavored-markdown/#syntax-highlighting).
|
||||||
|
- If you're **requesting a feature**, please be descriptive and understanding.
|
||||||
|
- A good title makes a difference. Please briefly describe what you're requesting in the title.
|
||||||
|
- Be descriptive in the issue body, too. Say what you want to do, and ideally what the method should be named.
|
||||||
|
- Be understanding if I don't think that your feature request falls within the scope of this module.
|
||||||
|
- If you're **asking a question** or **requesting support**, please don't submit a GitHub issue.
|
||||||
|
- Issues are only for problems directly relating to the module's code.
|
||||||
|
- Please [post a thread in the dedicated forum](https://dev.doctormckay.com/forum/8-node-steamcommunity/) instead.
|
||||||
|
|
||||||
|
# Pull Requests
|
||||||
|
|
||||||
|
Submitting a pull request? Great! Thanks for contributing your time and code! Please keep the following in mind.
|
||||||
|
|
||||||
|
- Please follow the existing code style.
|
||||||
|
- Tabs for indentation
|
||||||
|
- camelCase for variables and functions
|
||||||
|
- Opening braces on the same line as the if/for/while statement
|
||||||
|
- No omitting unnecessary braces
|
||||||
|
- etc.
|
||||||
|
- Please avoid breaking changes. If you make a breaking change that can be done in a backwards-compatible manner, I won't accept it.
|
||||||
|
- Please don't increment the version number in `package.json`. I'll do that myself when I publish it to npm.
|
||||||
|
- Please include a brief description of your change in the pull request if it's not immediately apparent from the code.
|
||||||
|
- Be understanding if I don't think that your change falls within the scope of this module.
|
||||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2015 Alexander Corn
|
Copyright (c) 2015 Alex Corn
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
15
README.md
15
README.md
@@ -9,12 +9,15 @@ This module provides an easy interface for the Steam Community website. This mod
|
|||||||
|
|
||||||
It supports Steam Guard and CAPTCHAs.
|
It supports Steam Guard and CAPTCHAs.
|
||||||
|
|
||||||
# Installation
|
**Have a question about the module or coding in general? *Do not create a GitHub issue.* GitHub issues are for feature
|
||||||
|
requests and bug reports. Instead, post in the [dedicated forum](https://dev.doctormckay.com/forum/8-node-steamcommunity/).
|
||||||
Install it from npm:
|
Such issues may be ignored!**
|
||||||
|
|
||||||
$ npm install steamcommunity
|
|
||||||
|
|
||||||
# Documentation
|
# Documentation
|
||||||
|
|
||||||
As of version 1.0.0, documentation is on the [GitHub wiki](https://github.com/DoctorMcKay/node-steamcommunity/wiki).
|
Documentation is available on the [GitHub wiki](https://github.com/DoctorMcKay/node-steamcommunity/wiki).
|
||||||
|
|
||||||
|
# Support
|
||||||
|
|
||||||
|
Report bugs on the [issue tracker](https://github.com/DoctorMcKay/node-steamcommunity/issues) or ask questions
|
||||||
|
on the [dedicated forum](https://dev.doctormckay.com/forum/8-node-steamcommunity/).
|
||||||
|
|||||||
35
classes/CConfirmation.js
Normal file
35
classes/CConfirmation.js
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
var SteamCommunity = require('../index.js');
|
||||||
|
|
||||||
|
module.exports = CConfirmation;
|
||||||
|
|
||||||
|
function CConfirmation(community, data) {
|
||||||
|
Object.defineProperty(this, "_community", {"value": community});
|
||||||
|
|
||||||
|
this.id = data.id.toString();
|
||||||
|
this.type = data.type;
|
||||||
|
this.creator = data.creator.toString();
|
||||||
|
this.key = data.key;
|
||||||
|
this.title = data.title;
|
||||||
|
this.receiving = data.receiving;
|
||||||
|
this.time = data.time;
|
||||||
|
this.icon = data.icon;
|
||||||
|
this.offerID = this.type == SteamCommunity.ConfirmationType.Trade ? this.creator : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
CConfirmation.prototype.getOfferID = function(time, key, callback) {
|
||||||
|
if (this.type && this.creator) {
|
||||||
|
if (this.type != SteamCommunity.ConfirmationType.Trade) {
|
||||||
|
callback(new Error("Not a trade confirmation"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(null, this.creator);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._community.getConfirmationOfferID(this.id, time, key, callback);
|
||||||
|
};
|
||||||
|
|
||||||
|
CConfirmation.prototype.respond = function(time, key, accept, callback) {
|
||||||
|
this._community.respondToConfirmation(this.id, this.key, time, key, accept, callback);
|
||||||
|
};
|
||||||
@@ -1,35 +1,92 @@
|
|||||||
module.exports = CEconItem;
|
module.exports = CEconItem;
|
||||||
|
|
||||||
function CEconItem(item, descriptions, contextID) {
|
function CEconItem(item, description, contextID) {
|
||||||
var thing;
|
var thing;
|
||||||
for(thing in item) {
|
for (thing in item) {
|
||||||
if(item.hasOwnProperty(thing)) {
|
if (item.hasOwnProperty(thing)) {
|
||||||
this[thing] = item[thing];
|
this[thing] = item[thing];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.assetid = this.id = (this.id || this.assetid);
|
var isCurrency = !!(this.is_currency || this.currency) || typeof this.currencyid !== 'undefined'; // I don't want to put this on the object yet; it's nice to have the ids at the top of printed output
|
||||||
|
|
||||||
|
if (isCurrency) {
|
||||||
|
this.currencyid = this.id = (this.id || this.currencyid);
|
||||||
|
} else {
|
||||||
|
this.assetid = this.id = (this.id || this.assetid);
|
||||||
|
}
|
||||||
|
|
||||||
this.instanceid = this.instanceid || '0';
|
this.instanceid = this.instanceid || '0';
|
||||||
this.amount = parseInt(this.amount, 10);
|
this.amount = parseInt(this.amount, 10);
|
||||||
this.contextid = this.contextid || contextID.toString();
|
this.contextid = this.contextid || contextID.toString();
|
||||||
|
|
||||||
// Merge the description
|
// Merge the description
|
||||||
if(descriptions) {
|
if (description) {
|
||||||
var description = descriptions[this.classid + '_' + this.instanceid];
|
// Is this a listing of descriptions?
|
||||||
if(description) {
|
if (description[this.classid + '_' + this.instanceid]) {
|
||||||
for(thing in description) {
|
description = description[this.classid + '_' + this.instanceid];
|
||||||
if(description.hasOwnProperty(thing)) {
|
}
|
||||||
this[thing] = description[thing];
|
|
||||||
}
|
for (thing in description) {
|
||||||
|
if (description.hasOwnProperty(thing)) {
|
||||||
|
this[thing] = description[thing];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.is_currency = isCurrency;
|
||||||
this.tradable = !!this.tradable;
|
this.tradable = !!this.tradable;
|
||||||
this.marketable = !!this.marketable;
|
this.marketable = !!this.marketable;
|
||||||
this.commodity = !!this.commodity;
|
this.commodity = !!this.commodity;
|
||||||
this.market_tradable_restriction = (this.market_tradable_restriction ? parseInt(this.market_tradable_restriction, 10) : 0);
|
this.market_tradable_restriction = (this.market_tradable_restriction ? parseInt(this.market_tradable_restriction, 10) : 0);
|
||||||
this.market_marketable_restriction = (this.market_marketable_restriction ? parseInt(this.market_marketable_restriction, 10) : 0);
|
this.market_marketable_restriction = (this.market_marketable_restriction ? parseInt(this.market_marketable_restriction, 10) : 0);
|
||||||
|
this.fraudwarnings = this.fraudwarnings || [];
|
||||||
|
this.descriptions = this.descriptions || [];
|
||||||
|
|
||||||
|
if (this.owner && JSON.stringify(this.owner) == '{}') {
|
||||||
|
this.owner = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restore old property names of tags
|
||||||
|
if (this.tags) {
|
||||||
|
this.tags = this.tags.map(function(tag) {
|
||||||
|
return {
|
||||||
|
"internal_name": tag.internal_name,
|
||||||
|
"name": tag.localized_tag_name || tag.name,
|
||||||
|
"category": tag.category,
|
||||||
|
"color": tag.color || "",
|
||||||
|
"category_name": tag.localized_category_name || tag.category_name
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restore market_fee_app, if applicable
|
||||||
|
var match;
|
||||||
|
if (this.appid == 753 && this.contextid == 6 && this.market_hash_name && (match = this.market_hash_name.match(/^(\d+)\-/))) {
|
||||||
|
this.market_fee_app = parseInt(match[1], 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restore cache_expiration, if we can (for CS:GO items)
|
||||||
|
if (this.appid == 730 && this.contextid == 2 && this.owner_descriptions) {
|
||||||
|
let description = this.owner_descriptions.find(d => d.value && d.value.indexOf('Tradable After ') == 0);
|
||||||
|
if (description) {
|
||||||
|
let date = new Date(description.value.substring(15).replace(/[,()]/g, ''));
|
||||||
|
if (date) {
|
||||||
|
this.cache_expiration = date.toISOString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we have item_expiration, also set cache_expiration to the same value
|
||||||
|
if (this.item_expiration) {
|
||||||
|
this.cache_expiration = this.item_expiration;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.actions === "") {
|
||||||
|
this.actions = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
delete this.currency;
|
||||||
}
|
}
|
||||||
|
|
||||||
CEconItem.prototype.getImageURL = function() {
|
CEconItem.prototype.getImageURL = function() {
|
||||||
@@ -45,12 +102,12 @@ CEconItem.prototype.getLargeImageURL = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
CEconItem.prototype.getTag = function(category) {
|
CEconItem.prototype.getTag = function(category) {
|
||||||
if(!this.tags) {
|
if (!this.tags) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(var i = 0; i < this.tags.length; i++) {
|
for (var i = 0; i < this.tags.length; i++) {
|
||||||
if(this.tags[i].category == category) {
|
if (this.tags[i].category == category) {
|
||||||
return this.tags[i];
|
return this.tags[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,51 +1,60 @@
|
|||||||
var SteamCommunity = require('../index.js');
|
var SteamCommunity = require('../index.js');
|
||||||
var Cheerio = require('cheerio');
|
var Cheerio = require('cheerio');
|
||||||
|
|
||||||
SteamCommunity.prototype.getMarketItem = function(appid, hashName, callback) {
|
SteamCommunity.prototype.getMarketItem = function(appid, hashName, currency, callback) {
|
||||||
|
if (typeof currency == "function") {
|
||||||
|
callback = currency;
|
||||||
|
currency = 1;
|
||||||
|
}
|
||||||
var self = this;
|
var self = this;
|
||||||
this.request("https://steamcommunity.com/market/listings/" + appid + "/" + encodeURIComponent(hashName), function(err, response, body) {
|
this.httpRequest("https://steamcommunity.com/market/listings/" + appid + "/" + encodeURIComponent(hashName), function(err, response, body) {
|
||||||
if(self._checkHttpError(err, response, callback)) {
|
if (err) {
|
||||||
|
callback(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var $ = Cheerio.load(body);
|
var $ = Cheerio.load(body);
|
||||||
if($('.market_listing_table_message') && $('.market_listing_table_message').text().trim() == 'There are no listings for this item.') {
|
if($('.market_listing_table_message') && $('.market_listing_table_message').text().trim() == 'There are no listings for this item.') {
|
||||||
callback(new Error("There are no listings for this item."));
|
callback(new Error("There are no listings for this item."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var item = new CMarketItem(self, body, $);
|
var item = new CMarketItem(appid, hashName, self, body, $);
|
||||||
if(item.commodity) {
|
item.updatePrice(currency, function(err) {
|
||||||
item.updatePrice(function(err) {
|
if(err) {
|
||||||
if(err) {
|
callback(err);
|
||||||
callback(err);
|
} else {
|
||||||
} else {
|
callback(null, item);
|
||||||
callback(null, item);
|
}
|
||||||
}
|
});
|
||||||
});
|
}, "steamcommunity");
|
||||||
} else {
|
|
||||||
callback(null, item);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function CMarketItem(community, body, $) {
|
function CMarketItem(appid, hashName, community, body, $) {
|
||||||
|
this._appid = appid;
|
||||||
|
this._hashName = hashName;
|
||||||
this._community = community;
|
this._community = community;
|
||||||
this._$ = $;
|
this._$ = $;
|
||||||
|
|
||||||
this._country = "US";
|
this._country = "US";
|
||||||
var match = body.match(/var g_strCountryCode = "([^"]+)";/);
|
var match = body.match(/var g_strCountryCode = "([^"]+)";/);
|
||||||
if(match) {
|
if(match) {
|
||||||
this._country = match[1];
|
this._country = match[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._language = "english";
|
||||||
|
match = body.match(/var g_strLanguage = "([^"]+)";/);
|
||||||
|
if(match) {
|
||||||
|
this._language = match[1];
|
||||||
|
}
|
||||||
|
|
||||||
this.commodity = false;
|
this.commodity = false;
|
||||||
var match = body.match(/Market_LoadOrderSpread\(\s*(\d+)\s*\);/);
|
match = body.match(/Market_LoadOrderSpread\(\s*(\d+)\s*\);/);
|
||||||
if(match) {
|
if(match) {
|
||||||
this.commodity = true;
|
this.commodity = true;
|
||||||
this.commodityID = parseInt(match[1], 10);
|
this.commodityID = parseInt(match[1], 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.medianSalePrices = null;
|
this.medianSalePrices = null;
|
||||||
match = body.match(/var line1=([^;]+);/);
|
match = body.match(/var line1=([^;]+);/);
|
||||||
if(match) {
|
if(match) {
|
||||||
@@ -62,65 +71,119 @@ function CMarketItem(community, body, $) {
|
|||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.quantity = 0;
|
this.firstAsset = null;
|
||||||
this.lowestPrice = 0;
|
this.assets = null;
|
||||||
|
match = body.match(/var g_rgAssets = (.*);/);
|
||||||
if(!this.commodity) {
|
if (match) {
|
||||||
var total = $('#searchResults_total');
|
try {
|
||||||
if(total) {
|
this.assets = JSON.parse(match[1]);
|
||||||
this.quantity = parseInt(total.text().replace(/[^\d]/g, '').trim(), 10);
|
this.assets = this.assets[appid];
|
||||||
}
|
this.assets = this.assets[Object.keys(this.assets)[0]];
|
||||||
|
this.firstAsset = this.assets[Object.keys(this.assets)[0]];
|
||||||
var lowest = $('.market_listing_price.market_listing_price_with_fee');
|
} catch (e) {
|
||||||
if(lowest[0]) {
|
// ignore
|
||||||
this.lowestPrice = parseInt($(lowest[0]).text().replace(/[^\d]/g, '').trim(), 10);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.quantity = 0;
|
||||||
|
this.lowestPrice = 0;
|
||||||
// TODO: Buying listings and placing buy orders
|
// TODO: Buying listings and placing buy orders
|
||||||
}
|
}
|
||||||
|
|
||||||
CMarketItem.prototype.updatePrice = function(callback) {
|
CMarketItem.prototype.updatePrice = function (currency, callback) {
|
||||||
|
if (this.commodity) {
|
||||||
|
this.updatePriceForCommodity(currency, callback);
|
||||||
|
} else {
|
||||||
|
this.updatePriceForNonCommodity(currency, callback);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
CMarketItem.prototype.updatePriceForCommodity = function(currency, callback) {
|
||||||
if(!this.commodity) {
|
if(!this.commodity) {
|
||||||
throw new Error("Cannot update price for non-commodity item");
|
throw new Error("Cannot update price for non-commodity item");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Currency option maybe?
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this._community.request({
|
this._community.httpRequest({
|
||||||
"uri": "https://steamcommunity.com/market/itemordershistogram?country=US&language=english¤cy=1&item_nameid=" + this.commodityID,
|
"uri": "https://steamcommunity.com/market/itemordershistogram?country=US&language=english¤cy=" + currency + "&item_nameid=" + this.commodityID,
|
||||||
"json": true,
|
"json": true
|
||||||
}, function(err, response, body) {
|
}, function(err, response, body) {
|
||||||
if(self._community._checkHttpError(err, response, callback)) {
|
if (err) {
|
||||||
|
callback(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(body.success != 1) {
|
if(body.success != 1) {
|
||||||
if(callback) {
|
if(callback) {
|
||||||
callback(new Error("Error " + body.success));
|
callback(new Error("Error " + body.success));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var match = (body.sell_order_summary || '').match(/<span class="market_commodity_orders_header_promote">(\d+)<\/span>/);
|
var match = (body.sell_order_summary || '').match(/<span class="market_commodity_orders_header_promote">(\d+)<\/span>/);
|
||||||
if(match) {
|
if(match) {
|
||||||
self.quantity = parseInt(match[1], 10);
|
self.quantity = parseInt(match[1], 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.buyQuantity = 0;
|
self.buyQuantity = 0;
|
||||||
match = (body.buy_order_summary || '').match(/<span class="market_commodity_orders_header_promote">(\d+)<\/span>/);
|
match = (body.buy_order_summary || '').match(/<span class="market_commodity_orders_header_promote">(\d+)<\/span>/);
|
||||||
if(match) {
|
if(match) {
|
||||||
self.buyQuantity = parseInt(match[1], 10);
|
self.buyQuantity = parseInt(match[1], 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.lowestPrice = parseInt(body.lowest_sell_order, 10);
|
self.lowestPrice = parseInt(body.lowest_sell_order, 10);
|
||||||
self.highestBuyOrder = parseInt(body.highest_buy_order, 10);
|
self.highestBuyOrder = parseInt(body.highest_buy_order, 10);
|
||||||
|
|
||||||
// TODO: The tables?
|
// TODO: The tables?
|
||||||
if(callback) {
|
if(callback) {
|
||||||
callback(null);
|
callback(null);
|
||||||
}
|
}
|
||||||
});
|
}, "steamcommunity");
|
||||||
|
};
|
||||||
|
|
||||||
|
CMarketItem.prototype.updatePriceForNonCommodity = function (currency, callback) {
|
||||||
|
if(this.commodity) {
|
||||||
|
throw new Error("Cannot update price for commodity item");
|
||||||
|
}
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
this._community.httpRequest({
|
||||||
|
"uri": "https://steamcommunity.com/market/listings/" +
|
||||||
|
this._appid + "/" +
|
||||||
|
encodeURIComponent(this._hashName) +
|
||||||
|
"/render/?query=&start=0&count=10&country=US&language=english¤cy=" + currency,
|
||||||
|
"json": true
|
||||||
|
}, function(err, response, body) {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body.success != 1) {
|
||||||
|
callback && callback(new Error("Error " + body.success));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var match = body.total_count;
|
||||||
|
if (match) {
|
||||||
|
self.quantity = parseInt(match, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
var lowestPrice;
|
||||||
|
var $ = Cheerio.load(body.results_html);
|
||||||
|
match = $(".market_listing_price.market_listing_price_with_fee");
|
||||||
|
if (match) {
|
||||||
|
for (var i = 0; i < match.length; i++) {
|
||||||
|
lowestPrice = parseFloat($(match[i]).text().replace(",", ".").replace(/[^\d.]/g, ''));
|
||||||
|
if (!isNaN(lowestPrice)) {
|
||||||
|
self.lowestPrice = lowestPrice;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
callback && callback(null);
|
||||||
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,83 +3,87 @@ var Cheerio = require('cheerio');
|
|||||||
|
|
||||||
SteamCommunity.prototype.marketSearch = function(options, callback) {
|
SteamCommunity.prototype.marketSearch = function(options, callback) {
|
||||||
var qs = {};
|
var qs = {};
|
||||||
|
|
||||||
if(typeof options === 'string') {
|
if(typeof options === 'string') {
|
||||||
qs.query = options;
|
qs.query = options;
|
||||||
} else {
|
} else {
|
||||||
qs.query = options.query || '';
|
qs.query = options.query || '';
|
||||||
qs.appid = options.appid;
|
qs.appid = options.appid;
|
||||||
qs.search_descriptions = options.searchDescriptions ? 1 : 0;
|
qs.search_descriptions = options.searchDescriptions ? 1 : 0;
|
||||||
|
|
||||||
if(qs.appid) {
|
if(qs.appid) {
|
||||||
for(var i in options) {
|
for(var i in options) {
|
||||||
if(['query', 'appid', 'searchDescriptions'].indexOf(i) != -1) {
|
if(['query', 'appid', 'searchDescriptions'].indexOf(i) != -1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is a tag
|
// This is a tag
|
||||||
qs['category_' + qs.appid + '_' + i + '[]'] = 'tag_' + options[i];
|
qs['category_' + qs.appid + '_' + i + '[]'] = 'tag_' + options[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qs.start = 0;
|
qs.start = 0;
|
||||||
qs.count = 100;
|
qs.count = 100;
|
||||||
qs.sort_column = 'price';
|
qs.sort_column = 'price';
|
||||||
qs.sort_dir = 'asc';
|
qs.sort_dir = 'asc';
|
||||||
performSearch.call(this, this.request, qs, [], callback);
|
|
||||||
|
var self = this;
|
||||||
|
var results = [];
|
||||||
|
performSearch();
|
||||||
|
|
||||||
|
function performSearch() {
|
||||||
|
self.httpRequest({
|
||||||
|
"uri": "https://steamcommunity.com/market/search/render/",
|
||||||
|
"qs": qs,
|
||||||
|
"headers": {
|
||||||
|
"referer": "https://steamcommunity.com/market/search"
|
||||||
|
},
|
||||||
|
"json": true
|
||||||
|
}, function(err, response, body) {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!body.success) {
|
||||||
|
callback(new Error("Success is not true"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!body.results_html) {
|
||||||
|
callback(new Error("No results_html in response"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var $ = Cheerio.load(body.results_html);
|
||||||
|
var $errorMsg = $('.market_listing_table_message');
|
||||||
|
if($errorMsg.length > 0) {
|
||||||
|
callback(new Error($errorMsg.text()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var rows = $('.market_listing_row_link');
|
||||||
|
for(var i = 0; i < rows.length; i++) {
|
||||||
|
results.push(new CMarketSearchResult($(rows[i])));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(body.start + body.pagesize >= body.total_count) {
|
||||||
|
callback(null, results);
|
||||||
|
} else {
|
||||||
|
qs.start += body.pagesize;
|
||||||
|
performSearch();
|
||||||
|
}
|
||||||
|
}, "steamcommunity");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function performSearch(request, qs, results, callback) {
|
|
||||||
var self = this;
|
|
||||||
request({
|
|
||||||
"uri": "https://steamcommunity.com/market/search/render/",
|
|
||||||
"qs": qs,
|
|
||||||
"headers": {
|
|
||||||
"referer": "https://steamcommunity.com/market/search"
|
|
||||||
},
|
|
||||||
"json": true
|
|
||||||
}, function(err, response, body) {
|
|
||||||
if(self._checkHttpError(err, response, callback)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!body.success) {
|
|
||||||
callback(new Error("Success is not true"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!body.results_html) {
|
|
||||||
callback(new Error("No results_html in response"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var $ = Cheerio.load(body.results_html);
|
|
||||||
if($('.market_listing_table_message').length > 0) {
|
|
||||||
callback(new Error($('.market_listing_table_message').text()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var rows = $('.market_listing_row_link');
|
|
||||||
for(var i = 0; i < rows.length; i++) {
|
|
||||||
results.push(new CMarketSearchResult($(rows[i])));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(body.start + body.pagesize >= body.total_count) {
|
|
||||||
callback(null, results);
|
|
||||||
} else {
|
|
||||||
qs.start += body.pagesize;
|
|
||||||
performSearch(request, qs, results, callback);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function CMarketSearchResult(row) {
|
function CMarketSearchResult(row) {
|
||||||
var match = row.attr('href').match(/\/market\/listings\/(\d+)\/(.+)/);
|
var match = row.attr('href').match(/\/market\/listings\/(\d+)\/([^\?\/]+)/);
|
||||||
|
|
||||||
this.appid = parseInt(match[1], 10);
|
this.appid = parseInt(match[1], 10);
|
||||||
this.market_hash_name = decodeURIComponent(match[2]);
|
this.market_hash_name = decodeURIComponent(match[2]);
|
||||||
this.image = row.find('.market_listing_item_img').attr('src').match(/^https?:\/\/[^\/]+\/economy\/image\/[^\/]+\//)[0];
|
this.image = ((row.find('.market_listing_item_img').attr('src') || "").match(/^https?:\/\/[^\/]+\/economy\/image\/[^\/]+\//) || [])[0];
|
||||||
this.price = parseInt(row.find('.market_listing_their_price .market_table_value span').text().replace(/[^\d]+/g, ''), 10);
|
this.price = parseInt(row.find('.market_listing_their_price .market_table_value span.normal_price').text().replace(/[^\d]+/g, ''), 10);
|
||||||
this.quantity = parseInt(row.find('.market_listing_num_listings_qty').text().replace(/[^\d]+/g, ''), 10);
|
this.quantity = parseInt(row.find('.market_listing_num_listings_qty').text().replace(/[^\d]+/g, ''), 10);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,40 +1,38 @@
|
|||||||
var SteamCommunity = require('../index.js');
|
var SteamCommunity = require('../index.js');
|
||||||
|
var Helpers = require('../components/helpers.js');
|
||||||
var SteamID = require('steamid');
|
var SteamID = require('steamid');
|
||||||
var xml2js = require('xml2js');
|
var xml2js = require('xml2js');
|
||||||
|
|
||||||
SteamCommunity.prototype.getSteamGroup = function(id, callback) {
|
SteamCommunity.prototype.getSteamGroup = function(id, callback) {
|
||||||
if(typeof id !== 'string' && !(typeof id === 'object' && id.__proto__ === SteamID.prototype)) {
|
if(typeof id !== 'string' && !Helpers.isSteamID(id)) {
|
||||||
throw new Error("id parameter should be a group URL string or a SteamID object");
|
throw new Error("id parameter should be a group URL string or a SteamID object");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(typeof id === 'object' && (id.universe != SteamID.Universe.PUBLIC || id.type != SteamID.Type.CLAN)) {
|
if(typeof id === 'object' && (id.universe != SteamID.Universe.PUBLIC || id.type != SteamID.Type.CLAN)) {
|
||||||
throw new Error("SteamID must stand for a clan account in the public universe");
|
throw new Error("SteamID must stand for a clan account in the public universe");
|
||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.request("https://steamcommunity.com/" + (typeof id === 'string' ? "groups/" + id : "gid/" + id.toString()) + "/memberslistxml/?xml=1", function(err, response, body) {
|
this.httpRequest("https://steamcommunity.com/" + (typeof id === 'string' ? "groups/" + id : "gid/" + id.toString()) + "/memberslistxml/?xml=1", function(err, response, body) {
|
||||||
if(self._checkHttpError(err, response, callback)) {
|
if (err) {
|
||||||
|
callback(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(self._checkCommunityError(body, callback)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
xml2js.parseString(body, function(err, result) {
|
xml2js.parseString(body, function(err, result) {
|
||||||
if(err) {
|
if(err) {
|
||||||
callback(err);
|
callback(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null, new CSteamGroup(self, result.memberList));
|
callback(null, new CSteamGroup(self, result.memberList));
|
||||||
});
|
});
|
||||||
});
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
function CSteamGroup(community, groupData) {
|
function CSteamGroup(community, groupData) {
|
||||||
this._community = community;
|
this._community = community;
|
||||||
|
|
||||||
this.steamID = new SteamID(groupData.groupID64[0]);
|
this.steamID = new SteamID(groupData.groupID64[0]);
|
||||||
this.name = groupData.groupDetails[0].groupName[0];
|
this.name = groupData.groupDetails[0].groupName[0];
|
||||||
this.url = groupData.groupDetails[0].groupURL[0];
|
this.url = groupData.groupDetails[0].groupURL[0];
|
||||||
@@ -50,7 +48,7 @@ function CSteamGroup(community, groupData) {
|
|||||||
CSteamGroup.prototype.getAvatarURL = function(size, protocol) {
|
CSteamGroup.prototype.getAvatarURL = function(size, protocol) {
|
||||||
size = size || '';
|
size = size || '';
|
||||||
protocol = protocol || 'http://';
|
protocol = protocol || 'http://';
|
||||||
|
|
||||||
var url = protocol + "steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/" + this.avatarHash.substring(0, 2) + "/" + this.avatarHash;
|
var url = protocol + "steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/" + this.avatarHash.substring(0, 2) + "/" + this.avatarHash;
|
||||||
if(size == 'full' || size == 'medium') {
|
if(size == 'full' || size == 'medium') {
|
||||||
return url + "_" + size + ".jpg";
|
return url + "_" + size + ".jpg";
|
||||||
@@ -76,14 +74,34 @@ CSteamGroup.prototype.leave = function(callback) {
|
|||||||
this._community.leaveGroup(this.steamID, callback);
|
this._community.leaveGroup(this.steamID, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
CSteamGroup.prototype.getAllAnnouncements = function(time, callback) {
|
||||||
|
this._community.getAllGroupAnnouncements(this.steamID, time, callback);
|
||||||
|
};
|
||||||
|
|
||||||
CSteamGroup.prototype.postAnnouncement = function(headline, content, callback) {
|
CSteamGroup.prototype.postAnnouncement = function(headline, content, callback) {
|
||||||
this._community.postGroupAnnouncement(this.steamID, headline, content, callback);
|
this._community.postGroupAnnouncement(this.steamID, headline, content, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
CSteamGroup.prototype.editAnnouncement = function(annoucementID, headline, content, callback) {
|
||||||
|
this._community.editGroupAnnouncement(this.steamID, annoucementID, headline, content, callback)
|
||||||
|
};
|
||||||
|
|
||||||
|
CSteamGroup.prototype.deleteAnnouncement = function(annoucementID, callback) {
|
||||||
|
this._community.deleteGroupAnnouncement(this.steamID, annoucementID, callback)
|
||||||
|
};
|
||||||
|
|
||||||
CSteamGroup.prototype.scheduleEvent = function(name, type, description, time, server, callback) {
|
CSteamGroup.prototype.scheduleEvent = function(name, type, description, time, server, callback) {
|
||||||
this._community.scheduleGroupEvent(this.steamID, name, type, description, time, server, callback);
|
this._community.scheduleGroupEvent(this.steamID, name, type, description, time, server, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
CSteamGroup.prototype.editEvent = function(id, name, type, description, time, server, callback) {
|
||||||
|
this._community.editGroupEvent(this.steamID, id, name, type, description, time, server, callback);
|
||||||
|
};
|
||||||
|
|
||||||
|
CSteamGroup.prototype.deleteEvent = function (id, callback) {
|
||||||
|
this._community.deleteGroupEvent(this.steamID, id, callback);
|
||||||
|
};
|
||||||
|
|
||||||
CSteamGroup.prototype.setPlayerOfTheWeek = function(steamID, callback) {
|
CSteamGroup.prototype.setPlayerOfTheWeek = function(steamID, callback) {
|
||||||
this._community.setGroupPlayerOfTheWeek(this.steamID, steamID, callback);
|
this._community.setGroupPlayerOfTheWeek(this.steamID, steamID, callback);
|
||||||
};
|
};
|
||||||
@@ -95,3 +113,43 @@ CSteamGroup.prototype.kick = function(steamID, callback) {
|
|||||||
CSteamGroup.prototype.getHistory = function(page, callback) {
|
CSteamGroup.prototype.getHistory = function(page, callback) {
|
||||||
this._community.getGroupHistory(this.steamID, page, callback);
|
this._community.getGroupHistory(this.steamID, page, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
CSteamGroup.prototype.getAllComments = function(from, count, callback) {
|
||||||
|
this._community.getAllGroupComments(this.steamID, from, count, callback);
|
||||||
|
};
|
||||||
|
|
||||||
|
CSteamGroup.prototype.deleteComment = function(cid, callback) {
|
||||||
|
this._community.deleteGroupComment(this.steamID, cid, callback);
|
||||||
|
};
|
||||||
|
|
||||||
|
CSteamGroup.prototype.comment = function(message, callback) {
|
||||||
|
this._community.postGroupComment(this.steamID, message, callback);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get requests to join this restricted group.
|
||||||
|
* @param {function} callback - First argument is null/Error, second is array of SteamID objects
|
||||||
|
*/
|
||||||
|
CSteamGroup.prototype.getJoinRequests = function(callback) {
|
||||||
|
this._community.getGroupJoinRequests(this.steamID, callback);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Respond to one or more join requests to this restricted group.
|
||||||
|
* @param {SteamID|string|SteamID[]|string[]} steamIDs - The SteamIDs of the users you want to approve or deny membership for (or a single value)
|
||||||
|
* @param {boolean} approve - True to put them in the group, false to deny their membership
|
||||||
|
* @param {function} callback - Takes only an Error object/null as the first argument
|
||||||
|
*/
|
||||||
|
CSteamGroup.prototype.respondToJoinRequests = function(steamIDs, approve, callback) {
|
||||||
|
this._community.respondToGroupJoinRequests(this.steamID, steamIDs, approve, callback);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Respond to *ALL* pending group-join requests for this group.
|
||||||
|
* @param {boolean} approve - True to allow everyone who requested into the group, false to not
|
||||||
|
* @param {function} callback - Takes only an Error object/null as the first argument
|
||||||
|
*/
|
||||||
|
CSteamGroup.prototype.respondToAllJoinRequests = function(approve, callback) {
|
||||||
|
this._community.respondToAllGroupJoinRequests(this.steamID, approve, callback);
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,37 +1,35 @@
|
|||||||
var SteamCommunity = require('../index.js');
|
var SteamCommunity = require('../index.js');
|
||||||
|
var Helpers = require('../components/helpers.js');
|
||||||
var SteamID = require('steamid');
|
var SteamID = require('steamid');
|
||||||
var xml2js = require('xml2js');
|
var xml2js = require('xml2js');
|
||||||
|
|
||||||
SteamCommunity.prototype.getSteamUser = function(id, callback) {
|
SteamCommunity.prototype.getSteamUser = function(id, callback) {
|
||||||
if(typeof id !== 'string' && !(typeof id === 'object' && id.__proto__ === SteamID.prototype)) {
|
if(typeof id !== 'string' && !Helpers.isSteamID(id)) {
|
||||||
throw new Error("id parameter should be a user URL string or a SteamID object");
|
throw new Error("id parameter should be a user URL string or a SteamID object");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(typeof id === 'object' && (id.universe != SteamID.Universe.PUBLIC || id.type != SteamID.Type.INDIVIDUAL)) {
|
if(typeof id === 'object' && (id.universe != SteamID.Universe.PUBLIC || id.type != SteamID.Type.INDIVIDUAL)) {
|
||||||
throw new Error("SteamID must stand for an individual account in the public universe");
|
throw new Error("SteamID must stand for an individual account in the public universe");
|
||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.request("http://steamcommunity.com/" + (typeof id === 'string' ? "id/" + id : "profiles/" + id.toString()) + "/?xml=1", function(err, response, body) {
|
this.httpRequest("http://steamcommunity.com/" + (typeof id === 'string' ? "id/" + id : "profiles/" + id.toString()) + "/?xml=1", function(err, response, body) {
|
||||||
if(self._checkHttpError(err, response, callback)) {
|
if (err) {
|
||||||
|
callback(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(self._checkCommunityError(body, callback)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
xml2js.parseString(body, function(err, result) {
|
xml2js.parseString(body, function(err, result) {
|
||||||
if(err || (!result.response && !result.profile)) {
|
if(err || (!result.response && !result.profile)) {
|
||||||
callback(err || new Error("No valid response"));
|
callback(err || new Error("No valid response"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(result.response && result.response.error && result.response.error.length) {
|
if(result.response && result.response.error && result.response.error.length) {
|
||||||
callback(new Error(result.response.error[0]));
|
callback(new Error(result.response.error[0]));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try and find custom URL from redirect
|
// Try and find custom URL from redirect
|
||||||
var customurl = null;
|
var customurl = null;
|
||||||
if(response.request.redirects && response.request.redirects.length) {
|
if(response.request.redirects && response.request.redirects.length) {
|
||||||
@@ -45,55 +43,61 @@ SteamCommunity.prototype.getSteamUser = function(id, callback) {
|
|||||||
callback(new Error("No valid response"));
|
callback(new Error("No valid response"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null, new CSteamUser(self, result.profile, customurl));
|
callback(null, new CSteamUser(self, result.profile, customurl));
|
||||||
});
|
});
|
||||||
});
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
function CSteamUser(community, userData, customurl) {
|
function CSteamUser(community, userData, customurl) {
|
||||||
this._community = community;
|
this._community = community;
|
||||||
|
|
||||||
this.steamID = new SteamID(userData.steamID64[0]);
|
this.steamID = new SteamID(userData.steamID64[0]);
|
||||||
this.name = processItem(userData, 'steamID');
|
this.name = processItem('steamID');
|
||||||
this.onlineState = processItem(userData, 'onlineState');
|
this.onlineState = processItem('onlineState');
|
||||||
this.stateMessage = processItem(userData, 'stateMessage');
|
this.stateMessage = processItem('stateMessage');
|
||||||
this.privacyState = processItem(userData, 'privacyState', 'uncreated');
|
this.privacyState = processItem('privacyState', 'uncreated');
|
||||||
this.visibilityState = processItem(userData, 'visibilityState');
|
this.visibilityState = processItem('visibilityState');
|
||||||
this.avatarHash = processItem(userData, 'avatarIcon', '').match(/([0-9a-f]+)\.[a-z]+$/);
|
this.avatarHash = processItem('avatarIcon', '').match(/([0-9a-f]+)\.[a-z]+$/);
|
||||||
if(this.avatarHash) {
|
if(this.avatarHash) {
|
||||||
this.avatarHash = this.avatarHash[1];
|
this.avatarHash = this.avatarHash[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
this.vacBanned = !!processItem(userData, 'vacBanned', false);
|
this.vacBanned = processItem('vacBanned', false) == 1;
|
||||||
this.tradeBanState = processItem(userData, 'tradeBanState', 'None');
|
this.tradeBanState = processItem('tradeBanState', 'None');
|
||||||
this.isLimitedAccount = !!processItem(userData, 'isLimitedAccount');
|
this.isLimitedAccount = processItem('isLimitedAccount') == 1;
|
||||||
this.customURL = processItem(userData, 'customURL', customurl);
|
this.customURL = processItem('customURL', customurl);
|
||||||
|
|
||||||
if(this.visibilityState == 3) {
|
if(this.visibilityState == 3) {
|
||||||
this.memberSince = new Date(processItem(userData, 'memberSince', '0').replace(/(\d{1,2})(st|nd|th)/, "$1"));
|
let memberSinceValue = processItem('memberSince', '0').replace(/(\d{1,2})(st|nd|th)/, "$1");
|
||||||
this.location = processItem(userData, 'location');
|
|
||||||
this.realName = processItem(userData, 'realname');
|
if (memberSinceValue.indexOf(',') === -1) {
|
||||||
this.summary = processItem(userData, 'summary');
|
memberSinceValue += ', ' + new Date().getFullYear();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.memberSince = new Date(memberSinceValue);
|
||||||
|
this.location = processItem('location');
|
||||||
|
this.realName = processItem('realname');
|
||||||
|
this.summary = processItem('summary');
|
||||||
} else {
|
} else {
|
||||||
this.memberSince = null;
|
this.memberSince = null;
|
||||||
this.location = null;
|
this.location = null;
|
||||||
this.realName = null;
|
this.realName = null;
|
||||||
this.summary = null;
|
this.summary = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Maybe handle mostPlayedGames?
|
// Maybe handle mostPlayedGames?
|
||||||
|
|
||||||
this.groups = null;
|
this.groups = null;
|
||||||
this.primaryGroup = null;
|
this.primaryGroup = null;
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
if(userData.groups && userData.groups[0] && userData.groups[0].group) {
|
if(userData.groups && userData.groups[0] && userData.groups[0].group) {
|
||||||
this.groups = userData.groups[0].group.map(function(group) {
|
this.groups = userData.groups[0].group.map(function(group) {
|
||||||
if(group['$'] && group['$'].isPrimary) {
|
if(group['$'] && group['$'].isPrimary === "1") {
|
||||||
self.primaryGroup = new SteamID(group.groupID64[0]);
|
self.primaryGroup = new SteamID(group.groupID64[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new SteamID(group.groupID64[0]);
|
return new SteamID(group.groupID64[0]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -110,7 +114,9 @@ function CSteamUser(community, userData, customurl) {
|
|||||||
CSteamUser.getAvatarURL = function(hash, size, protocol) {
|
CSteamUser.getAvatarURL = function(hash, size, protocol) {
|
||||||
size = size || '';
|
size = size || '';
|
||||||
protocol = protocol || 'http://';
|
protocol = protocol || 'http://';
|
||||||
|
|
||||||
|
hash = hash || "72f78b4c8cc1f62323f8a33f6d53e27db57c2252"; // The default "?" avatar
|
||||||
|
|
||||||
var url = protocol + "steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/" + hash.substring(0, 2) + "/" + hash;
|
var url = protocol + "steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/" + hash.substring(0, 2) + "/" + hash;
|
||||||
if(size == 'full' || size == 'medium') {
|
if(size == 'full' || size == 'medium') {
|
||||||
return url + "_" + size + ".jpg";
|
return url + "_" + size + ".jpg";
|
||||||
@@ -152,10 +158,51 @@ CSteamUser.prototype.inviteToGroup = function(groupID, callback) {
|
|||||||
this._community.inviteUserToGroup(this.steamID, groupID, callback);
|
this._community.inviteUserToGroup(this.steamID, groupID, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
CSteamUser.prototype.getAliases = function(callback) {
|
||||||
|
this._community.getUserAliases(this.steamID, callback);
|
||||||
|
};
|
||||||
|
|
||||||
CSteamUser.prototype.getInventoryContexts = function(callback) {
|
CSteamUser.prototype.getInventoryContexts = function(callback) {
|
||||||
this._community.getUserInventoryContexts(this.steamID, callback);
|
this._community.getUserInventoryContexts(this.steamID, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the contents of a user's inventory context.
|
||||||
|
* @deprecated Use CSteamUser#getInventoryContents instead
|
||||||
|
* @param {int} appID - The Steam application ID of the game for which you want an inventory
|
||||||
|
* @param {int} contextID - The ID of the "context" within the game you want to retrieve
|
||||||
|
* @param {boolean} tradableOnly - true to get only tradable items and currencies
|
||||||
|
* @param callback
|
||||||
|
*/
|
||||||
CSteamUser.prototype.getInventory = function(appID, contextID, tradableOnly, callback) {
|
CSteamUser.prototype.getInventory = function(appID, contextID, tradableOnly, callback) {
|
||||||
this._community.getInventory(appID, contextID, tradableOnly, callback);
|
this._community.getUserInventory(this.steamID, appID, contextID, tradableOnly, callback);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the contents of a user's inventory context.
|
||||||
|
* @param {int} appID - The Steam application ID of the game for which you want an inventory
|
||||||
|
* @param {int} contextID - The ID of the "context" within the game you want to retrieve
|
||||||
|
* @param {boolean} tradableOnly - true to get only tradable items and currencies
|
||||||
|
* @param callback
|
||||||
|
*/
|
||||||
|
CSteamUser.prototype.getInventoryContents = function(appID, contextID, tradableOnly, callback) {
|
||||||
|
this._community.getUserInventoryContents(this.steamID, appID, contextID, tradableOnly, callback);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the background URL of user's profile.
|
||||||
|
* @param {function} callback
|
||||||
|
*/
|
||||||
|
CSteamUser.prototype.getProfileBackground = function(callback) {
|
||||||
|
this._community.getUserProfileBackground(this.steamID, callback);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Upload an image to Steam and send it to the target user over chat.
|
||||||
|
* @param {Buffer} imageContentsBuffer - The image contents, as a Buffer
|
||||||
|
* @param {{spoiler?: boolean}} [options]
|
||||||
|
* @param {function} callback
|
||||||
|
*/
|
||||||
|
CSteamUser.prototype.sendImage = function(imageContentsBuffer, options, callback) {
|
||||||
|
this._community.sendImageToUser(this.steamID, imageContentsBuffer, options, callback);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,116 +1,109 @@
|
|||||||
var SteamCommunity = require('../index.js');
|
var SteamCommunity = require('../index.js');
|
||||||
var SteamID = require('steamid');
|
var SteamID = require('steamid');
|
||||||
|
|
||||||
SteamCommunity.ChatState = {
|
SteamCommunity.ChatState = require('../resources/EChatState.js');
|
||||||
"Offline": 0,
|
SteamCommunity.PersonaState = require('../resources/EPersonaState.js');
|
||||||
"LoggingOn": 1,
|
SteamCommunity.PersonaStateFlag = require('../resources/EPersonaStateFlag.js');
|
||||||
"LogOnFailed": 2,
|
|
||||||
"LoggedOn": 3
|
|
||||||
};
|
|
||||||
|
|
||||||
SteamCommunity.PersonaState = {
|
|
||||||
"Offline": 0,
|
|
||||||
"Online": 1,
|
|
||||||
"Busy": 2,
|
|
||||||
"Away": 3,
|
|
||||||
"Snooze": 4,
|
|
||||||
"LookingToTrade": 5,
|
|
||||||
"LookingToPlay": 6,
|
|
||||||
"Max": 7
|
|
||||||
};
|
|
||||||
|
|
||||||
SteamCommunity.PersonaStateFlag = {
|
|
||||||
"HasRichPresence": 1,
|
|
||||||
"InJoinableGame": 2,
|
|
||||||
|
|
||||||
"OnlineUsingWeb": 256,
|
|
||||||
"OnlineUsingMobile": 512,
|
|
||||||
"OnlineUsingBigPicture": 1024
|
|
||||||
};
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated No support for new Steam chat. Use steam-user instead.
|
||||||
|
* @param {int} interval
|
||||||
|
* @param {string} uiMode
|
||||||
|
*/
|
||||||
SteamCommunity.prototype.chatLogon = function(interval, uiMode) {
|
SteamCommunity.prototype.chatLogon = function(interval, uiMode) {
|
||||||
if(this.chatState == SteamCommunity.ChatState.LoggingOn || this.chatState == SteamCommunity.ChatState.LoggedOn) {
|
if(this.chatState == SteamCommunity.ChatState.LoggingOn || this.chatState == SteamCommunity.ChatState.LoggedOn) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
interval = interval || 500;
|
interval = interval || 500;
|
||||||
uiMode = uiMode || "web";
|
uiMode = uiMode || "web";
|
||||||
|
|
||||||
this.emit('debug', 'Requesting chat WebAPI token');
|
this.emit('debug', 'Requesting chat WebAPI token');
|
||||||
this.chatState = SteamCommunity.ChatState.LoggingOn;
|
this.chatState = SteamCommunity.ChatState.LoggingOn;
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.request("https://steamcommunity.com/chat", function(err, response, body) {
|
this.getWebApiOauthToken(function(err, token) {
|
||||||
if(err || response.statusCode != 200) {
|
if(err) {
|
||||||
self.emit('debug', 'Error requesting chat WebAPI token: ' + (err ? err.message : "HTTP error " + response.statusCode));
|
var fatal = err.message.indexOf('not authorized') != -1;
|
||||||
self.chatState = SteamCommunity.ChatState.LogOnFailed;
|
|
||||||
setTimeout(self.chatLogon.bind(self), 5000);
|
if (!fatal) {
|
||||||
|
self.chatState = SteamCommunity.ChatState.LogOnFailed;
|
||||||
|
setTimeout(self.chatLogon.bind(self), 5000);
|
||||||
|
} else {
|
||||||
|
self.chatState = SteamCommunity.ChatState.Offline;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.emit('chatLogOnFailed', err, fatal);
|
||||||
|
self.emit('debug', "Cannot get oauth token: " + err.message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var match = body.match(/[0-9a-f]{32}/);
|
self.httpRequestPost({
|
||||||
if(!match) {
|
|
||||||
self.emit('debug', 'Couldn\'t find a WebAPI chat token in the response.');
|
|
||||||
self.chatState = SteamCommunity.ChatState.LogOnFailed;
|
|
||||||
setTimeout(self.chatLogon.bind(self), 5000);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.request.post({
|
|
||||||
"uri": "https://api.steampowered.com/ISteamWebUserPresenceOAuth/Logon/v1",
|
"uri": "https://api.steampowered.com/ISteamWebUserPresenceOAuth/Logon/v1",
|
||||||
"form": {
|
"form": {
|
||||||
"ui_mode": uiMode,
|
"ui_mode": uiMode,
|
||||||
"access_token": match[0]
|
"access_token": token
|
||||||
},
|
},
|
||||||
"json": true
|
"json": true
|
||||||
}, function(err, response, body) {
|
}, function(err, response, body) {
|
||||||
if(err || response.statusCode != 200) {
|
if(err || response.statusCode != 200) {
|
||||||
|
self.chatState = SteamCommunity.ChatState.LogOnFailed;
|
||||||
|
self.emit('chatLogOnFailed', err ? err : new Error("HTTP error " + response.statusCode), false);
|
||||||
self.emit('debug', 'Error logging into webchat: ' + (err ? err.message : "HTTP error " + response.statusCode));
|
self.emit('debug', 'Error logging into webchat: ' + (err ? err.message : "HTTP error " + response.statusCode));
|
||||||
self.chatState = SteamCommunity.ChatState.LogOnFailed;
|
|
||||||
setTimeout(self.chatLogon.bind(self), 5000);
|
setTimeout(self.chatLogon.bind(self), 5000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(body.error != 'OK') {
|
if(body.error != 'OK') {
|
||||||
self.emit('debug', 'Error logging into webchat: ' + body.error);
|
|
||||||
self.chatState = SteamCommunity.ChatState.LogOnFailed;
|
self.chatState = SteamCommunity.ChatState.LogOnFailed;
|
||||||
|
self.emit('chatLogOnFailed', new Error(body.error), false);
|
||||||
|
self.emit('debug', 'Error logging into webchat: ' + body.error);
|
||||||
setTimeout(self.chatLogon.bind(self), 5000);
|
setTimeout(self.chatLogon.bind(self), 5000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self._chat = {
|
self._chat = {
|
||||||
"umqid": body.umqid,
|
"umqid": body.umqid,
|
||||||
"message": body.message,
|
"message": body.message,
|
||||||
"accessToken": match[0],
|
"accessToken": token,
|
||||||
"interval": interval
|
"interval": interval,
|
||||||
|
"uiMode": uiMode
|
||||||
};
|
};
|
||||||
|
|
||||||
self.chatFriends = {};
|
self.chatFriends = {};
|
||||||
|
|
||||||
self.chatState = SteamCommunity.ChatState.LoggedOn;
|
self.chatState = SteamCommunity.ChatState.LoggedOn;
|
||||||
self.emit('chatLoggedOn');
|
self.emit('chatLoggedOn');
|
||||||
self._chatPoll();
|
self._chatPoll();
|
||||||
});
|
}, "steamcommunity");
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated No support for new Steam chat. Use steam-user instead.
|
||||||
|
* @param {string|SteamID} recipient
|
||||||
|
* @param {string} text
|
||||||
|
* @param {string} [type]
|
||||||
|
* @param {function} [callback]
|
||||||
|
*/
|
||||||
SteamCommunity.prototype.chatMessage = function(recipient, text, type, callback) {
|
SteamCommunity.prototype.chatMessage = function(recipient, text, type, callback) {
|
||||||
if(this.chatState != SteamCommunity.ChatState.LoggedOn) {
|
if(this.chatState != SteamCommunity.ChatState.LoggedOn) {
|
||||||
throw new Error("Chat must be logged on before messages can be sent");
|
throw new Error("Chat must be logged on before messages can be sent");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(typeof recipient === 'string') {
|
if(typeof recipient === 'string') {
|
||||||
recipient = new SteamID(recipient);
|
recipient = new SteamID(recipient);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(typeof type === 'function') {
|
if(typeof type === 'function') {
|
||||||
callback = type;
|
callback = type;
|
||||||
type = 'saytext';
|
type = 'saytext';
|
||||||
}
|
}
|
||||||
|
|
||||||
type = type || 'saytext';
|
type = type || 'saytext';
|
||||||
|
|
||||||
this.request.post({
|
var self = this;
|
||||||
|
this.httpRequestPost({
|
||||||
"uri": "https://api.steampowered.com/ISteamWebUserPresenceOAuth/Message/v1",
|
"uri": "https://api.steampowered.com/ISteamWebUserPresenceOAuth/Message/v1",
|
||||||
"form": {
|
"form": {
|
||||||
"access_token": this._chat.accessToken,
|
"access_token": this._chat.accessToken,
|
||||||
@@ -124,22 +117,26 @@ SteamCommunity.prototype.chatMessage = function(recipient, text, type, callback)
|
|||||||
if(!callback) {
|
if(!callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(self._checkHttpError(err, response, callback)) {
|
if (err) {
|
||||||
|
callback(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(body.error != 'OK') {
|
if(body.error != 'OK') {
|
||||||
callback(new Error(body.error));
|
callback(new Error(body.error));
|
||||||
} else {
|
} else {
|
||||||
callback(null);
|
callback(null);
|
||||||
}
|
}
|
||||||
});
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated No support for new Steam chat. Use steam-user instead.
|
||||||
|
*/
|
||||||
SteamCommunity.prototype.chatLogoff = function() {
|
SteamCommunity.prototype.chatLogoff = function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.request.post({
|
this.httpRequestPost({
|
||||||
"uri": "https://api.steampowered.com/ISteamWebUserPresenceOAuth/Logoff/v1",
|
"uri": "https://api.steampowered.com/ISteamWebUserPresenceOAuth/Logoff/v1",
|
||||||
"form": {
|
"form": {
|
||||||
"access_token": this._chat.accessToken,
|
"access_token": this._chat.accessToken,
|
||||||
@@ -156,14 +153,17 @@ SteamCommunity.prototype.chatLogoff = function() {
|
|||||||
delete self.chatFriends;
|
delete self.chatFriends;
|
||||||
self.chatState = SteamCommunity.ChatState.Offline;
|
self.chatState = SteamCommunity.ChatState.Offline;
|
||||||
}
|
}
|
||||||
});
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
SteamCommunity.prototype._chatPoll = function() {
|
SteamCommunity.prototype._chatPoll = function() {
|
||||||
this.emit('debug', 'Doing chat poll');
|
this.emit('debug', 'Doing chat poll');
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.request.post({
|
this.httpRequestPost({
|
||||||
"uri": "https://api.steampowered.com/ISteamWebUserPresenceOAuth/Poll/v1",
|
"uri": "https://api.steampowered.com/ISteamWebUserPresenceOAuth/Poll/v1",
|
||||||
"form": {
|
"form": {
|
||||||
"umqid": self._chat.umqid,
|
"umqid": self._chat.umqid,
|
||||||
@@ -176,58 +176,88 @@ SteamCommunity.prototype._chatPoll = function() {
|
|||||||
},
|
},
|
||||||
"json": true
|
"json": true
|
||||||
}, function(err, response, body) {
|
}, function(err, response, body) {
|
||||||
if(self.chatState == SteamCommunity.ChatState.Offline) {
|
if (self.chatState == SteamCommunity.ChatState.Offline) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self._chat.timer = setTimeout(self._chatPoll.bind(self), self._chat.interval);
|
self._chat.timer = setTimeout(self._chatPoll.bind(self), self._chat.interval);
|
||||||
|
|
||||||
if(err || response.statusCode != 200) {
|
if(err || response.statusCode != 200) {
|
||||||
self.emit('debug', 'Error in chat poll: ' + (err ? err.message : "HTTP error " + response.statusCode));
|
self.emit('debug', 'Error in chat poll: ' + (err ? err.message : "HTTP error " + response.statusCode));
|
||||||
|
if (err.message == "Not Logged On") {
|
||||||
|
self._relogWebChat();
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(body.error != 'OK') {
|
if(!body || body.error != 'OK') {
|
||||||
self.emit('debug', 'Error in chat poll: ' + body.error);
|
self.emit('debug', 'Error in chat poll: ' + (body && body.error ? body.error : "Malformed response"));
|
||||||
|
if (body && body.error && body.error == "Not Logged On") {
|
||||||
|
self._relogWebChat();
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self._chat.message = body.messagelast;
|
self._chat.message = body.messagelast;
|
||||||
|
|
||||||
(body.messages || []).forEach(function(message) {
|
(body.messages || []).forEach(function(message) {
|
||||||
var sender = new SteamID();
|
var sender = new SteamID();
|
||||||
sender.universe = SteamID.Universe.PUBLIC;
|
sender.universe = SteamID.Universe.PUBLIC;
|
||||||
sender.type = SteamID.Type.INDIVIDUAL;
|
sender.type = SteamID.Type.INDIVIDUAL;
|
||||||
sender.instance = SteamID.Instance.DESKTOP;
|
sender.instance = SteamID.Instance.DESKTOP;
|
||||||
sender.accountid = message.accountid_from;
|
sender.accountid = message.accountid_from;
|
||||||
|
|
||||||
switch(message.type) {
|
switch(message.type) {
|
||||||
case 'personastate':
|
case 'personastate':
|
||||||
self._chatUpdatePersona(sender);
|
self._chatUpdatePersona(sender);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'saytext':
|
case 'saytext':
|
||||||
self.emit('chatMessage', sender, message.text);
|
self.emit('chatMessage', sender, message.text);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'typing':
|
case 'typing':
|
||||||
self.emit('chatTyping', sender);
|
self.emit('chatTyping', sender);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
self.emit('debug', 'Unhandled chat message type: ' + message.type);
|
self.emit('debug', 'Unhandled chat message type: ' + message.type);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
SteamCommunity.prototype._relogWebChat = function() {
|
||||||
|
this.emit('debug', "Relogging web chat");
|
||||||
|
clearTimeout(this._chat.timer);
|
||||||
|
this.chatState = SteamCommunity.ChatState.Offline;
|
||||||
|
this.chatLogon(this._chat.interval, this._chat.uiMode);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {SteamID} steamID
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
SteamCommunity.prototype._chatUpdatePersona = function(steamID) {
|
SteamCommunity.prototype._chatUpdatePersona = function(steamID) {
|
||||||
|
if (!this.chatFriends || this.chatState == SteamCommunity.ChatState.Offline) {
|
||||||
|
return; // we no longer care
|
||||||
|
}
|
||||||
|
|
||||||
this.emit('debug', 'Updating persona data for ' + steamID);
|
this.emit('debug', 'Updating persona data for ' + steamID);
|
||||||
var self = this;
|
var self = this;
|
||||||
this.request({
|
this.httpRequest({
|
||||||
"uri": "https://steamcommunity.com/chat/friendstate/" + steamID.accountid,
|
"uri": "https://steamcommunity.com/chat/friendstate/" + steamID.accountid,
|
||||||
"json": true
|
"json": true
|
||||||
}, function(err, response, body) {
|
}, function(err, response, body) {
|
||||||
|
if (!self.chatFriends || self.chatState == SteamCommunity.ChatState.Offline) {
|
||||||
|
return; // welp
|
||||||
|
}
|
||||||
|
|
||||||
if(err || response.statusCode != 200) {
|
if(err || response.statusCode != 200) {
|
||||||
self.emit('debug', 'Chat update persona error: ' + (err ? err.message : "HTTP error " + response.statusCode));
|
self.emit('debug', 'Chat update persona error: ' + (err ? err.message : "HTTP error " + response.statusCode));
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
@@ -235,7 +265,7 @@ SteamCommunity.prototype._chatUpdatePersona = function(steamID) {
|
|||||||
}, 2000);
|
}, 2000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var persona = {
|
var persona = {
|
||||||
"steamID": steamID,
|
"steamID": steamID,
|
||||||
"personaName": body.m_strName,
|
"personaName": body.m_strName,
|
||||||
@@ -249,5 +279,5 @@ SteamCommunity.prototype._chatUpdatePersona = function(steamID) {
|
|||||||
|
|
||||||
self.emit('chatPersonaState', steamID, persona);
|
self.emit('chatPersonaState', steamID, persona);
|
||||||
self.chatFriends[steamID.getSteamID64()] = persona;
|
self.chatFriends[steamID.getSteamID64()] = persona;
|
||||||
});
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|||||||
425
components/confirmations.js
Normal file
425
components/confirmations.js
Normal file
@@ -0,0 +1,425 @@
|
|||||||
|
var SteamCommunity = require('../index.js');
|
||||||
|
var Cheerio = require('cheerio');
|
||||||
|
var SteamTotp = require('steam-totp');
|
||||||
|
var Async = require('async');
|
||||||
|
|
||||||
|
var CConfirmation = require('../classes/CConfirmation.js');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of your account's currently outstanding confirmations.
|
||||||
|
* @param {int} time - The unix timestamp with which the following key was generated
|
||||||
|
* @param {string} key - The confirmation key that was generated using the preceeding time and the tag "conf" (this key can be reused)
|
||||||
|
* @param {SteamCommunity~getConfirmations} callback - Called when the list of confirmations is received
|
||||||
|
*/
|
||||||
|
SteamCommunity.prototype.getConfirmations = function(time, key, callback) {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
request(this, "conf", key, time, "conf", null, false, function(err, body) {
|
||||||
|
if(err) {
|
||||||
|
if (err.message == "Invalid protocol: steammobile:") {
|
||||||
|
err.message = "Not Logged In";
|
||||||
|
self._notifySessionExpired(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var $ = Cheerio.load(body);
|
||||||
|
var empty = $('#mobileconf_empty');
|
||||||
|
if(empty.length > 0) {
|
||||||
|
if(!$(empty).hasClass('mobileconf_done')) {
|
||||||
|
// An error occurred
|
||||||
|
callback(new Error(empty.find('div:nth-of-type(2)').text()));
|
||||||
|
} else {
|
||||||
|
callback(null, []);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We have something to confirm
|
||||||
|
var confirmations = $('#mobileconf_list');
|
||||||
|
if(!confirmations) {
|
||||||
|
callback(new Error("Malformed response"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var confs = [];
|
||||||
|
Array.prototype.forEach.call(confirmations.find('.mobileconf_list_entry'), function(conf) {
|
||||||
|
conf = $(conf);
|
||||||
|
|
||||||
|
var img = conf.find('.mobileconf_list_entry_icon img');
|
||||||
|
confs.push(new CConfirmation(self, {
|
||||||
|
"id": conf.data('confid'),
|
||||||
|
"type": conf.data('type'),
|
||||||
|
"creator": conf.data('creator'),
|
||||||
|
"key": conf.data('key'),
|
||||||
|
"title": conf.find('.mobileconf_list_entry_description>div:nth-of-type(1)').text().trim(),
|
||||||
|
"receiving": conf.find('.mobileconf_list_entry_description>div:nth-of-type(2)').text().trim(),
|
||||||
|
"time": conf.find('.mobileconf_list_entry_description>div:nth-of-type(3)').text().trim(),
|
||||||
|
"icon": img.length < 1 ? '' : $(img).attr('src')
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
callback(null, confs);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @callback SteamCommunity~getConfirmations
|
||||||
|
* @param {Error|null} err - An Error object on failure, or null on success
|
||||||
|
* @param {CConfirmation[]} confirmations - An array of CConfirmation objects
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the trade offer ID associated with a particular confirmation
|
||||||
|
* @param {int} confID - The ID of the confirmation in question
|
||||||
|
* @param {int} time - The unix timestamp with which the following key was generated
|
||||||
|
* @param {string} key - The confirmation key that was generated using the preceeding time and the tag "details" (this key can be reused)
|
||||||
|
* @param {SteamCommunity~getConfirmationOfferID} callback
|
||||||
|
*/
|
||||||
|
SteamCommunity.prototype.getConfirmationOfferID = function(confID, time, key, callback) {
|
||||||
|
request(this, "details/" + confID, key, time, "details", null, true, function(err, body) {
|
||||||
|
if(err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!body.success) {
|
||||||
|
callback(new Error("Cannot load confirmation details"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var $ = Cheerio.load(body.html);
|
||||||
|
var offer = $('.tradeoffer');
|
||||||
|
if(offer.length < 1) {
|
||||||
|
callback(null, null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(null, offer.attr('id').split('_')[1]);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @callback SteamCommunity~getConfirmationOfferID
|
||||||
|
* @param {Error|null} err - An Error object on failure, or null on success
|
||||||
|
* @param {string} offerID - The trade offer ID associated with the specified confirmation, or null if not for an offer
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Confirm or cancel a given confirmation.
|
||||||
|
* @param {int|int[]} confID - The ID of the confirmation in question, or an array of confirmation IDs
|
||||||
|
* @param {string|string[]} confKey - The confirmation key associated with the confirmation in question (or an array of them) (not a TOTP key, the `key` property of CConfirmation)
|
||||||
|
* @param {int} time - The unix timestamp with which the following key was generated
|
||||||
|
* @param {string} key - The confirmation key that was generated using the preceding time and the tag "allow" (if accepting) or "cancel" (if not accepting)
|
||||||
|
* @param {boolean} accept - true if you want to accept the confirmation, false if you want to cancel it
|
||||||
|
* @param {SteamCommunity~genericErrorCallback} callback - Called when the request is complete
|
||||||
|
*/
|
||||||
|
SteamCommunity.prototype.respondToConfirmation = function(confID, confKey, time, key, accept, callback) {
|
||||||
|
request(this, (confID instanceof Array) ? "multiajaxop" : "ajaxop", key, time, accept ? "allow" : "cancel", {
|
||||||
|
"op": accept ? "allow" : "cancel",
|
||||||
|
"cid": confID,
|
||||||
|
"ck": confKey
|
||||||
|
}, true, function(err, body) {
|
||||||
|
if(!callback) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(body.success) {
|
||||||
|
callback(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(body.message) {
|
||||||
|
callback(new Error(body.message));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(new Error("Could not act on confirmation"));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accept a confirmation for a given object (trade offer or market listing) automatically.
|
||||||
|
* @param {string} identitySecret
|
||||||
|
* @param {number|string} objectID
|
||||||
|
* @param {SteamCommunity~genericErrorCallback} callback
|
||||||
|
*/
|
||||||
|
SteamCommunity.prototype.acceptConfirmationForObject = function(identitySecret, objectID, callback) {
|
||||||
|
var self = this;
|
||||||
|
this._usedConfTimes = this._usedConfTimes || [];
|
||||||
|
|
||||||
|
if (typeof this._timeOffset !== 'undefined') {
|
||||||
|
// time offset is already known and saved
|
||||||
|
doConfirmation();
|
||||||
|
} else {
|
||||||
|
SteamTotp.getTimeOffset(function(err, offset) {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self._timeOffset = offset;
|
||||||
|
doConfirmation();
|
||||||
|
|
||||||
|
setTimeout(function() {
|
||||||
|
// Delete the saved time offset after 12 hours because why not
|
||||||
|
delete self._timeOffset;
|
||||||
|
}, 1000 * 60 * 60 * 12);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function doConfirmation() {
|
||||||
|
var offset = self._timeOffset;
|
||||||
|
var time = SteamTotp.time(offset);
|
||||||
|
self.getConfirmations(time, SteamTotp.getConfirmationKey(identitySecret, time, "conf"), function(err, confs) {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var conf = confs.filter(function(conf) { return conf.creator == objectID; });
|
||||||
|
if (conf.length == 0) {
|
||||||
|
callback(new Error("Could not find confirmation for object " + objectID));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
conf = conf[0];
|
||||||
|
|
||||||
|
// make sure we don't reuse the same time
|
||||||
|
var localOffset = 0;
|
||||||
|
do {
|
||||||
|
time = SteamTotp.time(offset) + localOffset++;
|
||||||
|
} while (self._usedConfTimes.indexOf(time) != -1);
|
||||||
|
|
||||||
|
self._usedConfTimes.push(time);
|
||||||
|
if (self._usedConfTimes.length > 60) {
|
||||||
|
self._usedConfTimes.splice(0, self._usedConfTimes.length - 60); // we don't need to save more than 60 entries
|
||||||
|
}
|
||||||
|
|
||||||
|
conf.respond(time, SteamTotp.getConfirmationKey(identitySecret, time, "allow"), true, callback);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a single request to Steam to accept all outstanding confirmations (after loading the list). If one fails, the
|
||||||
|
* entire request will fail and there will be no way to know which failed without loading the list again.
|
||||||
|
* @param {number} time
|
||||||
|
* @param {string} confKey
|
||||||
|
* @param {string} allowKey
|
||||||
|
* @param {function} callback
|
||||||
|
*/
|
||||||
|
SteamCommunity.prototype.acceptAllConfirmations = function(time, confKey, allowKey, callback) {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
this.getConfirmations(time, confKey, function(err, confs) {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (confs.length == 0) {
|
||||||
|
callback(null, []);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.respondToConfirmation(confs.map(function(conf) { return conf.id; }), confs.map(function(conf) { return conf.key; }), time, allowKey, true, function(err) {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(err, confs);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
function request(community, url, key, time, tag, params, json, callback) {
|
||||||
|
if (!community.steamID) {
|
||||||
|
throw new Error("Must be logged in before trying to do anything with confirmations");
|
||||||
|
}
|
||||||
|
|
||||||
|
params = params || {};
|
||||||
|
params.p = SteamTotp.getDeviceID(community.steamID);
|
||||||
|
params.a = community.steamID.getSteamID64();
|
||||||
|
params.k = key;
|
||||||
|
params.t = time;
|
||||||
|
params.m = "android";
|
||||||
|
params.tag = tag;
|
||||||
|
|
||||||
|
var req = {
|
||||||
|
"method": url == 'multiajaxop' ? 'POST' : 'GET',
|
||||||
|
"uri": "https://steamcommunity.com/mobileconf/" + url,
|
||||||
|
"json": !!json
|
||||||
|
};
|
||||||
|
|
||||||
|
if (req.method == "GET") {
|
||||||
|
req.qs = params;
|
||||||
|
} else {
|
||||||
|
req.form = params;
|
||||||
|
}
|
||||||
|
|
||||||
|
community.httpRequest(req, function(err, response, body) {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(null, body);
|
||||||
|
}, "steamcommunity");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Confirmation checker
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start automatically polling our confirmations for new ones. The `confKeyNeeded` event will be emitted when we need a confirmation key, or `newConfirmation` when we get a new confirmation
|
||||||
|
* @param {int} pollInterval - The interval, in milliseconds, at which we will poll for confirmations. This should probably be at least 10,000 to avoid rate-limits.
|
||||||
|
* @param {Buffer|string|null} [identitySecret=null] - Your identity_secret. If passed, all confirmations will be automatically accepted and nothing will be emitted.
|
||||||
|
*/
|
||||||
|
SteamCommunity.prototype.startConfirmationChecker = function(pollInterval, identitySecret) {
|
||||||
|
this._confirmationPollInterval = pollInterval;
|
||||||
|
this._knownConfirmations = this._knownConfirmations || {};
|
||||||
|
this._confirmationKeys = this._confirmationKeys || {};
|
||||||
|
this._identitySecret = identitySecret;
|
||||||
|
|
||||||
|
if(this._confirmationTimer) {
|
||||||
|
clearTimeout(this._confirmationTimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(this.checkConfirmations.bind(this), 500);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop automatically polling our confirmations.
|
||||||
|
*/
|
||||||
|
SteamCommunity.prototype.stopConfirmationChecker = function() {
|
||||||
|
if(this._confirmationPollInterval) {
|
||||||
|
delete this._confirmationPollInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this._identitySecret) {
|
||||||
|
delete this._identitySecret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this._confirmationTimer) {
|
||||||
|
clearTimeout(this._confirmationTimer);
|
||||||
|
delete this._confirmationTimer;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the confirmation checker right now instead of waiting for the next poll.
|
||||||
|
* Useful to call right after you send/accept an offer that needs confirmation.
|
||||||
|
*/
|
||||||
|
SteamCommunity.prototype.checkConfirmations = function() {
|
||||||
|
if(this._confirmationTimer) {
|
||||||
|
clearTimeout(this._confirmationTimer);
|
||||||
|
delete this._confirmationTimer;
|
||||||
|
}
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
if(!this._confirmationQueue) {
|
||||||
|
this._confirmationQueue = Async.queue(function(conf, callback) {
|
||||||
|
// Worker to process new confirmations
|
||||||
|
if(self._identitySecret) {
|
||||||
|
// We should accept this
|
||||||
|
self.emit('debug', "Accepting confirmation #" + conf.id);
|
||||||
|
var time = Math.floor(Date.now() / 1000);
|
||||||
|
conf.respond(time, SteamTotp.getConfirmationKey(self._identitySecret, time, "allow"), true, function(err) {
|
||||||
|
// If there was an error and it wasn't actually accepted, we'll pick it up again
|
||||||
|
if (!err) self.emit('confirmationAccepted', conf);
|
||||||
|
delete self._knownConfirmations[conf.id];
|
||||||
|
setTimeout(callback, 1000); // Call the callback in 1 second, to make sure the time changes
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
self.emit('newConfirmation', conf);
|
||||||
|
setTimeout(callback, 1000); // Call the callback in 1 second, to make sure the time changes
|
||||||
|
}
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.emit('debug', 'Checking confirmations');
|
||||||
|
|
||||||
|
this._confirmationCheckerGetKey('conf', function(err, key) {
|
||||||
|
if(err) {
|
||||||
|
resetTimer();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.getConfirmations(key.time, key.key, function(err, confirmations) {
|
||||||
|
if(err) {
|
||||||
|
self.emit('debug', "Can't check confirmations: " + err.message);
|
||||||
|
resetTimer();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var known = self._knownConfirmations;
|
||||||
|
|
||||||
|
var newOnes = confirmations.filter(function(conf) {
|
||||||
|
return !known[conf.id];
|
||||||
|
});
|
||||||
|
|
||||||
|
if(newOnes.length < 1) {
|
||||||
|
resetTimer();
|
||||||
|
return; // No new ones
|
||||||
|
}
|
||||||
|
|
||||||
|
// We have new confirmations!
|
||||||
|
newOnes.forEach(function(conf) {
|
||||||
|
self._knownConfirmations[conf.id] = conf; // Add it to our list of known confirmations
|
||||||
|
self._confirmationQueue.push(conf);
|
||||||
|
});
|
||||||
|
|
||||||
|
resetTimer();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function resetTimer() {
|
||||||
|
if(self._confirmationPollInterval) {
|
||||||
|
self._confirmationTimer = setTimeout(self.checkConfirmations.bind(self), self._confirmationPollInterval);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
SteamCommunity.prototype._confirmationCheckerGetKey = function(tag, callback) {
|
||||||
|
if(this._identitySecret) {
|
||||||
|
if(tag == 'details') {
|
||||||
|
// We don't care about details
|
||||||
|
callback(new Error("Disabled"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var time = Math.floor(Date.now() / 1000);
|
||||||
|
callback(null, {"time": time, "key": SteamTotp.getConfirmationKey(this._identitySecret, time, tag)});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var existing = this._confirmationKeys[tag];
|
||||||
|
var reusable = ['conf', 'details'];
|
||||||
|
|
||||||
|
// See if we already have a key that we can reuse.
|
||||||
|
if(reusable.indexOf(tag) != -1 && existing && (Date.now() - (existing.time * 1000) < (1000 * 60 * 5))) {
|
||||||
|
callback(null, existing);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We need a fresh one
|
||||||
|
var self = this;
|
||||||
|
this.emit('confKeyNeeded', tag, function(err, time, key) {
|
||||||
|
if(err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self._confirmationKeys[tag] = {"time": time, "key": key};
|
||||||
|
callback(null, {"time": time, "key": key});
|
||||||
|
});
|
||||||
|
};
|
||||||
@@ -2,6 +2,8 @@ var SteamCommunity = require('../index.js');
|
|||||||
var SteamID = require('steamid');
|
var SteamID = require('steamid');
|
||||||
var xml2js = require('xml2js');
|
var xml2js = require('xml2js');
|
||||||
var Cheerio = require('cheerio');
|
var Cheerio = require('cheerio');
|
||||||
|
var Helpers = require('./helpers.js');
|
||||||
|
var EResult = SteamCommunity.EResult;
|
||||||
|
|
||||||
SteamCommunity.prototype.getGroupMembers = function(gid, callback, members, link, addresses, addressIdx) {
|
SteamCommunity.prototype.getGroupMembers = function(gid, callback, members, link, addresses, addressIdx) {
|
||||||
members = members || [];
|
members = members || [];
|
||||||
@@ -38,8 +40,9 @@ SteamCommunity.prototype.getGroupMembers = function(gid, callback, members, link
|
|||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.request(options, function(err, response, body) {
|
this.httpRequest(options, function(err, response, body) {
|
||||||
if (self._checkHttpError(err, response, callback)) {
|
if (err) {
|
||||||
|
callback(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +63,7 @@ SteamCommunity.prototype.getGroupMembers = function(gid, callback, members, link
|
|||||||
callback(null, members);
|
callback(null, members);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
SteamCommunity.prototype.getGroupMembersEx = function(gid, addresses, callback) {
|
SteamCommunity.prototype.getGroupMembersEx = function(gid, addresses, callback) {
|
||||||
@@ -73,7 +76,7 @@ SteamCommunity.prototype.joinGroup = function(gid, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.request.post({
|
this.httpRequestPost({
|
||||||
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64(),
|
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64(),
|
||||||
"form": {
|
"form": {
|
||||||
"action": "join",
|
"action": "join",
|
||||||
@@ -84,17 +87,8 @@ SteamCommunity.prototype.joinGroup = function(gid, callback) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(err || response.statusCode >= 400) {
|
callback(err || null);
|
||||||
callback(err || new Error("HTTP error " + response.statusCode));
|
}, "steamcommunity");
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(self._checkCommunityError(body, callback)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
callback(null);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SteamCommunity.prototype.leaveGroup = function(gid, callback) {
|
SteamCommunity.prototype.leaveGroup = function(gid, callback) {
|
||||||
@@ -112,49 +106,140 @@ SteamCommunity.prototype.leaveGroup = function(gid, callback) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(err || response.statusCode >= 400) {
|
callback(err || null);
|
||||||
callback(err || new Error("HTTP error " + response.statusCode));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(self._checkCommunityError(body, callback)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
callback(null);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
SteamCommunity.prototype.postGroupAnnouncement = function(gid, headline, content, callback) {
|
SteamCommunity.prototype.getAllGroupAnnouncements = function(gid, time, callback) {
|
||||||
if(typeof gid === 'string') {
|
if(typeof gid === 'string') {
|
||||||
gid = new SteamID(gid);
|
gid = new SteamID(gid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(typeof time === 'function') {
|
||||||
|
callback = time;
|
||||||
|
time = new Date(0); // The beginnig of time...
|
||||||
|
}
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.request.post({
|
this.httpRequest({
|
||||||
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/announcements",
|
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/rss/"
|
||||||
"form": {
|
}, function(err, response, body) {
|
||||||
"sessionID": this.getSessionID(),
|
if (err) {
|
||||||
"action": "post",
|
callback(err);
|
||||||
"headline": headline,
|
return;
|
||||||
"body": content
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xml2js.parseString(body, function(err, results) {
|
||||||
|
if(err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!results.rss.channel[0].item) {
|
||||||
|
return callback(null, []);
|
||||||
|
}
|
||||||
|
|
||||||
|
var announcements = results.rss.channel[0].item.map(function(announcement) {
|
||||||
|
var splitLink = announcement.link[0].split('/');
|
||||||
|
return {
|
||||||
|
headline: announcement.title[0],
|
||||||
|
content: announcement.description[0],
|
||||||
|
date: new Date(announcement.pubDate[0]),
|
||||||
|
author: (typeof announcement.author === 'undefined') ? null : announcement.author[0],
|
||||||
|
aid: splitLink[splitLink.length - 1]
|
||||||
|
}
|
||||||
|
}).filter(function(announcement) {
|
||||||
|
return (announcement.date > time);
|
||||||
|
});
|
||||||
|
|
||||||
|
return callback(null, announcements);
|
||||||
|
});
|
||||||
|
}, "steamcommunity");
|
||||||
|
};
|
||||||
|
|
||||||
|
SteamCommunity.prototype.postGroupAnnouncement = function(gid, headline, content, hidden, callback) {
|
||||||
|
if(typeof gid === 'string') {
|
||||||
|
gid = new SteamID(gid);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(typeof hidden === 'function') {
|
||||||
|
callback = hidden;
|
||||||
|
hidden = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
var form = {
|
||||||
|
"sessionID": this.getSessionID(),
|
||||||
|
"action": "post",
|
||||||
|
"headline": headline,
|
||||||
|
"body": content,
|
||||||
|
"languages[0][headline]": headline,
|
||||||
|
"languages[0][body]": content
|
||||||
|
};
|
||||||
|
|
||||||
|
if(hidden) {
|
||||||
|
form.is_hidden = "is_hidden"
|
||||||
|
}
|
||||||
|
|
||||||
|
this.httpRequestPost({
|
||||||
|
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/announcements",
|
||||||
|
form
|
||||||
}, function(err, response, body) {
|
}, function(err, response, body) {
|
||||||
if(!callback) {
|
if(!callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(err || response.statusCode >= 400) {
|
callback(err || null);
|
||||||
callback(err || new Error("HTTP error " + response.statusCode));
|
}, "steamcommunity");
|
||||||
|
};
|
||||||
|
|
||||||
|
SteamCommunity.prototype.editGroupAnnouncement = function(gid, aid, headline, content, callback) {
|
||||||
|
if(typeof gid === 'string') {
|
||||||
|
gid = new SteamID(gid);
|
||||||
|
}
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
var submitData = {
|
||||||
|
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/announcements",
|
||||||
|
"form": {
|
||||||
|
"sessionID": this.getSessionID(),
|
||||||
|
"gid": aid,
|
||||||
|
"action": "update",
|
||||||
|
"headline": headline,
|
||||||
|
"body": content,
|
||||||
|
"languages[0][headline]": headline,
|
||||||
|
"languages[0][body]": content,
|
||||||
|
"languages[0][updated]": 1
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.httpRequestPost(submitData, function(err, response, body) {
|
||||||
|
if(!callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(self._checkCommunityError(body, callback)) {
|
callback(err || null);
|
||||||
|
}, "steamcommunity");
|
||||||
|
};
|
||||||
|
|
||||||
|
SteamCommunity.prototype.deleteGroupAnnouncement = function(gid, aid, callback) {
|
||||||
|
if(typeof gid === 'string') {
|
||||||
|
gid = new SteamID(gid);
|
||||||
|
}
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
var submitData = {
|
||||||
|
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/announcements/delete/" + aid + "?sessionID=" + this.getSessionID()
|
||||||
|
};
|
||||||
|
|
||||||
|
this.httpRequestGet(submitData, function(err, response, body) {
|
||||||
|
if(!callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null);
|
callback(err || null);
|
||||||
})
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
SteamCommunity.prototype.scheduleGroupEvent = function(gid, name, type, description, time, server, callback) {
|
SteamCommunity.prototype.scheduleGroupEvent = function(gid, name, type, description, time, server, callback) {
|
||||||
@@ -170,7 +255,7 @@ SteamCommunity.prototype.scheduleGroupEvent = function(gid, name, type, descript
|
|||||||
server = {"ip": "", "password": ""};
|
server = {"ip": "", "password": ""};
|
||||||
} else if(typeof server === 'string') {
|
} else if(typeof server === 'string') {
|
||||||
server = {"ip": server, "password": ""};
|
server = {"ip": server, "password": ""};
|
||||||
} else {
|
} else if(typeof server !== 'object') {
|
||||||
server = {"ip": "", "password": ""};
|
server = {"ip": "", "password": ""};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,25 +287,98 @@ SteamCommunity.prototype.scheduleGroupEvent = function(gid, name, type, descript
|
|||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.request.post({
|
this.httpRequestPost({
|
||||||
"uri": "https://steamcommunity.com/gid/" + this.steamID.toString() + "/eventEdit",
|
"uri": "https://steamcommunity.com/gid/" + gid.toString() + "/eventEdit",
|
||||||
"form": form
|
"form": form
|
||||||
}, function(err, response, body) {
|
}, function(err, response, body) {
|
||||||
if(!callback) {
|
if(!callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(err || response.statusCode >= 400) {
|
callback(err || null);
|
||||||
callback(err || new Error("HTTP error " + response.statusCode));
|
}, "steamcommunity");
|
||||||
|
};
|
||||||
|
|
||||||
|
SteamCommunity.prototype.editGroupEvent = function (gid, id, name, type, description, time, server, callback) {
|
||||||
|
if (typeof gid === 'string') {
|
||||||
|
gid = new SteamID(gid);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Event types: ChatEvent - Chat, OtherEvent - A lil somethin somethin, PartyEvent - Party!, MeetingEvent - Important meeting, SpecialCauseEvent - Special cause (charity ball?), MusicAndArtsEvent - Music or Art type thing, SportsEvent - Sporting endeavor, TripEvent - Out of town excursion
|
||||||
|
// Passing a number for type will make it a game event for that appid
|
||||||
|
|
||||||
|
if (typeof server === 'function') {
|
||||||
|
callback = server;
|
||||||
|
server = {"ip": "", "password": ""};
|
||||||
|
} else if (typeof server === 'string') {
|
||||||
|
server = {"ip": server, "password": ""};
|
||||||
|
} else if (typeof server !== 'object') {
|
||||||
|
server = {"ip": "", "password": ""};
|
||||||
|
}
|
||||||
|
|
||||||
|
var form = {
|
||||||
|
"sessionid": this.getSessionID(),
|
||||||
|
"action": "updateEvent",
|
||||||
|
"eventID": id,
|
||||||
|
"tzOffset": new Date().getTimezoneOffset() * -60,
|
||||||
|
"name": name,
|
||||||
|
"type": (typeof type === 'number' || !isNaN(parseInt(type, 10)) ? "GameEvent" : type),
|
||||||
|
"appID": (typeof type === 'number' || !isNaN(parseInt(type, 10)) ? type : ''),
|
||||||
|
"serverIP": server.ip,
|
||||||
|
"serverPassword": server.password,
|
||||||
|
"notes": description,
|
||||||
|
"eventQuickTime": "now"
|
||||||
|
};
|
||||||
|
|
||||||
|
if (time === null) {
|
||||||
|
form.startDate = 'MM/DD/YY';
|
||||||
|
form.startHour = '12';
|
||||||
|
form.startMinute = '00';
|
||||||
|
form.startAMPM = 'PM';
|
||||||
|
form.timeChoice = 'quick';
|
||||||
|
} else {
|
||||||
|
form.startDate = (time.getMonth() + 1 < 10 ? '0' : '') + (time.getMonth() + 1) + '/' + (time.getDate() < 10 ? '0' : '') + time.getDate() + '/' + time.getFullYear().toString().substring(2);
|
||||||
|
form.startHour = (time.getHours() === 0 ? '12' : (time.getHours() > 12 ? time.getHours() - 12 : time.getHours()));
|
||||||
|
form.startMinute = (time.getMinutes() < 10 ? '0' : '') + time.getMinutes();
|
||||||
|
form.startAMPM = (time.getHours() <= 12 ? 'AM' : 'PM');
|
||||||
|
form.timeChoice = 'specific';
|
||||||
|
}
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
this.httpRequestPost({
|
||||||
|
"uri": "https://steamcommunity.com/gid/" + gid.toString() + "/eventEdit",
|
||||||
|
"form": form
|
||||||
|
}, function(err, response, body) {
|
||||||
|
if(!callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(self._checkCommunityError(body, callback)) {
|
callback(err || null);
|
||||||
|
}, "steamcommunity");
|
||||||
|
};
|
||||||
|
|
||||||
|
SteamCommunity.prototype.deleteGroupEvent = function(gid, id, callback) {
|
||||||
|
if (typeof gid === 'string') {
|
||||||
|
gid = new SteamID(gid);
|
||||||
|
}
|
||||||
|
|
||||||
|
var form = {
|
||||||
|
"sessionid": this.getSessionID(),
|
||||||
|
"action": "deleteEvent",
|
||||||
|
"eventID": id
|
||||||
|
};
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
this.httpRequestPost({
|
||||||
|
"uri": "https://steamcommunity.com/gid/" + gid.toString() + "/eventEdit",
|
||||||
|
"form": form
|
||||||
|
}, function(err, response, body) {
|
||||||
|
if(!callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null);
|
callback(err || null);
|
||||||
});
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
SteamCommunity.prototype.setGroupPlayerOfTheWeek = function(gid, steamID, callback) {
|
SteamCommunity.prototype.setGroupPlayerOfTheWeek = function(gid, steamID, callback) {
|
||||||
@@ -233,7 +391,7 @@ SteamCommunity.prototype.setGroupPlayerOfTheWeek = function(gid, steamID, callba
|
|||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.request.post({
|
this.httpRequestPost({
|
||||||
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/potwEdit",
|
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/potwEdit",
|
||||||
"form": {
|
"form": {
|
||||||
"xml": 1,
|
"xml": 1,
|
||||||
@@ -263,7 +421,7 @@ SteamCommunity.prototype.setGroupPlayerOfTheWeek = function(gid, steamID, callba
|
|||||||
callback(new Error(results.response.results[0]));
|
callback(new Error(results.response.results[0]));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
SteamCommunity.prototype.kickGroupMember = function(gid, steamID, callback) {
|
SteamCommunity.prototype.kickGroupMember = function(gid, steamID, callback) {
|
||||||
@@ -276,7 +434,7 @@ SteamCommunity.prototype.kickGroupMember = function(gid, steamID, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.request.post({
|
this.httpRequestPost({
|
||||||
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/membersManage",
|
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/membersManage",
|
||||||
"form": {
|
"form": {
|
||||||
"sessionID": this.getSessionID(),
|
"sessionID": this.getSessionID(),
|
||||||
@@ -289,17 +447,8 @@ SteamCommunity.prototype.kickGroupMember = function(gid, steamID, callback) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(err || response.statusCode >= 400) {
|
callback(err || null);
|
||||||
callback(err || new Error("HTTP error " + response.statusCode));
|
}, "steamcommunity");
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(self._checkCommunityError(body, callback)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
callback(null);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SteamCommunity.prototype.getGroupHistory = function(gid, page, callback) {
|
SteamCommunity.prototype.getGroupHistory = function(gid, page, callback) {
|
||||||
@@ -313,12 +462,9 @@ SteamCommunity.prototype.getGroupHistory = function(gid, page, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.request("https://steamcommunity.com/gid/" + gid.getSteamID64() + "/history?p=" + page, function(err, response, body) {
|
this.httpRequest("https://steamcommunity.com/gid/" + gid.getSteamID64() + "/history?p=" + page, function(err, response, body) {
|
||||||
if(self._checkHttpError(err, response, callback)) {
|
if (err) {
|
||||||
return;
|
callback(err);
|
||||||
}
|
|
||||||
|
|
||||||
if(self._checkCommunityError(body, callback)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,7 +506,7 @@ SteamCommunity.prototype.getGroupHistory = function(gid, page, callback) {
|
|||||||
sid.universe = SteamID.Universe.PUBLIC;
|
sid.universe = SteamID.Universe.PUBLIC;
|
||||||
sid.type = SteamID.Type.INDIVIDUAL;
|
sid.type = SteamID.Type.INDIVIDUAL;
|
||||||
sid.instance = SteamID.Instance.DESKTOP;
|
sid.instance = SteamID.Instance.DESKTOP;
|
||||||
sid.accountid = $(users[0]).data('miniprofile');
|
sid.accountid = $(users[1]).data('miniprofile');
|
||||||
data.actor = sid;
|
data.actor = sid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,5 +528,205 @@ SteamCommunity.prototype.getGroupHistory = function(gid, page, callback) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
callback(null, output);
|
callback(null, output);
|
||||||
});
|
}, "steamcommunity");
|
||||||
|
};
|
||||||
|
|
||||||
|
SteamCommunity.prototype.getAllGroupComments = function(gid, from, count, callback) {
|
||||||
|
if (typeof gid === 'string') {
|
||||||
|
gid = new SteamID(gid);
|
||||||
|
}
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
"uri": "https://steamcommunity.com/comment/Clan/render/" + gid.getSteamID64() + "/-1/",
|
||||||
|
"form": {
|
||||||
|
"start": from,
|
||||||
|
"count": count
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
this.httpRequestPost(options, function(err, response, body) {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var comments = [];
|
||||||
|
|
||||||
|
var $ = Cheerio.load(JSON.parse(body).comments_html);
|
||||||
|
|
||||||
|
$(".commentthread_comment_content").each(function () {
|
||||||
|
var comment = {};
|
||||||
|
var cachedSelector;
|
||||||
|
|
||||||
|
var $selector = $(this).find(".commentthread_author_link");
|
||||||
|
comment.authorName = $($selector).find("bdi").text();
|
||||||
|
comment.authorId = $($selector).attr("href").replace(/https?:\/\/steamcommunity.com\/(id|profiles)\//, "");
|
||||||
|
comment.date = Helpers.decodeSteamTime($(this).find(".commentthread_comment_timestamp").text().trim());
|
||||||
|
|
||||||
|
$selector = $(this).find(".commentthread_comment_text");
|
||||||
|
comment.commentId = $($selector).attr("id").replace("comment_content_", "");
|
||||||
|
comment.text = $($selector).html().trim();
|
||||||
|
|
||||||
|
comments.push(comment);
|
||||||
|
});
|
||||||
|
|
||||||
|
callback(null, comments);
|
||||||
|
}, "steamcommunity");
|
||||||
|
};
|
||||||
|
|
||||||
|
SteamCommunity.prototype.deleteGroupComment = function(gid, cid, callback) {
|
||||||
|
if (typeof gid === 'string') {
|
||||||
|
gid = new SteamID(gid);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof cid !== 'string') {
|
||||||
|
cid = cid.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
"uri": "https://steamcommunity.com/comment/Clan/delete/" + gid.getSteamID64() + "/-1/",
|
||||||
|
"form": {
|
||||||
|
"sessionid": this.getSessionID(),
|
||||||
|
"gidcomment": cid
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
this.httpRequestPost(options, function(err, response, body) {
|
||||||
|
if(!callback) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(err || null);
|
||||||
|
}, "steamcommunity");
|
||||||
|
};
|
||||||
|
|
||||||
|
SteamCommunity.prototype.postGroupComment = function(gid, message, callback) {
|
||||||
|
if (typeof gid === 'string') {
|
||||||
|
gid = new SteamID(gid);
|
||||||
|
}
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
"uri": "https://steamcommunity.com/comment/Clan/post/" + gid.getSteamID64() + "/-1/",
|
||||||
|
"form": {
|
||||||
|
"comment": message,
|
||||||
|
"count": 6,
|
||||||
|
"sessionid": this.getSessionID()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
this.httpRequestPost(options, function(err, response, body) {
|
||||||
|
if(!callback) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(err || null);
|
||||||
|
}, "steamcommunity");
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get requests to join a restricted group.
|
||||||
|
* @param {SteamID|string} gid - The SteamID of the group you want to manage
|
||||||
|
* @param {function} callback - First argument is null/Error, second is array of SteamID objects
|
||||||
|
*/
|
||||||
|
SteamCommunity.prototype.getGroupJoinRequests = function(gid, callback) {
|
||||||
|
if (typeof gid === 'string') {
|
||||||
|
gid = new SteamID(gid);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.httpRequestGet("https://steamcommunity.com/gid/" + gid.getSteamID64() + "/joinRequestsManage", (err, res, body) => {
|
||||||
|
if (!body) {
|
||||||
|
callback(new Error("Malformed response"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var matches = body.match(/JoinRequests_ApproveDenyUser\(\W*['"](\d+)['"],\W0\W\)/g);
|
||||||
|
if (!matches) {
|
||||||
|
// no pending requests
|
||||||
|
callback(null, []);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var requests = [];
|
||||||
|
for (var i = 0; i < matches.length; i++) {
|
||||||
|
requests.push(new SteamID("[U:1:" + matches[i].match(/JoinRequests_ApproveDenyUser\(\W*['"](\d+)['"],\W0\W\)/)[1] + "]"));
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(null, requests);
|
||||||
|
}, "steamcommunity");
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Respond to one or more join requests to a restricted group.
|
||||||
|
* @param {SteamID|string} gid - The SteamID of the group you want to manage
|
||||||
|
* @param {SteamID|string|SteamID[]|string[]} steamIDs - The SteamIDs of the users you want to approve or deny membership for (or a single value)
|
||||||
|
* @param {boolean} approve - True to put them in the group, false to deny their membership
|
||||||
|
* @param {function} callback - Takes only an Error object/null as the first argument
|
||||||
|
*/
|
||||||
|
SteamCommunity.prototype.respondToGroupJoinRequests = function(gid, steamIDs, approve, callback) {
|
||||||
|
if (typeof gid === 'string') {
|
||||||
|
gid = new SteamID(gid);
|
||||||
|
}
|
||||||
|
|
||||||
|
var rgAccounts = (!Array.isArray(steamIDs) ? [steamIDs] : steamIDs).map(sid => sid.toString());
|
||||||
|
|
||||||
|
this.httpRequestPost({
|
||||||
|
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/joinRequestsManage",
|
||||||
|
"form": {
|
||||||
|
"rgAccounts": rgAccounts,
|
||||||
|
"bapprove": approve ? "1" : "0",
|
||||||
|
"json": "1",
|
||||||
|
"sessionID": this.getSessionID()
|
||||||
|
},
|
||||||
|
"json": true
|
||||||
|
}, (err, res, body) => {
|
||||||
|
if (!callback) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body != EResult.OK) {
|
||||||
|
var err = new Error(EResult[body] || ("Error " + body));
|
||||||
|
err.eresult = body;
|
||||||
|
callback(err);
|
||||||
|
} else {
|
||||||
|
callback(null);
|
||||||
|
}
|
||||||
|
}, "steamcommunity");
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Respond to *ALL* pending group-join requests for a particular group.
|
||||||
|
* @param {SteamID|string} gid - The SteamID of the group you want to manage
|
||||||
|
* @param {boolean} approve - True to allow everyone who requested into the group, false to not
|
||||||
|
* @param {function} callback - Takes only an Error object/null as the first argument
|
||||||
|
*/
|
||||||
|
SteamCommunity.prototype.respondToAllGroupJoinRequests = function(gid, approve, callback) {
|
||||||
|
if (typeof gid === 'string') {
|
||||||
|
gid = new SteamID(gid);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.httpRequestPost({
|
||||||
|
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/joinRequestsManage",
|
||||||
|
"form": {
|
||||||
|
"bapprove": approve ? "1" : "0",
|
||||||
|
"json": "1",
|
||||||
|
"action": "bulkrespond",
|
||||||
|
"sessionID": this.getSessionID()
|
||||||
|
},
|
||||||
|
"json": true
|
||||||
|
}, (err, res, body) => {
|
||||||
|
if (!callback) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body != EResult.OK) {
|
||||||
|
var err = new Error(EResult[body] || ("Error " + body));
|
||||||
|
err.eresult = body;
|
||||||
|
callback(err);
|
||||||
|
} else {
|
||||||
|
callback(null);
|
||||||
|
}
|
||||||
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|||||||
56
components/helpers.js
Normal file
56
components/helpers.js
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
const EResult = require('../resources/EResult.js');
|
||||||
|
|
||||||
|
exports.isSteamID = function(input) {
|
||||||
|
var keys = Object.keys(input);
|
||||||
|
if (keys.length != 4) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure it has the keys we expect
|
||||||
|
keys = keys.filter(function(item) {
|
||||||
|
return ['universe', 'type', 'instance', 'accountid'].indexOf(item) != -1;
|
||||||
|
});
|
||||||
|
|
||||||
|
return keys.length == 4;
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.decodeSteamTime = function(time) {
|
||||||
|
var date = new Date();
|
||||||
|
|
||||||
|
if (time.includes("@")) {
|
||||||
|
var parts = time.split('@');
|
||||||
|
if (!parts[0].includes(",")) {
|
||||||
|
// no year, assume current year
|
||||||
|
parts[0] += ", " + date.getFullYear();
|
||||||
|
}
|
||||||
|
|
||||||
|
date = new Date(parts.join('@').replace(/(am|pm)/, ' $1') + " UTC"); // add a space so JS can decode it
|
||||||
|
} else {
|
||||||
|
// Relative date
|
||||||
|
var amount = time.replace(/(\d) (minutes|hour|hours) ago/, "$1");
|
||||||
|
|
||||||
|
if(time.includes("minutes")) {
|
||||||
|
date.setMinutes(date.getMinutes() - amount);
|
||||||
|
} else if(time.match(/hour|hours/)) {
|
||||||
|
date.setHours(date.getHours() - amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return date;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an Error object for a particular EResult
|
||||||
|
* @param {int} eresult
|
||||||
|
* @returns {null|Error}
|
||||||
|
*/
|
||||||
|
exports.eresultError = function(eresult) {
|
||||||
|
if (eresult == EResult.OK) {
|
||||||
|
// no error
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var err = new Error(EResult[eresult] || ("Error " + eresult));
|
||||||
|
err.eresult = eresult;
|
||||||
|
return err;
|
||||||
|
};
|
||||||
150
components/http.js
Normal file
150
components/http.js
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
var SteamCommunity = require('../index.js');
|
||||||
|
|
||||||
|
SteamCommunity.prototype.httpRequest = function(uri, options, callback, source) {
|
||||||
|
if (typeof uri === 'object') {
|
||||||
|
source = callback;
|
||||||
|
callback = options;
|
||||||
|
options = uri;
|
||||||
|
uri = options.url || options.uri;
|
||||||
|
} else if (typeof options === 'function') {
|
||||||
|
source = callback;
|
||||||
|
callback = options;
|
||||||
|
options = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
options.url = options.uri = uri;
|
||||||
|
|
||||||
|
if (this._httpRequestConvenienceMethod) {
|
||||||
|
options.method = this._httpRequestConvenienceMethod;
|
||||||
|
delete this._httpRequestConvenienceMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
var requestID = ++this._httpRequestID;
|
||||||
|
source = source || "";
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
var continued = false;
|
||||||
|
|
||||||
|
if (!this.onPreHttpRequest || !this.onPreHttpRequest(requestID, source, options, continueRequest)) {
|
||||||
|
// No pre-hook, or the pre-hook doesn't want to delay the request.
|
||||||
|
continueRequest(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
function continueRequest(err) {
|
||||||
|
if (continued) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
continued = true;
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
if (callback) {
|
||||||
|
callback(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.request(options, function (err, response, body) {
|
||||||
|
var hasCallback = !!callback;
|
||||||
|
var httpError = options.checkHttpError !== false && self._checkHttpError(err, response, callback, body);
|
||||||
|
var communityError = !options.json && options.checkCommunityError !== false && self._checkCommunityError(body, httpError ? function () {} : callback); // don't fire the callback if hasHttpError did it already
|
||||||
|
var tradeError = !options.json && options.checkTradeError !== false && self._checkTradeError(body, httpError || communityError ? function () {} : callback); // don't fire the callback if either of the previous already did
|
||||||
|
var jsonError = options.json && options.checkJsonError !== false && !body ? new Error("Malformed JSON response") : null;
|
||||||
|
|
||||||
|
self.emit('postHttpRequest', requestID, source, options, httpError || communityError || tradeError || jsonError || null, response, body, {
|
||||||
|
"hasCallback": hasCallback,
|
||||||
|
"httpError": httpError,
|
||||||
|
"communityError": communityError,
|
||||||
|
"tradeError": tradeError,
|
||||||
|
"jsonError": jsonError
|
||||||
|
});
|
||||||
|
|
||||||
|
if (hasCallback && !(httpError || communityError || tradeError)) {
|
||||||
|
if (jsonError) {
|
||||||
|
callback.call(self, jsonError, response);
|
||||||
|
} else {
|
||||||
|
callback.apply(self, arguments);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
SteamCommunity.prototype.httpRequestGet = function() {
|
||||||
|
this._httpRequestConvenienceMethod = "GET";
|
||||||
|
return this.httpRequest.apply(this, arguments);
|
||||||
|
};
|
||||||
|
|
||||||
|
SteamCommunity.prototype.httpRequestPost = function() {
|
||||||
|
this._httpRequestConvenienceMethod = "POST";
|
||||||
|
return this.httpRequest.apply(this, arguments);
|
||||||
|
};
|
||||||
|
|
||||||
|
SteamCommunity.prototype._notifySessionExpired = function(err) {
|
||||||
|
this.emit('sessionExpired', err);
|
||||||
|
};
|
||||||
|
|
||||||
|
SteamCommunity.prototype._checkHttpError = function(err, response, callback, body) {
|
||||||
|
if (err) {
|
||||||
|
callback(err, response, body);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response.statusCode >= 300 && response.statusCode <= 399 && response.headers.location.indexOf('/login') != -1) {
|
||||||
|
err = new Error("Not Logged In");
|
||||||
|
callback(err, response, body);
|
||||||
|
this._notifySessionExpired(err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response.statusCode == 403 && typeof response.body === 'string' && response.body.match(/<div id="parental_notice_instructions">Enter your PIN below to exit Family View.<\/div>/)) {
|
||||||
|
err = new Error("Family View Restricted");
|
||||||
|
callback(err, response, body);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response.statusCode >= 400) {
|
||||||
|
err = new Error("HTTP error " + response.statusCode);
|
||||||
|
err.code = response.statusCode;
|
||||||
|
callback(err, response, body);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
SteamCommunity.prototype._checkCommunityError = function(html, callback) {
|
||||||
|
var err;
|
||||||
|
|
||||||
|
if(typeof html === 'string' && html.match(/<h1>Sorry!<\/h1>/)) {
|
||||||
|
var match = html.match(/<h3>(.+)<\/h3>/);
|
||||||
|
err = new Error(match ? match[1] : "Unknown error occurred");
|
||||||
|
callback(err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof html === 'string' && html.match(/g_steamID = false;/) && html.match(/<h1>Sign In<\/h1>/)) {
|
||||||
|
err = new Error("Not Logged In");
|
||||||
|
callback(err);
|
||||||
|
this._notifySessionExpired(err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
SteamCommunity.prototype._checkTradeError = function(html, callback) {
|
||||||
|
if (typeof html !== 'string') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var match = html.match(/<div id="error_msg">\s*([^<]+)\s*<\/div>/);
|
||||||
|
if (match) {
|
||||||
|
var err = new Error(match[1].trim());
|
||||||
|
callback(err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
@@ -5,137 +5,184 @@ var request = require('request');
|
|||||||
var Cheerio = require('cheerio');
|
var Cheerio = require('cheerio');
|
||||||
var Async = require('async');
|
var Async = require('async');
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Inventory history in a nutshell.
|
||||||
|
*
|
||||||
|
* There are no more page numbers. Now you have to request after_time and optionally after_trade.
|
||||||
|
* Without "prev" set, you will request 30 trades that were completed FURTHER IN THE PAST than after_time (and optionally after_trade)
|
||||||
|
* With "prev" set, you will request 30 trades that were completed MORE RECENTLY than after_time (and optionally after_trade)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use GetTradeHistory instead: https://lab.xpaw.me/steam_api_documentation.html#IEconService_GetTradeHistory_v1
|
||||||
|
* @param {object} options
|
||||||
|
* @param {function} callback
|
||||||
|
*/
|
||||||
SteamCommunity.prototype.getInventoryHistory = function(options, callback) {
|
SteamCommunity.prototype.getInventoryHistory = function(options, callback) {
|
||||||
if(typeof options === 'function') {
|
if (typeof options === 'function') {
|
||||||
callback = options;
|
callback = options;
|
||||||
options = {};
|
options = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
options.page = options.page || 1;
|
options.direction = options.direction || "past";
|
||||||
|
|
||||||
this.request("https://steamcommunity.com/my/inventoryhistory?l=english&p=" + options.page, function(err, response, body) {
|
var qs = "?l=english";
|
||||||
if(err) {
|
if (options.startTime) {
|
||||||
|
if (options.startTime instanceof Date) {
|
||||||
|
options.startTime = Math.floor(options.startTime.getTime() / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
qs += "&after_time=" + options.startTime;
|
||||||
|
|
||||||
|
if (options.startTrade) {
|
||||||
|
qs += "&after_trade=" + options.startTrade;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.direction == "future") {
|
||||||
|
qs += "&prev=1";
|
||||||
|
}
|
||||||
|
|
||||||
|
this._myProfile("inventoryhistory" + qs, null, function(err, response, body) {
|
||||||
|
if (err) {
|
||||||
callback(err);
|
callback(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var output = {};
|
var output = {};
|
||||||
var vanityURLs = [];
|
var vanityURLs = [];
|
||||||
|
|
||||||
var $ = Cheerio.load(body);
|
var $ = Cheerio.load(body);
|
||||||
var html = $('.inventory_history_pagingrow').html();
|
if (!$('.inventory_history_pagingrow').html()) {
|
||||||
if(!html) {
|
callback(new Error("Malformed page: no paging row found"));
|
||||||
callback("Malformed page: no paging row found");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var match = html.match(/(\d+) - (\d+) of (\d+) History Items/);
|
|
||||||
|
|
||||||
output.first = parseInt(match[1], 10);
|
|
||||||
output.last = parseInt(match[2], 10);
|
|
||||||
output.totalTrades = parseInt(match[3], 10);
|
|
||||||
|
|
||||||
// Load the inventory item data
|
// Load the inventory item data
|
||||||
var match2 = body.match(/var g_rgHistoryInventory = (.*);/);
|
var match2 = body.match(/var g_rgHistoryInventory = (.*);/);
|
||||||
if(!match2) {
|
if (!match2) {
|
||||||
callback(new Error("Malformed page: no trade found"));
|
callback(new Error("Malformed page: no trade found"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var historyInventory = JSON.parse(match2[1]);
|
|
||||||
|
try {
|
||||||
|
var historyInventory = JSON.parse(match2[1]);
|
||||||
|
} catch (ex) {
|
||||||
|
callback(new Error("Malformed page: no well-formed trade data found"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var i;
|
||||||
|
|
||||||
|
// See if we've got paging buttons
|
||||||
|
var $paging = $('.inventory_history_nextbtn .pagebtn:not(.disabled)');
|
||||||
|
var href;
|
||||||
|
for (i = 0; i < $paging.length; i++) {
|
||||||
|
href = $paging[i].attribs.href;
|
||||||
|
if (href.match(/prev=1/)) {
|
||||||
|
output.firstTradeTime = new Date(href.match(/after_time=(\d+)/)[1] * 1000);
|
||||||
|
output.firstTradeID = href.match(/after_trade=(\d+)/)[1];
|
||||||
|
} else {
|
||||||
|
output.lastTradeTime = new Date(href.match(/after_time=(\d+)/)[1] * 1000);
|
||||||
|
output.lastTradeID = href.match(/after_trade=(\d+)/)[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
output.trades = [];
|
output.trades = [];
|
||||||
var trades = $('.tradehistoryrow');
|
var trades = $('.tradehistoryrow');
|
||||||
|
|
||||||
var item, trade, profileLink, items, j, econItem, timeMatch, time;
|
var item, trade, profileLink, items, j, econItem, timeMatch, time;
|
||||||
for(var i = 0; i < trades.length; i++) {
|
for (i = 0; i < trades.length; i++) {
|
||||||
item = $(trades[i]);
|
item = $(trades[i]);
|
||||||
trade = {};
|
trade = {};
|
||||||
|
|
||||||
|
trade.onHold = !!item.find('span:nth-of-type(2)').text().match(/Trade on Hold/i);
|
||||||
|
|
||||||
timeMatch = item.find('.tradehistory_timestamp').html().match(/(\d+):(\d+)(am|pm)/);
|
timeMatch = item.find('.tradehistory_timestamp').html().match(/(\d+):(\d+)(am|pm)/);
|
||||||
if(timeMatch[1] == 12 && timeMatch[3] == 'am') {
|
if (timeMatch[1] == 12 && timeMatch[3] == 'am') {
|
||||||
timeMatch[1] = 0;
|
timeMatch[1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(timeMatch[1] < 12 && timeMatch[3] == 'pm') {
|
if (timeMatch[1] < 12 && timeMatch[3] == 'pm') {
|
||||||
timeMatch[1] = parseInt(timeMatch[1], 10) + 12;
|
timeMatch[1] = parseInt(timeMatch[1], 10) + 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
time = (timeMatch[1] < 10 ? '0' : '') + timeMatch[1] + ':' + timeMatch[2] + ':00';
|
time = (timeMatch[1] < 10 ? '0' : '') + timeMatch[1] + ':' + timeMatch[2] + ':00';
|
||||||
|
|
||||||
trade.date = new Date(item.find('.tradehistory_date').html() + ' ' + time);
|
trade.date = new Date(item.find('.tradehistory_date').html() + ' ' + time + ' UTC');
|
||||||
trade.partnerName = item.find('.tradehistory_event_description a').html();
|
trade.partnerName = item.find('.tradehistory_event_description a').html();
|
||||||
trade.partnerSteamID = null;
|
trade.partnerSteamID = null;
|
||||||
trade.partnerVanityURL = null;
|
trade.partnerVanityURL = null;
|
||||||
trade.itemsReceived = [];
|
trade.itemsReceived = [];
|
||||||
trade.itemsGiven = [];
|
trade.itemsGiven = [];
|
||||||
|
|
||||||
profileLink = item.find('.tradehistory_event_description a').attr('href');
|
profileLink = item.find('.tradehistory_event_description a').attr('href');
|
||||||
if(profileLink.indexOf('/profiles/') != -1) {
|
if (profileLink.indexOf('/profiles/') != -1) {
|
||||||
trade.partnerSteamID = new SteamID(profileLink.match(/(\d+)$/)[1]);
|
trade.partnerSteamID = new SteamID(profileLink.match(/(\d+)$/)[1]);
|
||||||
} else {
|
} else {
|
||||||
trade.partnerVanityURL = profileLink.match(/\/([^\/]+)$/)[1];
|
trade.partnerVanityURL = profileLink.match(/\/([^\/]+)$/)[1];
|
||||||
if(options.resolveVanityURLs && vanityURLs.indexOf(trade.partnerVanityURL) == -1) {
|
if (options.resolveVanityURLs && vanityURLs.indexOf(trade.partnerVanityURL) == -1) {
|
||||||
vanityURLs.push(trade.partnerVanityURL);
|
vanityURLs.push(trade.partnerVanityURL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
items = item.find('.history_item');
|
items = item.find('.history_item');
|
||||||
for(j = 0; j < items.length; j++) {
|
for (j = 0; j < items.length; j++) {
|
||||||
match = body.match(new RegExp("HistoryPageCreateItemHover\\( '" + $(items[j]).attr('id') + "', (\\d+), '(\\d+)', '(\\d+)', '(\\d+)' \\);"));
|
match = body.match(new RegExp("HistoryPageCreateItemHover\\( '" + $(items[j]).attr('id') + "', (\\d+), '(\\d+)', '(\\d+|class_\\d+_instance_\\d+|class_\\d+)', '(\\d+)' \\);"));
|
||||||
econItem = historyInventory[match[1]][match[2]][match[3]];
|
econItem = historyInventory[match[1]][match[2]][match[3]];
|
||||||
|
|
||||||
if($(items[j]).attr('id').indexOf('received') != -1) {
|
if ($(items[j]).attr('id').indexOf('received') != -1) {
|
||||||
trade.itemsReceived.push(new CEconItem(econItem));
|
trade.itemsReceived.push(new CEconItem(econItem));
|
||||||
} else {
|
} else {
|
||||||
trade.itemsGiven.push(new CEconItem(econItem));
|
trade.itemsGiven.push(new CEconItem(econItem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
output.trades.push(trade);
|
output.trades.push(trade);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(options.resolveVanityURLs) {
|
if (options.resolveVanityURLs) {
|
||||||
Async.map(vanityURLs, resolveVanityURL, function(err, results) {
|
Async.map(vanityURLs, resolveVanityURL, function(err, results) {
|
||||||
if(err) {
|
if (err) {
|
||||||
callback(err);
|
callback(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < output.trades.length; i++) {
|
for (i = 0; i < output.trades.length; i++) {
|
||||||
if(output.trades[i].partnerSteamID || !output.trades[i].partnerVanityURL) {
|
if (output.trades[i].partnerSteamID || !output.trades[i].partnerVanityURL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the vanity URL
|
// Find the vanity URL
|
||||||
for(j = 0; j < results.length; j++) {
|
for (j = 0; j < results.length; j++) {
|
||||||
if(results[j].vanityURL == output.trades[i].partnerVanityURL) {
|
if (results[j].vanityURL == output.trades[i].partnerVanityURL) {
|
||||||
output.trades[i].partnerSteamID = new SteamID(results[j].steamID);
|
output.trades[i].partnerSteamID = new SteamID(results[j].steamID);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null, output);
|
callback(null, output);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
callback(null, output);
|
callback(null, output);
|
||||||
}
|
}
|
||||||
});
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
function resolveVanityURL(vanityURL, callback) {
|
function resolveVanityURL(vanityURL, callback) {
|
||||||
request("https://steamcommunity.com/id/" + vanityURL + "/?xml=1", function(err, response, body) {
|
request("https://steamcommunity.com/id/" + vanityURL + "/?xml=1", function(err, response, body) {
|
||||||
if(err) {
|
if (err) {
|
||||||
callback(err);
|
callback(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var match = body.match(/<steamID64>(\d+)<\/steamID64>/);
|
var match = body.match(/<steamID64>(\d+)<\/steamID64>/);
|
||||||
if(!match || !match[1]) {
|
if (!match || !match[1]) {
|
||||||
callback(new Error("Couldn't find Steam ID"));
|
callback(new Error("Couldn't find Steam ID"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null, {"vanityURL": vanityURL, "steamID": match[1]});
|
callback(null, {"vanityURL": vanityURL, "steamID": match[1]});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,22 @@
|
|||||||
var SteamCommunity = require('../index.js');
|
var SteamCommunity = require('../index.js');
|
||||||
var Cheerio = require('cheerio');
|
var Cheerio = require('cheerio');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of all apps on the market
|
||||||
|
* @param {function} callback - First argument is null|Error, second is an object of appid => name
|
||||||
|
*/
|
||||||
SteamCommunity.prototype.getMarketApps = function(callback) {
|
SteamCommunity.prototype.getMarketApps = function(callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.request('https://steamcommunity.com/market/', function (err, response, body) {
|
this.httpRequest('https://steamcommunity.com/market/', function (err, response, body) {
|
||||||
if(self._checkHttpError(err, response, callback)) {
|
if (err) {
|
||||||
|
callback(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var $ = Cheerio.load(body);
|
var $ = Cheerio.load(body);
|
||||||
if ($('.market_search_game_button_group')) {
|
if ($('.market_search_game_button_group')) {
|
||||||
apps = {};
|
let apps = {};
|
||||||
$('.market_search_game_button_group > a').each(function (i, element) {
|
$('.market_search_game_button_group a.game_button').each(function (i, element) {
|
||||||
var e = Cheerio.load(element);
|
var e = Cheerio.load(element);
|
||||||
var name = e('.game_button_game_name').text().trim();
|
var name = e('.game_button_game_name').text().trim();
|
||||||
var url = element.attribs.href;
|
var url = element.attribs.href;
|
||||||
@@ -21,5 +27,151 @@ SteamCommunity.prototype.getMarketApps = function(callback) {
|
|||||||
} else {
|
} else {
|
||||||
callback(new Error("Malformed response"));
|
callback(new Error("Malformed response"));
|
||||||
}
|
}
|
||||||
|
}, "steamcommunity");
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if an item is eligible to be turned into gems and if so, get its gem value
|
||||||
|
* @param {int} appid
|
||||||
|
* @param {int|string} assetid
|
||||||
|
* @param {function} callback
|
||||||
|
*/
|
||||||
|
SteamCommunity.prototype.getGemValue = function(appid, assetid, callback) {
|
||||||
|
this._myProfile({
|
||||||
|
"endpoint": "ajaxgetgoovalue/",
|
||||||
|
"qs": {
|
||||||
|
"sessionid": this.getSessionID(),
|
||||||
|
"appid": appid,
|
||||||
|
"contextid": 6,
|
||||||
|
"assetid": assetid
|
||||||
|
},
|
||||||
|
"checkHttpError": false,
|
||||||
|
"json": true
|
||||||
|
}, null, (err, res, body) => {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body.success && body.success != SteamCommunity.EResult.OK) {
|
||||||
|
let err = new Error(body.message || SteamCommunity.EResult[body.success]);
|
||||||
|
err.eresult = err.code = body.success;
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!body.goo_value || !body.strTitle) {
|
||||||
|
callback(new Error("Malformed response"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(null, {"promptTitle": body.strTitle, "gemValue": parseInt(body.goo_value, 10)});
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turn an eligible item into gems.
|
||||||
|
* @param {int} appid
|
||||||
|
* @param {int|string} assetid
|
||||||
|
* @param {int} expectedGemsValue
|
||||||
|
* @param {function} callback
|
||||||
|
*/
|
||||||
|
SteamCommunity.prototype.turnItemIntoGems = function(appid, assetid, expectedGemsValue, callback) {
|
||||||
|
this._myProfile({
|
||||||
|
"endpoint": "ajaxgrindintogoo/",
|
||||||
|
"json": true,
|
||||||
|
"checkHttpError": false
|
||||||
|
}, {
|
||||||
|
"appid": appid,
|
||||||
|
"contextid": 6,
|
||||||
|
"assetid": assetid,
|
||||||
|
"goo_value_expected": expectedGemsValue,
|
||||||
|
"sessionid": this.getSessionID()
|
||||||
|
}, (err, res, body) => {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body.success && body.success != SteamCommunity.EResult.OK) {
|
||||||
|
let err = new Error(body.message || SteamCommunity.EResult[body.success]);
|
||||||
|
err.eresult = err.code = body.success;
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!body['goo_value_received '] || !body.goo_value_total) { // lol valve
|
||||||
|
callback(new Error("Malformed response"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(null, {"gemsReceived": parseInt(body['goo_value_received '], 10), "totalGems": parseInt(body.goo_value_total, 10)});
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get details about a gift in your inventory.
|
||||||
|
* @param {string} giftID
|
||||||
|
* @param {function} callback
|
||||||
|
*/
|
||||||
|
SteamCommunity.prototype.getGiftDetails = function(giftID, callback) {
|
||||||
|
this.httpRequestPost({
|
||||||
|
"uri": "https://steamcommunity.com/gifts/" + giftID + "/validateunpack",
|
||||||
|
"form": {
|
||||||
|
"sessionid": this.getSessionID()
|
||||||
|
},
|
||||||
|
"json": true
|
||||||
|
}, (err, res, body) => {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body.success && body.success != SteamCommunity.EResult.OK) {
|
||||||
|
let err = new Error(body.message || SteamCommunity.EResult[body.success]);
|
||||||
|
err.eresult = err.code = body.success;
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!body.packageid || !body.gift_name) {
|
||||||
|
callback(new Error("Malformed response"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(null, {
|
||||||
|
"giftName": body.gift_name,
|
||||||
|
"packageID": parseInt(body.packageid, 10),
|
||||||
|
"owned": body.owned
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unpack a gift in your inventory to your library.
|
||||||
|
* @param {string} giftID
|
||||||
|
* @param {function} callback
|
||||||
|
*/
|
||||||
|
SteamCommunity.prototype.redeemGift = function(giftID, callback) {
|
||||||
|
this.httpRequestPost({
|
||||||
|
"uri": "https://steamcommunity.com/gifts/" + giftID + "/unpack",
|
||||||
|
"form": {
|
||||||
|
"sessionid": this.getSessionID()
|
||||||
|
},
|
||||||
|
"json": true
|
||||||
|
}, (err, res, body) => {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body.success && body.success != SteamCommunity.EResult.OK) {
|
||||||
|
let err = new Error(body.message || SteamCommunity.EResult[body.success]);
|
||||||
|
err.eresult = err.code = body.success;
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(null);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
var SteamCommunity = require('../index.js');
|
const Cheerio = require('cheerio');
|
||||||
var SteamID = require('steamid');
|
const FS = require('fs');
|
||||||
var Cheerio = require('cheerio');
|
const SteamID = require('steamid');
|
||||||
var fs = require('fs');
|
|
||||||
|
const Helpers = require('./helpers.js');
|
||||||
|
const SteamCommunity = require('../index.js');
|
||||||
|
|
||||||
SteamCommunity.PrivacyState = {
|
SteamCommunity.PrivacyState = {
|
||||||
"Private": 1,
|
"Private": 1,
|
||||||
@@ -10,9 +12,9 @@ SteamCommunity.PrivacyState = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var CommentPrivacyState = {
|
var CommentPrivacyState = {
|
||||||
"1": "commentselfonly",
|
"1": 2, // private
|
||||||
"2": "commentfriendsonly",
|
"2": 0, // friends only
|
||||||
"3": "commentanyone"
|
"3": 1 // anyone
|
||||||
};
|
};
|
||||||
|
|
||||||
SteamCommunity.prototype.setupProfile = function(callback) {
|
SteamCommunity.prototype.setupProfile = function(callback) {
|
||||||
@@ -21,7 +23,7 @@ SteamCommunity.prototype.setupProfile = function(callback) {
|
|||||||
if(!callback) {
|
if(!callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(err || response.statusCode != 200) {
|
if(err || response.statusCode != 200) {
|
||||||
callback(err || new Error("HTTP error " + response.statusCode));
|
callback(err || new Error("HTTP error " + response.statusCode));
|
||||||
} else {
|
} else {
|
||||||
@@ -37,91 +39,95 @@ SteamCommunity.prototype.editProfile = function(settings, callback) {
|
|||||||
if(callback) {
|
if(callback) {
|
||||||
callback(err || new Error("HTTP error " + response.statusCode));
|
callback(err || new Error("HTTP error " + response.statusCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var $ = Cheerio.load(body);
|
var $ = Cheerio.load(body);
|
||||||
var form = $('#editForm');
|
var form = $('#editForm');
|
||||||
if(!form) {
|
if(!form) {
|
||||||
if(callback) {
|
if(callback) {
|
||||||
callback(new Error("Malformed response"));
|
callback(new Error("Malformed response"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var values = {};
|
var values = {};
|
||||||
form.serializeArray().forEach(function(item) {
|
form.serializeArray().forEach(function(item) {
|
||||||
values[item.name] = item.value;
|
values[item.name] = item.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
for(var i in settings) {
|
for(var i in settings) {
|
||||||
if(!settings.hasOwnProperty(i)) {
|
if(!settings.hasOwnProperty(i)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(i) {
|
switch(i) {
|
||||||
case 'name':
|
case 'name':
|
||||||
values.personaName = settings[i];
|
values.personaName = settings[i];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'realName':
|
case 'realName':
|
||||||
values.real_name = settings[i];
|
values.real_name = settings[i];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'summary':
|
case 'summary':
|
||||||
values.summary = settings[i];
|
values.summary = settings[i];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'country':
|
case 'country':
|
||||||
values.country = settings[i];
|
values.country = settings[i];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'state':
|
case 'state':
|
||||||
values.state = settings[i];
|
values.state = settings[i];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'city':
|
case 'city':
|
||||||
values.city = settings[i];
|
values.city = settings[i];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'customURL':
|
case 'customURL':
|
||||||
values.customURL = settings[i];
|
values.customURL = settings[i];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'background':
|
case 'background':
|
||||||
// The assetid of our desired profile background
|
// The assetid of our desired profile background
|
||||||
values.profile_background = settings[i];
|
values.profile_background = settings[i];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'featuredBadge':
|
case 'featuredBadge':
|
||||||
// Currently, game badges aren't supported
|
// Currently, game badges aren't supported
|
||||||
values.favorite_badge_badgeid = settings[i];
|
values.favorite_badge_badgeid = settings[i];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'primaryGroup':
|
case 'primaryGroup':
|
||||||
if(typeof settings[i] === 'object' && settings[i].accountid) {
|
if(typeof settings[i] === 'object' && settings[i].getSteamID64) {
|
||||||
values.primary_group_steamid = settings[i].accountid;
|
values.primary_group_steamid = settings[i].getSteamID64();
|
||||||
} else {
|
} else {
|
||||||
values.primary_group_steamid = new SteamID(settings[i]).accountid;
|
values.primary_group_steamid = new SteamID(settings[i]).getSteamID64();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// TODO: profile showcases
|
// TODO: profile showcases
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self._myProfile("edit", values, function(err, response, body) {
|
self._myProfile("edit", values, function(err, response, body) {
|
||||||
|
if (settings.customURL) {
|
||||||
|
delete self._profileURL;
|
||||||
|
}
|
||||||
|
|
||||||
if(err || response.statusCode != 200) {
|
if(err || response.statusCode != 200) {
|
||||||
if(callback) {
|
if(callback) {
|
||||||
callback(err || new Error("HTTP error " + response.statusCode));
|
callback(err || new Error("HTTP error " + response.statusCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for an error
|
// Check for an error
|
||||||
var $ = Cheerio.load(body);
|
var $ = Cheerio.load(body);
|
||||||
var error = $('#errorText .formRowFields');
|
var error = $('#errorText .formRowFields');
|
||||||
@@ -131,11 +137,11 @@ SteamCommunity.prototype.editProfile = function(settings, callback) {
|
|||||||
if(callback) {
|
if(callback) {
|
||||||
callback(new Error(error));
|
callback(new Error(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(callback) {
|
if(callback) {
|
||||||
callback(null);
|
callback(null);
|
||||||
}
|
}
|
||||||
@@ -144,70 +150,94 @@ SteamCommunity.prototype.editProfile = function(settings, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
SteamCommunity.prototype.profileSettings = function(settings, callback) {
|
SteamCommunity.prototype.profileSettings = function(settings, callback) {
|
||||||
var self = this;
|
this._myProfile("edit/settings", null, (err, response, body) => {
|
||||||
this._myProfile("edit/settings", null, function(err, response, body) {
|
if (err || response.statusCode != 200) {
|
||||||
if(err || response.statusCode != 200) {
|
if (callback) {
|
||||||
if(callback) {
|
|
||||||
callback(err || new Error("HTTP error " + response.statusCode));
|
callback(err || new Error("HTTP error " + response.statusCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var $ = Cheerio.load(body);
|
var $ = Cheerio.load(body);
|
||||||
var form = $('#editForm');
|
var existingSettings = $('.ProfileReactRoot[data-privacysettings]').data('privacysettings');
|
||||||
if(!form) {
|
if (!existingSettings) {
|
||||||
if(callback) {
|
if(callback) {
|
||||||
callback(new Error("Malformed response"));
|
callback(new Error("Malformed response"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var values = {};
|
// PrivacySettings => {PrivacyProfile, PrivacyInventory, PrivacyInventoryGifts, PrivacyOwnedGames, PrivacyPlaytime}
|
||||||
form.serializeArray().forEach(function(item) {
|
// eCommentPermission
|
||||||
values[item.name] = item.value;
|
var privacy = existingSettings.PrivacySettings;
|
||||||
});
|
var commentPermission = existingSettings.eCommentPermission;
|
||||||
|
|
||||||
for(var i in settings) {
|
for (var i in settings) {
|
||||||
if(!settings.hasOwnProperty(i)) {
|
if (!settings.hasOwnProperty(i)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(i) {
|
switch (i) {
|
||||||
case 'profile':
|
case 'profile':
|
||||||
values.privacySetting = settings[i];
|
privacy.PrivacyProfile = settings[i];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'comments':
|
case 'comments':
|
||||||
values.commentSetting = CommentPrivacyState[settings[i]];
|
commentPermission = CommentPrivacyState[settings[i]];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'inventory':
|
case 'inventory':
|
||||||
values.inventoryPrivacySetting = settings[i];
|
privacy.PrivacyInventory = settings[i];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'inventoryGifts':
|
case 'inventoryGifts':
|
||||||
values.inventoryGiftPrivacy = settings[i] ? 1 : 0;
|
privacy.PrivacyInventoryGifts = settings[i] ? SteamCommunity.PrivacyState.Private : SteamCommunity.PrivacyState.Public;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'emailConfirmation':
|
case 'gameDetails':
|
||||||
values.tradeConfirmationSetting = settings[i] ? 1 : 0;
|
privacy.PrivacyOwnedGames = settings[i];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'playtime':
|
||||||
|
privacy.PrivacyPlaytime = settings[i] ? SteamCommunity.PrivacyState.Private : SteamCommunity.PrivacyState.Public;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'friendsList':
|
||||||
|
privacy.PrivacyFriendsList = settings[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self._myProfile("edit/settings", values, function(err, response, body) {
|
this._myProfile({
|
||||||
if(err || response.statusCode != 200) {
|
"method": "POST",
|
||||||
if(callback) {
|
"endpoint": "ajaxsetprivacy/",
|
||||||
|
"json": true,
|
||||||
|
"formData": { // it's multipart because lolvalve
|
||||||
|
"sessionid": this.getSessionID(),
|
||||||
|
"Privacy": JSON.stringify(privacy),
|
||||||
|
"eCommentPermission": commentPermission
|
||||||
|
}
|
||||||
|
}, null, function(err, response, body) {
|
||||||
|
if (err || response.statusCode != 200) {
|
||||||
|
if (callback) {
|
||||||
callback(err || new Error("HTTP error " + response.statusCode));
|
callback(err || new Error("HTTP error " + response.statusCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(callback) {
|
if (body.success != 1) {
|
||||||
callback(null);
|
if (callback) {
|
||||||
|
callback(new Error(body.success ? "Error " + body.success : "Request was not successful"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (callback) {
|
||||||
|
callback(null, body.Privacy);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -219,12 +249,18 @@ SteamCommunity.prototype.uploadAvatar = function(image, format, callback) {
|
|||||||
format = null;
|
format = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// are we logged in?
|
||||||
|
if (!this.steamID) {
|
||||||
|
callback(new Error("Not Logged In"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if(image instanceof Buffer) {
|
if(image instanceof Buffer) {
|
||||||
doUpload(image);
|
doUpload(image);
|
||||||
} else if(image.match(/^https?:\/\//)) {
|
} else if(image.match(/^https?:\/\//)) {
|
||||||
this.request.get({
|
this.httpRequestGet({
|
||||||
"uri": image,
|
"uri": image,
|
||||||
"encoding": null
|
"encoding": null
|
||||||
}, function(err, response, body) {
|
}, function(err, response, body) {
|
||||||
@@ -241,7 +277,7 @@ SteamCommunity.prototype.uploadAvatar = function(image, format, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
doUpload(body);
|
doUpload(body);
|
||||||
})
|
}, "steamcommunity");
|
||||||
} else {
|
} else {
|
||||||
if(!format) {
|
if(!format) {
|
||||||
format = image.match(/\.([^\.]+)$/);
|
format = image.match(/\.([^\.]+)$/);
|
||||||
@@ -250,7 +286,7 @@ SteamCommunity.prototype.uploadAvatar = function(image, format, callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.readFile(image, function(err, file) {
|
FS.readFile(image, function(err, file) {
|
||||||
if(err) {
|
if(err) {
|
||||||
if(callback) {
|
if(callback) {
|
||||||
callback(err);
|
callback(err);
|
||||||
@@ -304,7 +340,7 @@ SteamCommunity.prototype.uploadAvatar = function(image, format, callback) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.request.post({
|
self.httpRequestPost({
|
||||||
"uri": "https://steamcommunity.com/actions/FileUploader",
|
"uri": "https://steamcommunity.com/actions/FileUploader",
|
||||||
"formData": {
|
"formData": {
|
||||||
"MAX_FILE_SIZE": buffer.length,
|
"MAX_FILE_SIZE": buffer.length,
|
||||||
@@ -358,6 +394,71 @@ SteamCommunity.prototype.uploadAvatar = function(image, format, callback) {
|
|||||||
if(callback) {
|
if(callback) {
|
||||||
callback(null, body.images.full);
|
callback(null, body.images.full);
|
||||||
}
|
}
|
||||||
});
|
}, "steamcommunity");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Post a new status to your profile activity feed.
|
||||||
|
* @param {string} statusText - The text of this status update
|
||||||
|
* @param {{appID: int}} [options] - Options for this status update. All are optional. If you don't pass any options, this can be omitted.
|
||||||
|
* @param {function} callback - err, postID
|
||||||
|
*/
|
||||||
|
SteamCommunity.prototype.postProfileStatus = function(statusText, options, callback) {
|
||||||
|
if (typeof options === 'function') {
|
||||||
|
callback = options;
|
||||||
|
options = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
this._myProfile("ajaxpostuserstatus/", {
|
||||||
|
"appid": options.appID || 0,
|
||||||
|
"sessionid": this.getSessionID(),
|
||||||
|
"status_text": statusText
|
||||||
|
}, (err, res, body) => {
|
||||||
|
try {
|
||||||
|
body = JSON.parse(body);
|
||||||
|
if (body.message) {
|
||||||
|
callback(new Error(body.message));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var match = body.blotter_html.match(/id="userstatus_(\d+)_/);
|
||||||
|
if (!match) {
|
||||||
|
callback(new Error("Malformed response"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(null, parseInt(match[1], 10));
|
||||||
|
} catch (ex) {
|
||||||
|
callback(ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a previously-posted profile status update.
|
||||||
|
* @param {int} postID
|
||||||
|
* @param {function} [callback]
|
||||||
|
*/
|
||||||
|
SteamCommunity.prototype.deleteProfileStatus = function(postID, callback) {
|
||||||
|
this._myProfile("ajaxdeleteuserstatus/", {
|
||||||
|
"sessionid": this.getSessionID(),
|
||||||
|
"postid": postID
|
||||||
|
}, (err, res, body) => {
|
||||||
|
if (!callback) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
body = JSON.parse(body);
|
||||||
|
if (!body.success) {
|
||||||
|
callback(new Error("Malformed response"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(Helpers.eresultError(body.success));
|
||||||
|
} catch (ex) {
|
||||||
|
callback(ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|||||||
159
components/twofactor.js
Normal file
159
components/twofactor.js
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
var SteamTotp = require('steam-totp');
|
||||||
|
var SteamCommunity = require('../index.js');
|
||||||
|
|
||||||
|
var 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.
|
||||||
|
};
|
||||||
|
|
||||||
|
SteamCommunity.prototype.enableTwoFactor = function(callback) {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
this.getWebApiOauthToken(function(err, token) {
|
||||||
|
if(err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.httpRequestPost({
|
||||||
|
"uri": "https://api.steampowered.com/ITwoFactorService/AddAuthenticator/v1/",
|
||||||
|
"form": {
|
||||||
|
"steamid": self.steamID.getSteamID64(),
|
||||||
|
"access_token": token,
|
||||||
|
"authenticator_time": Math.floor(Date.now() / 1000),
|
||||||
|
"authenticator_type": ETwoFactorTokenType.ValveMobileApp,
|
||||||
|
"device_identifier": SteamTotp.getDeviceID(self.steamID),
|
||||||
|
"sms_phone_id": "1"
|
||||||
|
},
|
||||||
|
"json": true
|
||||||
|
}, function(err, response, body) {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!body.response) {
|
||||||
|
callback(new Error("Malformed response"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(body.response.status != 1) {
|
||||||
|
var error = new Error("Error " + body.response.status);
|
||||||
|
error.eresult = body.response.status;
|
||||||
|
callback(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(null, body.response);
|
||||||
|
}, "steamcommunity");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
SteamCommunity.prototype.finalizeTwoFactor = function(secret, activationCode, callback) {
|
||||||
|
var attemptsLeft = 30;
|
||||||
|
var diff = 0;
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
this.getWebApiOauthToken(function(err, token) {
|
||||||
|
if(err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SteamTotp.getTimeOffset(function(err, offset, latency) {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff = offset;
|
||||||
|
finalize(token);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function finalize(token) {
|
||||||
|
var code = SteamTotp.generateAuthCode(secret, diff);
|
||||||
|
|
||||||
|
self.httpRequestPost({
|
||||||
|
"uri": "https://api.steampowered.com/ITwoFactorService/FinalizeAddAuthenticator/v1/",
|
||||||
|
"form": {
|
||||||
|
"steamid": self.steamID.getSteamID64(),
|
||||||
|
"access_token": token,
|
||||||
|
"authenticator_code": code,
|
||||||
|
"authenticator_time": Math.floor(Date.now() / 1000),
|
||||||
|
"activation_code": activationCode
|
||||||
|
},
|
||||||
|
"json": true
|
||||||
|
}, function(err, response, body) {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!body.response) {
|
||||||
|
callback(new Error("Malformed response"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
body = body.response;
|
||||||
|
|
||||||
|
if(body.server_time) {
|
||||||
|
diff = body.server_time - Math.floor(Date.now() / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(body.status == 89) {
|
||||||
|
callback(new Error("Invalid activation code"));
|
||||||
|
} else if(body.want_more) {
|
||||||
|
attemptsLeft--;
|
||||||
|
diff += 30;
|
||||||
|
|
||||||
|
finalize(token);
|
||||||
|
} else if(!body.success) {
|
||||||
|
callback(new Error("Error " + body.status));
|
||||||
|
} else {
|
||||||
|
callback(null);
|
||||||
|
}
|
||||||
|
}, "steamcommunity");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
SteamCommunity.prototype.disableTwoFactor = function(revocationCode, callback) {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
this.getWebApiOauthToken(function(err, token) {
|
||||||
|
if(err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.httpRequestPost({
|
||||||
|
"uri": "https://api.steampowered.com/ITwoFactorService/RemoveAuthenticator/v1/",
|
||||||
|
"form": {
|
||||||
|
"steamid": self.steamID.getSteamID64(),
|
||||||
|
"access_token": token,
|
||||||
|
"revocation_code": revocationCode,
|
||||||
|
"steamguard_scheme": 1
|
||||||
|
},
|
||||||
|
"json": true
|
||||||
|
}, function(err, response, body) {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!body.response) {
|
||||||
|
callback(new Error("Malformed response"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!body.response.success) {
|
||||||
|
callback(new Error("Request failed"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// success = true means it worked
|
||||||
|
callback(null);
|
||||||
|
}, "steamcommunity");
|
||||||
|
});
|
||||||
|
};
|
||||||
@@ -1,6 +1,12 @@
|
|||||||
var SteamCommunity = require('../index.js');
|
const Cheerio = require('cheerio');
|
||||||
var SteamID = require('steamid');
|
const Crypto = require('crypto');
|
||||||
var CEconItem = require('../classes/CEconItem.js');
|
const imageSize = require('image-size');
|
||||||
|
const SteamID = require('steamid');
|
||||||
|
|
||||||
|
const SteamCommunity = require('../index.js');
|
||||||
|
|
||||||
|
const CEconItem = require('../classes/CEconItem.js');
|
||||||
|
const Helpers = require('./helpers.js');
|
||||||
|
|
||||||
SteamCommunity.prototype.addFriend = function(userID, callback) {
|
SteamCommunity.prototype.addFriend = function(userID, callback) {
|
||||||
if(typeof userID === 'string') {
|
if(typeof userID === 'string') {
|
||||||
@@ -8,7 +14,7 @@ SteamCommunity.prototype.addFriend = function(userID, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.request.post({
|
this.httpRequestPost({
|
||||||
"uri": "https://steamcommunity.com/actions/AddFriendAjax",
|
"uri": "https://steamcommunity.com/actions/AddFriendAjax",
|
||||||
"form": {
|
"form": {
|
||||||
"accept_invite": 0,
|
"accept_invite": 0,
|
||||||
@@ -21,7 +27,8 @@ SteamCommunity.prototype.addFriend = function(userID, callback) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(self._checkHttpError(err, response, callback)) {
|
if (err) {
|
||||||
|
callback(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +37,7 @@ SteamCommunity.prototype.addFriend = function(userID, callback) {
|
|||||||
} else {
|
} else {
|
||||||
callback(new Error("Unknown error"));
|
callback(new Error("Unknown error"));
|
||||||
}
|
}
|
||||||
});
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
SteamCommunity.prototype.acceptFriendRequest = function(userID, callback) {
|
SteamCommunity.prototype.acceptFriendRequest = function(userID, callback) {
|
||||||
@@ -39,7 +46,7 @@ SteamCommunity.prototype.acceptFriendRequest = function(userID, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.request.post({
|
this.httpRequestPost({
|
||||||
"uri": "https://steamcommunity.com/actions/AddFriendAjax",
|
"uri": "https://steamcommunity.com/actions/AddFriendAjax",
|
||||||
"form": {
|
"form": {
|
||||||
"accept_invite": 1,
|
"accept_invite": 1,
|
||||||
@@ -51,12 +58,8 @@ SteamCommunity.prototype.acceptFriendRequest = function(userID, callback) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(self._checkHttpError(err, response, callback)) {
|
callback(err || null);
|
||||||
return;
|
}, "steamcommunity");
|
||||||
}
|
|
||||||
|
|
||||||
callback(null);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SteamCommunity.prototype.removeFriend = function(userID, callback) {
|
SteamCommunity.prototype.removeFriend = function(userID, callback) {
|
||||||
@@ -65,7 +68,7 @@ SteamCommunity.prototype.removeFriend = function(userID, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.request.post({
|
this.httpRequestPost({
|
||||||
"uri": "https://steamcommunity.com/actions/RemoveFriendAjax",
|
"uri": "https://steamcommunity.com/actions/RemoveFriendAjax",
|
||||||
"form": {
|
"form": {
|
||||||
"sessionID": this.getSessionID(),
|
"sessionID": this.getSessionID(),
|
||||||
@@ -76,12 +79,8 @@ SteamCommunity.prototype.removeFriend = function(userID, callback) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(self._checkHttpError(err, response, callback)) {
|
callback(err || null);
|
||||||
return;
|
}, "steamcommunity");
|
||||||
}
|
|
||||||
|
|
||||||
callback(null);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SteamCommunity.prototype.blockCommunication = function(userID, callback) {
|
SteamCommunity.prototype.blockCommunication = function(userID, callback) {
|
||||||
@@ -90,7 +89,7 @@ SteamCommunity.prototype.blockCommunication = function(userID, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.request.post({
|
this.httpRequestPost({
|
||||||
"uri": "https://steamcommunity.com/actions/BlockUserAjax",
|
"uri": "https://steamcommunity.com/actions/BlockUserAjax",
|
||||||
"form": {
|
"form": {
|
||||||
"sessionID": this.getSessionID(),
|
"sessionID": this.getSessionID(),
|
||||||
@@ -101,12 +100,8 @@ SteamCommunity.prototype.blockCommunication = function(userID, callback) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(self._checkHttpError(err, response, callback)) {
|
callback(err || null);
|
||||||
return;
|
}, "steamcommunity");
|
||||||
}
|
|
||||||
|
|
||||||
callback(null);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SteamCommunity.prototype.unblockCommunication = function(userID, callback) {
|
SteamCommunity.prototype.unblockCommunication = function(userID, callback) {
|
||||||
@@ -137,7 +132,7 @@ SteamCommunity.prototype.postUserComment = function(userID, message, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.request.post({
|
this.httpRequestPost({
|
||||||
"uri": "https://steamcommunity.com/comment/Profile/post/" + userID.toString() + "/-1",
|
"uri": "https://steamcommunity.com/comment/Profile/post/" + userID.toString() + "/-1",
|
||||||
"form": {
|
"form": {
|
||||||
"comment": message,
|
"comment": message,
|
||||||
@@ -150,18 +145,19 @@ SteamCommunity.prototype.postUserComment = function(userID, message, callback) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(self._checkHttpError(err, response, callback)) {
|
if (err) {
|
||||||
|
callback(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(body.success) {
|
if(body.success) {
|
||||||
callback(null);
|
callback(null);
|
||||||
} else if(bpdy.error) {
|
} else if(body.error) {
|
||||||
callback(new Error(body.error));
|
callback(new Error(body.error));
|
||||||
} else {
|
} else {
|
||||||
callback(new Error("Unknown error"));
|
callback(new Error("Unknown error"));
|
||||||
}
|
}
|
||||||
});
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
SteamCommunity.prototype.inviteUserToGroup = function(userID, groupID, callback) {
|
SteamCommunity.prototype.inviteUserToGroup = function(userID, groupID, callback) {
|
||||||
@@ -170,7 +166,7 @@ SteamCommunity.prototype.inviteUserToGroup = function(userID, groupID, callback)
|
|||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.request.post({
|
this.httpRequestPost({
|
||||||
"uri": "https://steamcommunity.com/actions/GroupInvite",
|
"uri": "https://steamcommunity.com/actions/GroupInvite",
|
||||||
"form": {
|
"form": {
|
||||||
"group": groupID.toString(),
|
"group": groupID.toString(),
|
||||||
@@ -185,7 +181,8 @@ SteamCommunity.prototype.inviteUserToGroup = function(userID, groupID, callback)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(self._checkHttpError(err, response, callback)) {
|
if (err) {
|
||||||
|
callback(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,33 +193,110 @@ SteamCommunity.prototype.inviteUserToGroup = function(userID, groupID, callback)
|
|||||||
} else {
|
} else {
|
||||||
callback(new Error("Unknown error"));
|
callback(new Error("Unknown error"));
|
||||||
}
|
}
|
||||||
});
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
SteamCommunity.prototype.getUserInventoryContexts = function(userID, callback) {
|
SteamCommunity.prototype.getUserAliases = function(userID, callback) {
|
||||||
if(typeof userID === 'string') {
|
if (typeof userID === 'string') {
|
||||||
userID = new SteamID(userID);
|
userID = new SteamID(userID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(typeof userID === 'function') {
|
this.httpRequestGet({
|
||||||
|
"uri": "https://steamcommunity.com/profiles/" + userID.getSteamID64() + "/ajaxaliases",
|
||||||
|
"json": true
|
||||||
|
}, function(err, response, body) {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof body !== 'object') {
|
||||||
|
callback(new Error("Malformed response"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(null, body.map(function(entry) {
|
||||||
|
entry.timechanged = Helpers.decodeSteamTime(entry.timechanged);
|
||||||
|
return entry;
|
||||||
|
}));
|
||||||
|
}, "steamcommunity");
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the background URL of user's profile.
|
||||||
|
* @param {SteamID|string} userID - The user's SteamID as a SteamID object or a string which can parse into one
|
||||||
|
* @param {function} callback
|
||||||
|
*/
|
||||||
|
SteamCommunity.prototype.getUserProfileBackground = function(userID, callback) {
|
||||||
|
if (typeof userID === 'string') {
|
||||||
|
userID = new SteamID(userID);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.httpRequest("https://steamcommunity.com/profiles/" + userID.getSteamID64(), (err, response, body) => {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var $ = Cheerio.load(body);
|
||||||
|
|
||||||
|
var $privateProfileInfo = $('.profile_private_info');
|
||||||
|
if ($privateProfileInfo.length > 0) {
|
||||||
|
callback(new Error($privateProfileInfo.text().trim()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($('body').hasClass('has_profile_background')) {
|
||||||
|
var backgroundUrl = $('div.profile_background_image_content').css('background-image');
|
||||||
|
var matcher = backgroundUrl.match(/\(([^)]+)\)/);
|
||||||
|
|
||||||
|
if (matcher.length != 2 || !matcher[1].length) {
|
||||||
|
callback(new Error("Malformed response"));
|
||||||
|
} else {
|
||||||
|
callback(null, matcher[1]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
callback(null, null);
|
||||||
|
}
|
||||||
|
}, "steamcommunity");
|
||||||
|
};
|
||||||
|
|
||||||
|
SteamCommunity.prototype.getUserInventoryContexts = function(userID, callback) {
|
||||||
|
if (typeof userID === 'string') {
|
||||||
|
userID = new SteamID(userID);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof userID === 'function') {
|
||||||
callback = userID;
|
callback = userID;
|
||||||
userID = this.steamID;
|
userID = this.steamID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!userID) {
|
if (!userID) {
|
||||||
callback(new Error("No SteamID specified and not logged in"));
|
callback(new Error("No SteamID specified and not logged in"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.request("https://steamcommunity.com/profiles/" + userID.getSteamID64() + "/inventory/", function(err, response, body) {
|
this.httpRequest("https://steamcommunity.com/profiles/" + userID.getSteamID64() + "/inventory/", function(err, response, body) {
|
||||||
if(self._checkHttpError(err, response, callback)) {
|
if (err) {
|
||||||
|
callback(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var match = body.match(/var g_rgAppContextData = ([^\n]+);\r?\n/);
|
var match = body.match(/var g_rgAppContextData = ([^\n]+);\r?\n/);
|
||||||
if(!match) {
|
if (!match) {
|
||||||
callback(new Error("Malformed response"));
|
var errorMessage = "Malformed response";
|
||||||
|
|
||||||
|
if(body.match(/0 items in their inventory\./)){
|
||||||
|
callback(null, {});
|
||||||
|
return;
|
||||||
|
}else if(body.match(/inventory is currently private\./)){
|
||||||
|
errorMessage = "Private inventory";
|
||||||
|
}else if(body.match(/profile\_private\_info/)){
|
||||||
|
errorMessage = "Private profile";
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(new Error(errorMessage));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,13 +309,22 @@ SteamCommunity.prototype.getUserInventoryContexts = function(userID, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
callback(null, data);
|
callback(null, data);
|
||||||
});
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the contents of a user's inventory context.
|
||||||
|
* @deprecated Use getUserInventoryContents instead
|
||||||
|
* @param {SteamID|string} userID - The user's SteamID as a SteamID object or a string which can parse into one
|
||||||
|
* @param {int} appID - The Steam application ID of the game for which you want an inventory
|
||||||
|
* @param {int} contextID - The ID of the "context" within the game you want to retrieve
|
||||||
|
* @param {boolean} tradableOnly - true to get only tradable items and currencies
|
||||||
|
* @param {function} callback
|
||||||
|
*/
|
||||||
SteamCommunity.prototype.getUserInventory = function(userID, appID, contextID, tradableOnly, callback) {
|
SteamCommunity.prototype.getUserInventory = function(userID, appID, contextID, tradableOnly, callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if(typeof userID === 'string') {
|
if (typeof userID === 'string') {
|
||||||
userID = new SteamID(userID);
|
userID = new SteamID(userID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,41 +332,50 @@ SteamCommunity.prototype.getUserInventory = function(userID, appID, contextID, t
|
|||||||
get([], []);
|
get([], []);
|
||||||
|
|
||||||
function get(inventory, currency, start) {
|
function get(inventory, currency, start) {
|
||||||
self.request({
|
self.httpRequest({
|
||||||
"uri": "https://steamcommunity.com" + endpoint + "/inventory/json/" + appID + "/" + contextID,
|
"uri": "https://steamcommunity.com" + endpoint + "/inventory/json/" + appID + "/" + contextID,
|
||||||
|
"headers": {
|
||||||
|
"Referer": "https://steamcommunity.com" + endpoint + "/inventory"
|
||||||
|
},
|
||||||
"qs": {
|
"qs": {
|
||||||
"start": start,
|
"start": start,
|
||||||
"trading": tradableOnly ? 1 : undefined
|
"trading": tradableOnly ? 1 : undefined
|
||||||
},
|
},
|
||||||
"json": true
|
"json": true
|
||||||
}, function(err, response, body) {
|
}, function(err, response, body) {
|
||||||
if(self._checkHttpError(err, response, callback)) {
|
if (err) {
|
||||||
|
callback(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!body || !body.success || !body.rgInventory || !body.rgDescriptions || !body.rgCurrency) {
|
if (!body || !body.success || !body.rgInventory || !body.rgDescriptions || !body.rgCurrency) {
|
||||||
callback(new Error(body.Error || "Malformed response"));
|
if (body) {
|
||||||
|
callback(new Error(body.Error || "Malformed response"));
|
||||||
|
} else {
|
||||||
|
callback(new Error("Malformed response"));
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var i;
|
var i;
|
||||||
for(i in body.rgInventory) {
|
for (i in body.rgInventory) {
|
||||||
if(!body.rgInventory.hasOwnProperty(i)) {
|
if (!body.rgInventory.hasOwnProperty(i)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
inventory.push(new CEconItem(body.rgInventory[i], body.rgDescriptions, contextID));
|
inventory.push(new CEconItem(body.rgInventory[i], body.rgDescriptions, contextID));
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i in body.rgCurrency) {
|
for (i in body.rgCurrency) {
|
||||||
if(!body.rgCurrency.hasOwnProperty(i)) {
|
if (!body.rgCurrency.hasOwnProperty(i)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
currency.push(new CEconItem(body.rgInventory[i], body.rgDescriptions, contextID));
|
currency.push(new CEconItem(body.rgInventory[i], body.rgDescriptions, contextID));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(body.more) {
|
if (body.more) {
|
||||||
var match = response.request.uri.href.match(/\/(profiles|id)\/([^\/]+)\//);
|
var match = response.request.uri.href.match(/\/(profiles|id)\/([^\/]+)\//);
|
||||||
if(match) {
|
if(match) {
|
||||||
endpoint = "/" + match[1] + "/" + match[2];
|
endpoint = "/" + match[1] + "/" + match[2];
|
||||||
@@ -293,6 +385,283 @@ SteamCommunity.prototype.getUserInventory = function(userID, appID, contextID, t
|
|||||||
} else {
|
} else {
|
||||||
callback(null, inventory, currency);
|
callback(null, inventory, currency);
|
||||||
}
|
}
|
||||||
});
|
}, "steamcommunity");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the contents of a user's inventory context.
|
||||||
|
* @param {SteamID|string} userID - The user's SteamID as a SteamID object or a string which can parse into one
|
||||||
|
* @param {int} appID - The Steam application ID of the game for which you want an inventory
|
||||||
|
* @param {int} contextID - The ID of the "context" within the game you want to retrieve
|
||||||
|
* @param {boolean} tradableOnly - true to get only tradable items and currencies
|
||||||
|
* @param {string} [language] - The language of item descriptions to return. Omit for default (which may either be English or your account's chosen language)
|
||||||
|
* @param {function} callback
|
||||||
|
*/
|
||||||
|
SteamCommunity.prototype.getUserInventoryContents = function(userID, appID, contextID, tradableOnly, language, callback) {
|
||||||
|
if (typeof language === 'function') {
|
||||||
|
callback = language;
|
||||||
|
language = "english";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!userID) {
|
||||||
|
callback(new Error("The user's SteamID is invalid or missing."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
if (typeof userID === 'string') {
|
||||||
|
userID = new SteamID(userID);
|
||||||
|
}
|
||||||
|
|
||||||
|
var pos = 1;
|
||||||
|
get([], []);
|
||||||
|
|
||||||
|
function get(inventory, currency, start) {
|
||||||
|
self.httpRequest({
|
||||||
|
"uri": "https://steamcommunity.com/inventory/" + userID.getSteamID64() + "/" + appID + "/" + contextID,
|
||||||
|
"headers": {
|
||||||
|
"Referer": "https://steamcommunity.com/profiles/" + userID.getSteamID64() + "/inventory"
|
||||||
|
},
|
||||||
|
"qs": {
|
||||||
|
"l": language, // Default language
|
||||||
|
"count": 5000, // Max items per 'page'
|
||||||
|
"start_assetid": start
|
||||||
|
},
|
||||||
|
"json": true
|
||||||
|
}, function(err, response, body) {
|
||||||
|
if (err) {
|
||||||
|
if (err.message == "HTTP error 403" && body === null) {
|
||||||
|
// 403 with a body of "null" means the inventory/profile is private.
|
||||||
|
if (self.steamID && userID.getSteamID64() == self.steamID.getSteamID64()) {
|
||||||
|
// We can never get private profile error for our own inventory!
|
||||||
|
self._notifySessionExpired(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(new Error("This profile is private."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err.message == "HTTP error 500" && body && body.error) {
|
||||||
|
err = new Error(body.error);
|
||||||
|
|
||||||
|
var match = body.error.match(/^(.+) \((\d+)\)$/);
|
||||||
|
if (match) {
|
||||||
|
err.message = match[1];
|
||||||
|
err.eresult = match[2];
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body && body.success && body.total_inventory_count === 0) {
|
||||||
|
// Empty inventory
|
||||||
|
callback(null, [], [], 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!body || !body.success || !body.assets || !body.descriptions) {
|
||||||
|
if (body) {
|
||||||
|
// Dunno if the error/Error property even exists on this new endpoint
|
||||||
|
callback(new Error(body.error || body.Error || "Malformed response"));
|
||||||
|
} else {
|
||||||
|
callback(new Error("Malformed response"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < body.assets.length; i++) {
|
||||||
|
var description = getDescription(body.descriptions, body.assets[i].classid, body.assets[i].instanceid);
|
||||||
|
|
||||||
|
if (!tradableOnly || (description && description.tradable)) {
|
||||||
|
body.assets[i].pos = pos++;
|
||||||
|
(body.assets[i].currencyid ? currency : inventory).push(new CEconItem(body.assets[i], description, contextID));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body.more_items) {
|
||||||
|
get(inventory, currency, body.last_assetid);
|
||||||
|
} else {
|
||||||
|
callback(null, inventory, currency, body.total_inventory_count);
|
||||||
|
}
|
||||||
|
}, "steamcommunity");
|
||||||
|
}
|
||||||
|
|
||||||
|
// A bit of optimization; objects are hash tables so it's more efficient to look up by key than to iterate an array
|
||||||
|
var quickDescriptionLookup = {};
|
||||||
|
|
||||||
|
function getDescription(descriptions, classID, instanceID) {
|
||||||
|
var key = classID + '_' + (instanceID || '0'); // instanceID can be undefined, in which case it's 0.
|
||||||
|
|
||||||
|
if (quickDescriptionLookup[key]) {
|
||||||
|
return quickDescriptionLookup[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < descriptions.length; i++) {
|
||||||
|
quickDescriptionLookup[descriptions[i].classid + '_' + (descriptions[i].instanceid || '0')] = descriptions[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return quickDescriptionLookup[key];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Upload an image to Steam and send it to another user over Steam chat.
|
||||||
|
* @param {SteamID|string} userID - Either a SteamID object or a string that can parse into one
|
||||||
|
* @param {Buffer} imageContentsBuffer - The image contents, as a Buffer
|
||||||
|
* @param {{spoiler?: boolean}} [options]
|
||||||
|
* @param {function} callback
|
||||||
|
*/
|
||||||
|
SteamCommunity.prototype.sendImageToUser = function(userID, imageContentsBuffer, options, callback) {
|
||||||
|
if (typeof options == 'function') {
|
||||||
|
callback = options;
|
||||||
|
options = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
|
if (!userID) {
|
||||||
|
callback(new Error('The user\'s SteamID is invalid or missing'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof userID == 'string') {
|
||||||
|
userID = new SteamID(userID);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Buffer.isBuffer(imageContentsBuffer)) {
|
||||||
|
callback(new Error('The image contents must be a Buffer containing an image'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var imageDetails = null;
|
||||||
|
try {
|
||||||
|
imageDetails = imageSize(imageContentsBuffer);
|
||||||
|
} catch (ex) {
|
||||||
|
callback(ex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var imageHash = Crypto.createHash('sha1');
|
||||||
|
imageHash.update(imageContentsBuffer);
|
||||||
|
imageHash = imageHash.digest('hex');
|
||||||
|
|
||||||
|
var filename = Date.now() + '_image.' + imageDetails.type;
|
||||||
|
|
||||||
|
this.httpRequestPost({
|
||||||
|
uri: 'https://steamcommunity.com/chat/beginfileupload/?l=english',
|
||||||
|
headers: {
|
||||||
|
referer: 'https://steamcommunity.com/chat/'
|
||||||
|
},
|
||||||
|
formData: { // it's multipart
|
||||||
|
sessionid: this.getSessionID(),
|
||||||
|
l: 'english',
|
||||||
|
file_size: imageContentsBuffer.length,
|
||||||
|
file_name: filename,
|
||||||
|
file_sha: imageHash,
|
||||||
|
file_image_width: imageDetails.width,
|
||||||
|
file_image_height: imageDetails.height,
|
||||||
|
file_type: 'image/' + (imageDetails.type == 'jpg' ? 'jpeg' : imageDetails.type)
|
||||||
|
},
|
||||||
|
json: true
|
||||||
|
}, (err, res, body) => {
|
||||||
|
if (err) {
|
||||||
|
if (body && body.success) {
|
||||||
|
var err2 = Helpers.eresultError(body.success);
|
||||||
|
if (body.message) {
|
||||||
|
err2.message = body.message;
|
||||||
|
}
|
||||||
|
callback(err2);
|
||||||
|
} else {
|
||||||
|
callback(err);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body.success != 1) {
|
||||||
|
callback(Helpers.eresultError(body.success));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var hmac = body.hmac;
|
||||||
|
var timestamp = body.timestamp;
|
||||||
|
var startResult = body.result;
|
||||||
|
|
||||||
|
if (!startResult || !startResult.ugcid || !startResult.url_host || !startResult.request_headers) {
|
||||||
|
callback(new Error('Malformed response'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Okay, now we need to PUT the file to the provided URL
|
||||||
|
var uploadUrl = (startResult.use_https ? 'https' : 'http') + '://' + startResult.url_host + startResult.url_path;
|
||||||
|
var headers = {};
|
||||||
|
startResult.request_headers.forEach((header) => {
|
||||||
|
headers[header.name.toLowerCase()] = header.value;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.httpRequest({
|
||||||
|
uri: uploadUrl,
|
||||||
|
method: 'PUT',
|
||||||
|
headers,
|
||||||
|
body: imageContentsBuffer
|
||||||
|
}, (err, res, body) => {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now we need to commit the upload
|
||||||
|
this.httpRequestPost({
|
||||||
|
uri: 'https://steamcommunity.com/chat/commitfileupload/',
|
||||||
|
headers: {
|
||||||
|
referer: 'https://steamcommunity.com/chat/'
|
||||||
|
},
|
||||||
|
formData: { // it's multipart again
|
||||||
|
sessionid: this.getSessionID(),
|
||||||
|
l: 'english',
|
||||||
|
file_name: filename,
|
||||||
|
file_sha: imageHash,
|
||||||
|
success: '1',
|
||||||
|
ugcid: startResult.ugcid,
|
||||||
|
file_type: 'image/' + (imageDetails.type == 'jpg' ? 'jpeg' : imageDetails.type),
|
||||||
|
file_image_width: imageDetails.width,
|
||||||
|
file_image_height: imageDetails.height,
|
||||||
|
timestamp,
|
||||||
|
hmac,
|
||||||
|
friend_steamid: userID.getSteamID64(),
|
||||||
|
spoiler: options.spoiler ? '1' : '0'
|
||||||
|
},
|
||||||
|
json: true
|
||||||
|
}, (err, res, body) => {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body.success != 1) {
|
||||||
|
callback(Helpers.eresultError(body.success));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body.result.success != 1) {
|
||||||
|
// lol valve
|
||||||
|
callback(Helpers.eresultError(body.result.success));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!body.result.details || !body.result.details.url) {
|
||||||
|
callback(new Error('Malformed response'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(null, body.result.details.url);
|
||||||
|
}, 'steamcommunity');
|
||||||
|
}, 'steamcommunity');
|
||||||
|
}, 'steamcommunity');
|
||||||
|
};
|
||||||
|
|||||||
73
components/webapi.js
Normal file
73
components/webapi.js
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
var SteamCommunity = require('../index.js');
|
||||||
|
|
||||||
|
SteamCommunity.prototype.getWebApiKey = function(domain, callback) {
|
||||||
|
var self = this;
|
||||||
|
this.httpRequest({
|
||||||
|
"uri": "https://steamcommunity.com/dev/apikey?l=english",
|
||||||
|
"followRedirect": false
|
||||||
|
}, function(err, response, body) {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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."));
|
||||||
|
}
|
||||||
|
|
||||||
|
var match = body.match(/<p>Key: ([0-9A-F]+)<\/p>/);
|
||||||
|
if(match) {
|
||||||
|
// We already have an API key registered
|
||||||
|
callback(null, match[1]);
|
||||||
|
} else {
|
||||||
|
// We need to register a new API key
|
||||||
|
self.httpRequestPost('https://steamcommunity.com/dev/registerkey?l=english', {
|
||||||
|
"form": {
|
||||||
|
"domain": domain,
|
||||||
|
"agreeToTerms": "agreed",
|
||||||
|
"sessionid": self.getSessionID(),
|
||||||
|
"Submit": "Register"
|
||||||
|
}
|
||||||
|
}, function(err, response, body) {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.getWebApiKey(domain, callback);
|
||||||
|
}, "steamcommunity");
|
||||||
|
}
|
||||||
|
}, "steamcommunity");
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated No longer works if not logged in via mobile login. Will be removed in a future release.
|
||||||
|
* @param {function} callback
|
||||||
|
*/
|
||||||
|
SteamCommunity.prototype.getWebApiOauthToken = function(callback) {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
if( this.oAuthToken ) {
|
||||||
|
return callback( null, this.oAuthToken );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pull an oauth token from the webchat UI
|
||||||
|
this.httpRequest("https://steamcommunity.com/chat", function(err, response, body) {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var match = body.match(/"([0-9a-f]{32})"/);
|
||||||
|
if (!match) {
|
||||||
|
callback(new Error("Malformed response"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(null, match[1]);
|
||||||
|
}, "steamcommunity");
|
||||||
|
};
|
||||||
61
examples/disable_twofactor.js
Normal file
61
examples/disable_twofactor.js
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
var SteamCommunity = require('../index.js');
|
||||||
|
var ReadLine = require('readline');
|
||||||
|
var fs = require('fs');
|
||||||
|
|
||||||
|
var community = new SteamCommunity();
|
||||||
|
var rl = ReadLine.createInterface({
|
||||||
|
"input": process.stdin,
|
||||||
|
"output": process.stdout
|
||||||
|
});
|
||||||
|
|
||||||
|
rl.question("Username: ", function(accountName) {
|
||||||
|
rl.question("Password: ", function(password) {
|
||||||
|
rl.question("Two-Factor Auth Code: ", function(authCode) {
|
||||||
|
rl.question("Revocation Code: R", function(rCode) {
|
||||||
|
doLogin(accountName, password, authCode, "", rCode);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function doLogin(accountName, password, authCode, captcha, rCode) {
|
||||||
|
community.login({
|
||||||
|
"accountName": accountName,
|
||||||
|
"password": password,
|
||||||
|
"twoFactorCode": authCode,
|
||||||
|
"captcha": captcha
|
||||||
|
}, function(err, sessionID, cookies, steamguard) {
|
||||||
|
if(err) {
|
||||||
|
if(err.message == 'SteamGuard') {
|
||||||
|
console.log("This account does not have two-factor authentication enabled.");
|
||||||
|
process.exit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(err.message == 'CAPTCHA') {
|
||||||
|
console.log(err.captchaurl);
|
||||||
|
rl.question("CAPTCHA: ", function(captchaInput) {
|
||||||
|
doLogin(accountName, password, authCode, captchaInput);
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(err);
|
||||||
|
process.exit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Logged on!");
|
||||||
|
community.disableTwoFactor("R" + rCode, function(err) {
|
||||||
|
if(err) {
|
||||||
|
console.log(err);
|
||||||
|
process.exit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Two-factor authentication disabled!");
|
||||||
|
process.exit();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
118
examples/edit-group-announcement.js
Normal file
118
examples/edit-group-announcement.js
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
var SteamCommunity = require('../index.js');
|
||||||
|
var ReadLine = require('readline');
|
||||||
|
|
||||||
|
var community = new SteamCommunity();
|
||||||
|
var rl = ReadLine.createInterface({
|
||||||
|
"input": process.stdin,
|
||||||
|
"output": process.stdout
|
||||||
|
});
|
||||||
|
|
||||||
|
rl.question("Username: ", function(accountName) {
|
||||||
|
rl.question("Password: ", function(password) {
|
||||||
|
doLogin(accountName, password);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function doLogin(accountName, password, authCode, twoFactorCode, captcha) {
|
||||||
|
community.login({
|
||||||
|
"accountName": accountName,
|
||||||
|
"password": password,
|
||||||
|
"authCode": authCode,
|
||||||
|
"twoFactorCode": twoFactorCode,
|
||||||
|
"captcha": captcha
|
||||||
|
}, function(err, sessionID, cookies, steamguard) {
|
||||||
|
if(err) {
|
||||||
|
if(err.message == 'SteamGuardMobile') {
|
||||||
|
rl.question("Steam Authenticator Code: ", function(code) {
|
||||||
|
doLogin(accountName, password, null, code);
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(err.message == 'SteamGuard') {
|
||||||
|
console.log("An email has been sent to your address at " + err.emaildomain);
|
||||||
|
rl.question("Steam Guard Code: ", function(code) {
|
||||||
|
doLogin(accountName, password, code);
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(err.message == 'CAPTCHA') {
|
||||||
|
console.log(err.captchaurl);
|
||||||
|
rl.question("CAPTCHA: ", function(captchaInput) {
|
||||||
|
doLogin(accountName, password, authCode, twoFactorCode, captchaInput);
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(err);
|
||||||
|
process.exit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Logged on!");
|
||||||
|
|
||||||
|
rl.question("Group ID: ", function(gid) {
|
||||||
|
community.getSteamGroup(gid, function(err, group) {
|
||||||
|
if (err) {
|
||||||
|
console.log(err);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
group.getAllAnnouncements(function(err, announcements) {
|
||||||
|
|
||||||
|
if(announcements.length === 0) {
|
||||||
|
return console.log("This group has no announcements");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = announcements.length - 1; i >= 0; i--) {
|
||||||
|
console.log("[%s] %s %s: %s", announcements[i].date, announcements[i].aid, announcements[i].author, announcements[i].content);
|
||||||
|
};
|
||||||
|
|
||||||
|
rl.question("Would you like to delete delete or edit an annoucement? (Type edit/delete): ", function(choice) {
|
||||||
|
rl.question("Annoucement ID: ", function(aid) {
|
||||||
|
if(choice === 'edit') {
|
||||||
|
rl.question("New title: ", function(header) {
|
||||||
|
rl.question("New body: ", function(content) {
|
||||||
|
// EW THE PYRAMID!
|
||||||
|
// Try replace this with delete!
|
||||||
|
editAnnouncement(group, aid, header, content);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
deleteAnnouncement(group, aid);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function editAnnouncement(group, aid, header, content) {
|
||||||
|
// Actual community method.
|
||||||
|
group.editAnnouncement(aid, header, content, function(error) {
|
||||||
|
if(!error) {
|
||||||
|
console.log("Annoucement edited!");
|
||||||
|
} else {
|
||||||
|
console.log("Unable to edit annoucement! %j", error);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteAnnouncement(group, aid) {
|
||||||
|
// group.deleteAnnouncement(aid);
|
||||||
|
// Or
|
||||||
|
group.deleteAnnouncement(aid, function(err) {
|
||||||
|
if(!err) {
|
||||||
|
console.log("Deleted");
|
||||||
|
} else {
|
||||||
|
console.log("Error deleting announcement.");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
107
examples/enable_twofactor.js
Normal file
107
examples/enable_twofactor.js
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
var SteamCommunity = require('../index.js');
|
||||||
|
var ReadLine = require('readline');
|
||||||
|
var fs = require('fs');
|
||||||
|
|
||||||
|
var community = new SteamCommunity();
|
||||||
|
var rl = ReadLine.createInterface({
|
||||||
|
"input": process.stdin,
|
||||||
|
"output": process.stdout
|
||||||
|
});
|
||||||
|
|
||||||
|
rl.question("Username: ", function(accountName) {
|
||||||
|
rl.question("Password: ", function(password) {
|
||||||
|
doLogin(accountName, password);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function doLogin(accountName, password, authCode, captcha) {
|
||||||
|
community.login({
|
||||||
|
"accountName": accountName,
|
||||||
|
"password": password,
|
||||||
|
"authCode": authCode,
|
||||||
|
"captcha": captcha
|
||||||
|
}, function(err, sessionID, cookies, steamguard) {
|
||||||
|
if(err) {
|
||||||
|
if(err.message == 'SteamGuardMobile') {
|
||||||
|
console.log("This account already has two-factor authentication enabled.");
|
||||||
|
process.exit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(err.message == 'SteamGuard') {
|
||||||
|
console.log("An email has been sent to your address at " + err.emaildomain);
|
||||||
|
rl.question("Steam Guard Code: ", function (code) {
|
||||||
|
doLogin(accountName, password, code);
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(err.message == 'CAPTCHA') {
|
||||||
|
console.log(err.captchaurl);
|
||||||
|
rl.question("CAPTCHA: ", function(captchaInput) {
|
||||||
|
doLogin(accountName, password, authCode, captchaInput);
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(err);
|
||||||
|
process.exit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Logged on!");
|
||||||
|
community.enableTwoFactor(function(err, response) {
|
||||||
|
if(err) {
|
||||||
|
if(err.eresult == 2) {
|
||||||
|
console.log("Error: Failed to enable two-factor authentication. Do you have a phone number attached to your account?");
|
||||||
|
process.exit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(err.eresult == 84) {
|
||||||
|
console.log("Error: RateLimitExceeded. Try again later.");
|
||||||
|
process.exit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(err);
|
||||||
|
process.exit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(response.status != 1) {
|
||||||
|
console.log("Error: Status " + response.status);
|
||||||
|
process.exit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Writing secrets to twofactor_" + community.steamID.getSteamID64() + ".json");
|
||||||
|
console.log("Revocation code: " + response.revocation_code);
|
||||||
|
fs.writeFileSync("twofactor_" + community.steamID.getSteamID64() + ".json", JSON.stringify(response, null, "\t"));
|
||||||
|
|
||||||
|
promptActivationCode(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function promptActivationCode(response) {
|
||||||
|
rl.question("SMS Code: ", function(smsCode) {
|
||||||
|
community.finalizeTwoFactor(response.shared_secret, smsCode, function(err) {
|
||||||
|
if(err) {
|
||||||
|
if(err.message == "Invalid activation code") {
|
||||||
|
console.log(err);
|
||||||
|
promptActivationCode(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(err);
|
||||||
|
} else {
|
||||||
|
console.log("Two-factor authentication enabled!");
|
||||||
|
}
|
||||||
|
|
||||||
|
process.exit();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
602
index.js
602
index.js
@@ -1,106 +1,192 @@
|
|||||||
var Request = require('request');
|
const hex2b64 = require('node-bignumber').hex2b64;
|
||||||
var RSA = require('node-bignumber').Key;
|
const Request = require('request');
|
||||||
var hex2b64 = require('node-bignumber').hex2b64;
|
const RSA = require('node-bignumber').Key;
|
||||||
var SteamID = require('steamid');
|
const SteamID = require('steamid');
|
||||||
|
|
||||||
|
const Helpers = require('./components/helpers.js');
|
||||||
|
|
||||||
|
const USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36";
|
||||||
|
|
||||||
require('util').inherits(SteamCommunity, require('events').EventEmitter);
|
require('util').inherits(SteamCommunity, require('events').EventEmitter);
|
||||||
|
|
||||||
module.exports = SteamCommunity;
|
module.exports = SteamCommunity;
|
||||||
|
|
||||||
SteamCommunity.SteamID = SteamID;
|
SteamCommunity.SteamID = SteamID;
|
||||||
|
SteamCommunity.ConfirmationType = require('./resources/EConfirmationType.js');
|
||||||
|
SteamCommunity.EResult = require('./resources/EResult.js');
|
||||||
|
|
||||||
|
|
||||||
|
function SteamCommunity(options) {
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
function SteamCommunity(localAddress) {
|
|
||||||
this._jar = Request.jar();
|
this._jar = Request.jar();
|
||||||
this._captchaGid = -1;
|
this._captchaGid = -1;
|
||||||
|
this._httpRequestID = 0;
|
||||||
this.chatState = SteamCommunity.ChatState.Offline;
|
this.chatState = SteamCommunity.ChatState.Offline;
|
||||||
|
|
||||||
var defaults = {"jar": this._jar, "timeout": 50000};
|
var defaults = {
|
||||||
if(localAddress) {
|
"jar": this._jar,
|
||||||
defaults.localAddress = localAddress;
|
"timeout": options.timeout || 50000,
|
||||||
|
"gzip": true,
|
||||||
|
"headers": {
|
||||||
|
"User-Agent": options.userAgent || USER_AGENT
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
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({"forever": true}); // "forever" indicates that we want a keep-alive agent
|
||||||
|
this.request = this.request.defaults(defaults);
|
||||||
|
|
||||||
// English
|
// English
|
||||||
this._jar.setCookie(Request.cookie('Steam_Language=english'), 'https://steamcommunity.com');
|
this._setCookie(Request.cookie('Steam_Language=english'));
|
||||||
|
|
||||||
// UTC
|
// UTC
|
||||||
this._jar.setCookie(Request.cookie('timezoneOffset=0,0'), 'https://steamcommunity.com');
|
this._setCookie(Request.cookie('timezoneOffset=0,0'));
|
||||||
}
|
}
|
||||||
|
|
||||||
SteamCommunity.prototype.login = function(details, callback) {
|
SteamCommunity.prototype.login = function(details, callback) {
|
||||||
if(details.steamguard) {
|
if (!details.accountName || !details.password) {
|
||||||
var parts = details.steamguard.split('||');
|
throw new Error("Missing either accountName or password to login; both are needed");
|
||||||
this._jar.setCookie(Request.cookie('steamMachineAuth' + parts[0] + '=' + encodeURIComponent(parts[1])), 'https://steamcommunity.com');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (details.steamguard) {
|
||||||
|
var parts = details.steamguard.split('||');
|
||||||
|
this._setCookie(Request.cookie('steamMachineAuth' + parts[0] + '=' + encodeURIComponent(parts[1])), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
var disableMobile = details.disableMobile;
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.request.post("https://steamcommunity.com/login/getrsakey/", {"form": {"username": details.accountName}}, function(err, response, body) {
|
|
||||||
if(err) {
|
// Delete the cache
|
||||||
|
delete self._profileURL;
|
||||||
|
|
||||||
|
// headers required to convince steam that we're logging in from a mobile device so that we can get the oAuth data
|
||||||
|
var mobileHeaders = {};
|
||||||
|
if (!disableMobile) {
|
||||||
|
mobileHeaders = {
|
||||||
|
"X-Requested-With": "com.valvesoftware.android.steam.community",
|
||||||
|
"Referer": "https://steamcommunity.com/mobilelogin?oauth_client_id=DE45CD61&oauth_scope=read_profile%20write_profile%20read_client%20write_client",
|
||||||
|
"User-Agent": this._options.mobileUserAgent || details.mobileUserAgent || "Mozilla/5.0 (Linux; U; Android 4.1.1; en-us; Google Nexus 4 - 4.1.1 - API 16 - 768x1280 Build/JRO03S) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
|
||||||
|
"Accept": "text/javascript, text/html, application/xml, text/xml, */*"
|
||||||
|
};
|
||||||
|
|
||||||
|
this._setCookie(Request.cookie("mobileClientVersion=0 (2.1.3)"));
|
||||||
|
this._setCookie(Request.cookie("mobileClient=android"));
|
||||||
|
} else {
|
||||||
|
mobileHeaders = {"Referer": "https://steamcommunity.com/login"};
|
||||||
|
}
|
||||||
|
|
||||||
|
this.httpRequestPost("https://steamcommunity.com/login/getrsakey/", {
|
||||||
|
"form": {"username": details.accountName},
|
||||||
|
"headers": mobileHeaders,
|
||||||
|
"json": true
|
||||||
|
}, function(err, response, body) {
|
||||||
|
// Remove the mobile cookies
|
||||||
|
if (err) {
|
||||||
|
deleteMobileCookies();
|
||||||
callback(err);
|
callback(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var json;
|
if (!body.publickey_mod || !body.publickey_exp) {
|
||||||
try {
|
deleteMobileCookies();
|
||||||
json = JSON.parse(body);
|
callback(new Error("Invalid RSA key received"));
|
||||||
} catch(e) {
|
|
||||||
callback(e);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var key = new RSA();
|
var key = new RSA();
|
||||||
key.setPublic(json.publickey_mod, json.publickey_exp);
|
key.setPublic(body.publickey_mod, body.publickey_exp);
|
||||||
|
|
||||||
var form = {
|
var formObj = {
|
||||||
"captcha_text": details.captcha || "",
|
"captcha_text": details.captcha || "",
|
||||||
"captchagid": self._captchaGid,
|
"captchagid": self._captchaGid,
|
||||||
"emailauth": details.authCode || "",
|
"emailauth": details.authCode || "",
|
||||||
"emailsteamid": "",
|
"emailsteamid": "",
|
||||||
"loginfriendlyname": "",
|
|
||||||
"password": hex2b64(key.encrypt(details.password)),
|
"password": hex2b64(key.encrypt(details.password)),
|
||||||
"remember_login": "true",
|
"remember_login": "true",
|
||||||
"rsatimestamp": json.timestamp,
|
"rsatimestamp": body.timestamp,
|
||||||
"twofactorcode": details.twoFactorCode || "",
|
"twofactorcode": details.twoFactorCode || "",
|
||||||
"username": details.accountName
|
"username": details.accountName,
|
||||||
|
"loginfriendlyname": "",
|
||||||
|
"donotcache": Date.now()
|
||||||
};
|
};
|
||||||
|
|
||||||
self.request.post({
|
if(!disableMobile){
|
||||||
|
formObj.oauth_client_id = "DE45CD61";
|
||||||
|
formObj.oauth_scope = "read_profile write_profile read_client write_client";
|
||||||
|
formObj.loginfriendlyname = "#login_emailauth_friendlyname_mobile";
|
||||||
|
}
|
||||||
|
|
||||||
|
self.httpRequestPost({
|
||||||
"uri": "https://steamcommunity.com/login/dologin/",
|
"uri": "https://steamcommunity.com/login/dologin/",
|
||||||
"json": true,
|
"json": true,
|
||||||
"form": form
|
"form": formObj,
|
||||||
|
"headers": mobileHeaders
|
||||||
}, function(err, response, body) {
|
}, function(err, response, body) {
|
||||||
if(self._checkHttpError(err, response, callback)) {
|
deleteMobileCookies();
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!body.success && body.emailauth_needed) {
|
var error;
|
||||||
|
if (!body.success && body.emailauth_needed) {
|
||||||
// Steam Guard (email)
|
// Steam Guard (email)
|
||||||
var error = new Error("SteamGuard");
|
error = new Error("SteamGuard");
|
||||||
error.emaildomain = body.emaildomain;
|
error.emaildomain = body.emaildomain;
|
||||||
|
|
||||||
callback(error);
|
callback(error);
|
||||||
} else if(!body.success && body.requires_twofactor) {
|
} else if (!body.success && body.requires_twofactor) {
|
||||||
// Steam Guard (app)
|
// Steam Guard (app)
|
||||||
callback(new Error("SteamGuardMobile"));
|
callback(new Error("SteamGuardMobile"));
|
||||||
} else if(!body.success && body.captcha_needed) {
|
} else if (!body.success && body.captcha_needed && body.message.match(/Please verify your humanity/)) {
|
||||||
var error = new Error("CAPTCHA");
|
error = new Error("CAPTCHA");
|
||||||
error.captchaurl = "https://steamcommunity.com/public/captcha.php?gid=" + body.captcha_gid;
|
error.captchaurl = "https://steamcommunity.com/login/rendercaptcha/?gid=" + body.captcha_gid;
|
||||||
|
|
||||||
self._captchaGid = body.captcha_gid;
|
self._captchaGid = body.captcha_gid;
|
||||||
|
|
||||||
callback(error);
|
callback(error);
|
||||||
} else if(!body.success) {
|
} else if (!body.success) {
|
||||||
callback(new Error(body.message || "Unknown error"));
|
callback(new Error(body.message || "Unknown error"));
|
||||||
|
} else if (!disableMobile && !body.oauth) {
|
||||||
|
callback(new Error("Malformed response"));
|
||||||
} else {
|
} else {
|
||||||
var sessionID = generateSessionID();
|
var sessionID = generateSessionID();
|
||||||
self._jar.setCookie(Request.cookie('sessionid=' + sessionID), 'http://steamcommunity.com');
|
var oAuth;
|
||||||
|
self._setCookie(Request.cookie('sessionid=' + sessionID));
|
||||||
self.steamID = new SteamID(body.transfer_parameters.steamid);
|
|
||||||
var cookies = self._jar.getCookieString("https://steamcommunity.com").split(';').map(function(cookie) {
|
var cookies = self._jar.getCookieString("https://steamcommunity.com").split(';').map(function(cookie) {
|
||||||
return cookie.trim();
|
return cookie.trim();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!disableMobile){
|
||||||
|
oAuth = JSON.parse(body.oauth);
|
||||||
|
self.steamID = new SteamID(oAuth.steamid);
|
||||||
|
self.oAuthToken = oAuth.oauth_token;
|
||||||
|
}else{
|
||||||
|
for(var i = 0; i < cookies.length; i++) {
|
||||||
|
var parts = cookies[i].split('=');
|
||||||
|
if(parts[0] == 'steamLogin') {
|
||||||
|
self.steamID = new SteamID(decodeURIComponent(parts[1]).split('||')[0])
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self.oAuthToken = null;
|
||||||
|
}
|
||||||
|
|
||||||
// Find the Steam Guard cookie
|
// Find the Steam Guard cookie
|
||||||
var steamguard = null;
|
var steamguard = null;
|
||||||
for(var i = 0; i < cookies.length; i++) {
|
for(var i = 0; i < cookies.length; i++) {
|
||||||
@@ -110,22 +196,110 @@ SteamCommunity.prototype.login = function(details, callback) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null, sessionID, cookies, steamguard);
|
self.setCookies(cookies);
|
||||||
|
|
||||||
|
callback(null, sessionID, cookies, steamguard, disableMobile ? null : oAuth.oauth_token);
|
||||||
}
|
}
|
||||||
|
}, "steamcommunity");
|
||||||
|
}, "steamcommunity");
|
||||||
|
|
||||||
|
function deleteMobileCookies() {
|
||||||
|
var cookie = Request.cookie('mobileClientVersion=');
|
||||||
|
cookie.expires = new Date(0);
|
||||||
|
self._setCookie(cookie);
|
||||||
|
|
||||||
|
cookie = Request.cookie('mobileClient=');
|
||||||
|
cookie.expires = new Date(0);
|
||||||
|
self._setCookie(cookie);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
SteamCommunity.prototype.oAuthLogin = function(steamguard, token, callback) {
|
||||||
|
steamguard = steamguard.split('||');
|
||||||
|
var steamID = new SteamID(steamguard[0]);
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
this.httpRequestPost({
|
||||||
|
"uri": "https://api.steampowered.com/IMobileAuthService/GetWGToken/v1/",
|
||||||
|
"form": {
|
||||||
|
"access_token": token
|
||||||
|
},
|
||||||
|
"json": true
|
||||||
|
}, function(err, response, body) {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!body.response || !body.response.token || !body.response.token_secure) {
|
||||||
|
callback(new Error("Malformed response"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var cookies = [
|
||||||
|
'steamLogin=' + encodeURIComponent(steamID.getSteamID64() + '||' + body.response.token),
|
||||||
|
'steamLoginSecure=' + encodeURIComponent(steamID.getSteamID64() + '||' + body.response.token_secure),
|
||||||
|
'steamMachineAuth' + steamID.getSteamID64() + '=' + steamguard[1],
|
||||||
|
'sessionid=' + self.getSessionID()
|
||||||
|
];
|
||||||
|
|
||||||
|
self.setCookies(cookies);
|
||||||
|
callback(null, self.getSessionID(), cookies);
|
||||||
|
}, "steamcommunity");
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a token that can be used to log onto Steam using steam-user.
|
||||||
|
* @param {function} callback
|
||||||
|
*/
|
||||||
|
SteamCommunity.prototype.getClientLogonToken = function(callback) {
|
||||||
|
this.httpRequestGet({
|
||||||
|
"uri": "https://steamcommunity.com/chat/clientjstoken",
|
||||||
|
"json": true
|
||||||
|
}, (err, res, body) => {
|
||||||
|
if (err || res.statusCode != 200) {
|
||||||
|
callback(err ? err : new Error('HTTP error ' + res.statusCode));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!body.logged_in) {
|
||||||
|
let e = new Error('Not Logged In');
|
||||||
|
callback(e);
|
||||||
|
this._notifySessionExpired(e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!body.steamid || !body.account_name || !body.token) {
|
||||||
|
callback(new Error('Malformed response'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(null, {
|
||||||
|
"steamID": new SteamID(body.steamid),
|
||||||
|
"accountName": body.account_name,
|
||||||
|
"webLogonToken": body.token
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SteamCommunity.prototype._setCookie = function(cookie, secure) {
|
||||||
|
var protocol = secure ? "https" : "http";
|
||||||
|
cookie.secure = !!secure;
|
||||||
|
|
||||||
|
this._jar.setCookie(cookie.clone(), protocol + "://steamcommunity.com");
|
||||||
|
this._jar.setCookie(cookie.clone(), protocol + "://store.steampowered.com");
|
||||||
|
this._jar.setCookie(cookie.clone(), protocol + "://help.steampowered.com");
|
||||||
|
};
|
||||||
|
|
||||||
SteamCommunity.prototype.setCookies = function(cookies) {
|
SteamCommunity.prototype.setCookies = function(cookies) {
|
||||||
var self = this;
|
cookies.forEach((cookie) => {
|
||||||
cookies.forEach(function(cookie) {
|
|
||||||
var cookieName = cookie.match(/(.+)=/)[1];
|
var cookieName = cookie.match(/(.+)=/)[1];
|
||||||
if(cookieName == 'steamLogin') {
|
if (cookieName == 'steamLogin' || cookieName == 'steamLoginSecure') {
|
||||||
self.steamID = new SteamID(cookie.match(/=(\d+)/)[1]);
|
this.steamID = new SteamID(cookie.match(/=(\d+)/)[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
self._jar.setCookie(Request.cookie(cookie), (cookieName.match(/^steamMachineAuth/) || cookieName.match(/Secure$/) ? "https://" : "http://") + "steamcommunity.com");
|
this._setCookie(Request.cookie(cookie), !!(cookieName.match(/^steamMachineAuth/) || cookieName.match(/Secure$/)));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -137,56 +311,20 @@ SteamCommunity.prototype.getSessionID = function() {
|
|||||||
return decodeURIComponent(match[2]);
|
return decodeURIComponent(match[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var sessionID = generateSessionID();
|
var sessionID = generateSessionID();
|
||||||
this._jar.setCookie(Request.cookie('sessionid=' + sessionID), "http://steamcommunity.com");
|
this._setCookie(Request.cookie('sessionid=' + sessionID));
|
||||||
return sessionID;
|
return sessionID;
|
||||||
};
|
};
|
||||||
|
|
||||||
function generateSessionID() {
|
function generateSessionID() {
|
||||||
return Math.floor(Math.random() * 1000000000);
|
return require('crypto').randomBytes(12).toString('hex');
|
||||||
};
|
}
|
||||||
|
|
||||||
SteamCommunity.prototype.getWebApiKey = function(domain, callback) {
|
|
||||||
var self = this;
|
|
||||||
this.request({
|
|
||||||
"uri": "https://steamcommunity.com/dev/apikey",
|
|
||||||
"followRedirect": false
|
|
||||||
}, function(err, response, body) {
|
|
||||||
if(self._checkHttpError(err, response, callback)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(body.match(/<h2>Access Denied<\/h2>/)) {
|
|
||||||
return callback("Access Denied");
|
|
||||||
}
|
|
||||||
|
|
||||||
var match = body.match(/<p>Key: ([0-9A-F]+)<\/p>/);
|
|
||||||
if(match) {
|
|
||||||
// We already have an API key registered
|
|
||||||
callback(null, match[1]);
|
|
||||||
} else {
|
|
||||||
// We need to register a new API key
|
|
||||||
self.request.post('https://steamcommunity.com/dev/registerkey', {
|
|
||||||
"form": {
|
|
||||||
"domain": domain,
|
|
||||||
"agreeToTerms": "agreed",
|
|
||||||
"sessionid": self.getSessionID(),
|
|
||||||
"Submit": "Register"
|
|
||||||
}
|
|
||||||
}, function(err, response, body) {
|
|
||||||
if(self._checkHttpError(err, response, callback)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.getWebApiKey(domain, callback);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
SteamCommunity.prototype.parentalUnlock = function(pin, callback) {
|
SteamCommunity.prototype.parentalUnlock = function(pin, callback) {
|
||||||
this.request.post("https://steamcommunity.com/parental/ajaxunlock", {
|
var self = this;
|
||||||
|
|
||||||
|
this.httpRequestPost("https://steamcommunity.com/parental/ajaxunlock", {
|
||||||
"json": true,
|
"json": true,
|
||||||
"form": {
|
"form": {
|
||||||
"pin": pin
|
"pin": pin
|
||||||
@@ -195,144 +333,222 @@ SteamCommunity.prototype.parentalUnlock = function(pin, callback) {
|
|||||||
if(!callback) {
|
if(!callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(self._checkHttpError(err, response, callback)) {
|
if (err) {
|
||||||
|
callback(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!body || typeof body.success !== 'boolean') {
|
if (!body || typeof body.success !== 'boolean') {
|
||||||
return callback("Invalid response");
|
callback("Invalid response");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!body.success) {
|
if (!body.success) {
|
||||||
return callback("Incorrect PIN");
|
switch (body.eresult) {
|
||||||
|
case 15:
|
||||||
|
callback("Incorrect PIN");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 25:
|
||||||
|
callback("Too many invalid PIN attempts");
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
callback("Error " + body.eresult);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback();
|
callback();
|
||||||
}.bind(this));
|
}.bind(this), "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
SteamCommunity.prototype.getNotifications = function(callback) {
|
SteamCommunity.prototype.getNotifications = function(callback) {
|
||||||
this.request.get("https://steamcommunity.com/actions/RefreshNotificationArea", function(err, response, body) {
|
var self = this;
|
||||||
if(self._checkHttpError(err, response, callback)) {
|
this.httpRequestGet({
|
||||||
|
"uri": "https://steamcommunity.com/actions/GetNotificationCounts",
|
||||||
|
"json": true
|
||||||
|
}, function(err, response, body) {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var notifications = {
|
if (!body || !body.notifications) {
|
||||||
"comments": 0,
|
callback(new Error("Malformed response"));
|
||||||
"items": 0,
|
return;
|
||||||
"invites": 0,
|
|
||||||
"gifts": 0,
|
|
||||||
"chat": 0,
|
|
||||||
"trades": 0
|
|
||||||
};
|
|
||||||
|
|
||||||
var items = {
|
|
||||||
"comments": /(\d+) new comments?/,
|
|
||||||
"items": /(\d+) new items? in your inventory/,
|
|
||||||
"invites": /(\d+) new invites?/,
|
|
||||||
"gifts": /(\d+) new gifts?/,
|
|
||||||
"chat": /(\d+) unread chat messages?/,
|
|
||||||
"trades": /(\d+) new trade notifications?/
|
|
||||||
};
|
|
||||||
|
|
||||||
var match;
|
|
||||||
for(var i in items) {
|
|
||||||
if(match = body.match(items[i])) {
|
|
||||||
notifications[i] = parseInt(match[1], 10);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var notifications = {
|
||||||
|
"trades": body.notifications[1] || 0,
|
||||||
|
"gameTurns": body.notifications[2] || 0,
|
||||||
|
"moderatorMessages": body.notifications[3] || 0,
|
||||||
|
"comments": body.notifications[4] || 0,
|
||||||
|
"items": body.notifications[5] || 0,
|
||||||
|
"invites": body.notifications[6] || 0,
|
||||||
|
// dunno about 7
|
||||||
|
"gifts": body.notifications[8] || 0,
|
||||||
|
"chat": body.notifications[9] || 0,
|
||||||
|
"helpRequestReplies": body.notifications[10] || 0,
|
||||||
|
"accountAlerts": body.notifications[11] || 0
|
||||||
|
};
|
||||||
|
|
||||||
callback(null, notifications);
|
callback(null, notifications);
|
||||||
});
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
SteamCommunity.prototype.resetItemNotifications = function(callback) {
|
SteamCommunity.prototype.resetItemNotifications = function(callback) {
|
||||||
this.request.get("https://steamcommunity.com/my/inventory", function(err, response, body) {
|
var self = this;
|
||||||
|
this.httpRequestGet("https://steamcommunity.com/my/inventory", function(err, response, body) {
|
||||||
if(!callback) {
|
if(!callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(self._checkHttpError(err, response, callback)) {
|
callback(err || null);
|
||||||
return;
|
}, "steamcommunity");
|
||||||
}
|
|
||||||
|
|
||||||
callback(null);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SteamCommunity.prototype.loggedIn = function(callback) {
|
SteamCommunity.prototype.loggedIn = function(callback) {
|
||||||
this.request("https://steamcommunity.com/my", {"followRedirect": false}, function(err, response, body) {
|
this.httpRequestGet({
|
||||||
|
"uri": "https://steamcommunity.com/my",
|
||||||
|
"followRedirect": false,
|
||||||
|
"checkHttpError": false
|
||||||
|
}, function(err, response, body) {
|
||||||
if(err || (response.statusCode != 302 && response.statusCode != 403)) {
|
if(err || (response.statusCode != 302 && response.statusCode != 403)) {
|
||||||
callback(err || new Error("HTTP error " + response.statusCode));
|
callback(err || new Error("HTTP error " + response.statusCode));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(response.statusCode == 403) {
|
if(response.statusCode == 403) {
|
||||||
callback(null, true, true);
|
callback(null, true, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null, !!response.headers.location.match(/steamcommunity\.com(\/(id|profiles)\/[^\/]+)\/?/), false);
|
callback(null, !!response.headers.location.match(/steamcommunity\.com(\/(id|profiles)\/[^\/]+)\/?/), false);
|
||||||
});
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
SteamCommunity.prototype._checkCommunityError = function(html, callback) {
|
SteamCommunity.prototype.getTradeURL = function(callback) {
|
||||||
if(html.match(/<h1>Sorry!<\/h1>/)) {
|
this._myProfile("tradeoffers/privacy", null, (err, response, body) => {
|
||||||
var match = html.match(/<h3>(.+)<\/h3>/);
|
if (err) {
|
||||||
callback(new Error(match ? match[1] : "Unknown error occurred"));
|
callback(err);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
var match = body.match(/https?:\/\/(www.)?steamcommunity.com\/tradeoffer\/new\/?\?partner=\d+(&|&)token=([a-zA-Z0-9-_]+)/);
|
||||||
|
if (match) {
|
||||||
|
var token = match[3];
|
||||||
|
callback(null, match[0], token);
|
||||||
|
} else {
|
||||||
|
callback(new Error("Malformed response"));
|
||||||
|
}
|
||||||
|
}, "steamcommunity");
|
||||||
|
};
|
||||||
|
|
||||||
|
SteamCommunity.prototype.changeTradeURL = function(callback) {
|
||||||
|
this._myProfile("tradeoffers/newtradeurl", {"sessionid": this.getSessionID()}, (err, response, body) => {
|
||||||
|
if (!callback) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!body || typeof body !== "string" || body.length < 3 || body.indexOf('"') !== 0) {
|
||||||
|
callback(new Error("Malformed response"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var newToken = body.replace(/"/g, ''); //"t1o2k3e4n" => t1o2k3e4n
|
||||||
|
callback(null, "https://steamcommunity.com/tradeoffer/new/?partner=" + this.steamID.accountid + "&token=" + newToken, newToken);
|
||||||
|
}, "steamcommunity");
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear your profile name (alias) history.
|
||||||
|
* @param {function} callback
|
||||||
|
*/
|
||||||
|
SteamCommunity.prototype.clearPersonaNameHistory = function(callback) {
|
||||||
|
this._myProfile("ajaxclearaliashistory/", {"sessionid": this.getSessionID()}, (err, res, body) => {
|
||||||
|
if (!callback) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res.statusCode != 200) {
|
||||||
|
return callback(new Error("HTTP error " + res.statusCode));
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
body = JSON.parse(body);
|
||||||
|
callback(Helpers.eresultError(body.success));
|
||||||
|
} catch (ex) {
|
||||||
|
return callback(new Error("Malformed response"));
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
SteamCommunity.prototype._myProfile = function(endpoint, form, callback) {
|
SteamCommunity.prototype._myProfile = function(endpoint, form, callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.request("https://steamcommunity.com/my", {"followRedirect": false}, function(err, response, body) {
|
|
||||||
if(err || response.statusCode != 302) {
|
if (this._profileURL) {
|
||||||
callback(err || "HTTP error " + response.statusCode);
|
completeRequest(this._profileURL);
|
||||||
return;
|
} else {
|
||||||
|
this.httpRequest("https://steamcommunity.com/my", {"followRedirect": false}, function(err, response, body) {
|
||||||
|
if(err || response.statusCode != 302) {
|
||||||
|
callback(err || "HTTP error " + response.statusCode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var match = response.headers.location.match(/steamcommunity\.com(\/(id|profiles)\/[^\/]+)\/?/);
|
||||||
|
if(!match) {
|
||||||
|
callback(new Error("Can't get profile URL"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self._profileURL = match[1];
|
||||||
|
setTimeout(function () {
|
||||||
|
delete self._profileURL; // delete the cache
|
||||||
|
}, 60000).unref();
|
||||||
|
|
||||||
|
completeRequest(match[1]);
|
||||||
|
}, "steamcommunity");
|
||||||
|
}
|
||||||
|
|
||||||
|
function completeRequest(url) {
|
||||||
|
var options = endpoint.endpoint ? endpoint : {};
|
||||||
|
options.uri = "https://steamcommunity.com" + url + "/" + (endpoint.endpoint || endpoint);
|
||||||
|
|
||||||
|
if (form) {
|
||||||
|
options.method = "POST";
|
||||||
|
options.form = form;
|
||||||
|
options.followAllRedirects = true;
|
||||||
|
} else if (!options.method) {
|
||||||
|
options.method = "GET";
|
||||||
}
|
}
|
||||||
|
|
||||||
var match = response.headers.location.match(/steamcommunity\.com(\/(id|profiles)\/[^\/]+)\/?/);
|
self.httpRequest(options, callback, "steamcommunity");
|
||||||
if(!match) {
|
}
|
||||||
callback("Can't get profile URL");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
(form ? self.request.post : self.request)("https://steamcommunity.com" + match[1] + "/" + endpoint, form ? {"form": form} : {}, callback);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
SteamCommunity.prototype._checkHttpError = function(err, response, callback) {
|
|
||||||
if(err) {
|
|
||||||
callback(err);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(response.statusCode >= 300 && response.statusCode <= 399 && response.headers.location.indexOf('/login') != -1) {
|
|
||||||
callback(new Error("Not Logged In"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(response.statusCode >= 400) {
|
|
||||||
var error = new Error("HTTP error " + response.statusCode);
|
|
||||||
error.code = response.statusCode;
|
|
||||||
callback(error);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
require('./components/http.js');
|
||||||
require('./components/chat.js');
|
require('./components/chat.js');
|
||||||
require('./components/profile.js');
|
require('./components/profile.js');
|
||||||
require('./components/market.js');
|
require('./components/market.js');
|
||||||
require('./components/groups.js');
|
require('./components/groups.js');
|
||||||
require('./components/users.js');
|
require('./components/users.js');
|
||||||
require('./components/inventoryhistory.js');
|
require('./components/inventoryhistory.js');
|
||||||
|
require('./components/webapi.js');
|
||||||
|
require('./components/twofactor.js');
|
||||||
|
require('./components/confirmations.js');
|
||||||
require('./classes/CMarketItem.js');
|
require('./classes/CMarketItem.js');
|
||||||
require('./classes/CMarketSearchResult.js');
|
require('./classes/CMarketSearchResult.js');
|
||||||
require('./classes/CSteamGroup.js');
|
require('./classes/CSteamGroup.js');
|
||||||
require('./classes/CSteamUser.js');
|
require('./classes/CSteamUser.js');
|
||||||
|
|
||||||
|
/**
|
||||||
|
@callback SteamCommunity~genericErrorCallback
|
||||||
|
@param {Error|null} err - An Error object on failure, or null on success
|
||||||
|
*/
|
||||||
|
|||||||
31
package.json
31
package.json
@@ -1,23 +1,36 @@
|
|||||||
{
|
{
|
||||||
"name": "steamcommunity",
|
"name": "steamcommunity",
|
||||||
"version": "3.9.4",
|
"version": "3.41.2",
|
||||||
"description": "Provides an interface for logging into and interacting with the Steam Community website",
|
"description": "Provides an interface for logging into and interacting with the Steam Community website",
|
||||||
"keywords": ["steam", "steam community"],
|
"keywords": [
|
||||||
|
"steam",
|
||||||
|
"steam community"
|
||||||
|
],
|
||||||
"homepage": "https://github.com/DoctorMcKay/node-steamcommunity",
|
"homepage": "https://github.com/DoctorMcKay/node-steamcommunity",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/DoctorMcKay/node-steamcommunity/issues"
|
"url": "https://github.com/DoctorMcKay/node-steamcommunity/issues"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"author": {
|
||||||
|
"name": "Alex Corn",
|
||||||
|
"email": "mckay@doctormckay.com",
|
||||||
|
"url": "https://www.doctormckay.com"
|
||||||
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/DoctorMcKay/node-steamcommunity.git"
|
"url": "https://github.com/DoctorMcKay/node-steamcommunity.git"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"request": "^2.61.0",
|
"async": "^2.6.3",
|
||||||
"node-bignumber": "^1.2.1",
|
"cheerio": "0.22.0",
|
||||||
"steamid": "^0.3.1",
|
"image-size": "^0.8.2",
|
||||||
"xml2js": "^0.4.11",
|
"node-bignumber": "^1.2.1",
|
||||||
"cheerio": "^0.19.0",
|
"request": "^2.88.0",
|
||||||
"async": "^1.4.2"
|
"steam-totp": "^1.5.0",
|
||||||
|
"steamid": "^1.1.3",
|
||||||
|
"xml2js": "^0.4.22"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
14
resources/EChatState.js
Normal file
14
resources/EChatState.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
/**
|
||||||
|
* @enum EChatState
|
||||||
|
*/
|
||||||
|
module.exports = {
|
||||||
|
"Offline": 0,
|
||||||
|
"LoggingOn": 1,
|
||||||
|
"LogOnFailed": 2,
|
||||||
|
"LoggedOn": 3,
|
||||||
|
|
||||||
|
"0": "Offline",
|
||||||
|
"1": "LoggingOn",
|
||||||
|
"2": "LogOnFailed",
|
||||||
|
"3": "LoggedOn"
|
||||||
|
};
|
||||||
12
resources/EConfirmationType.js
Normal file
12
resources/EConfirmationType.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* @enum EConfirmationType
|
||||||
|
*/
|
||||||
|
module.exports = {
|
||||||
|
// 1 is unknown, possibly "Invalid"
|
||||||
|
"Trade": 2,
|
||||||
|
"MarketListing": 3,
|
||||||
|
// 4 is opt-out or other like account confirmation?
|
||||||
|
|
||||||
|
"2": "Trade",
|
||||||
|
"3": "MarketListing"
|
||||||
|
};
|
||||||
23
resources/EPersonaState.js
Normal file
23
resources/EPersonaState.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* @enum EPersonaState
|
||||||
|
*/
|
||||||
|
module.exports = {
|
||||||
|
"Offline": 0,
|
||||||
|
"Online": 1,
|
||||||
|
"Busy": 2,
|
||||||
|
"Away": 3,
|
||||||
|
"Snooze": 4,
|
||||||
|
"LookingToTrade": 5,
|
||||||
|
"LookingToPlay": 6,
|
||||||
|
"Max": 7,
|
||||||
|
|
||||||
|
// Value-to-name mapping for convenience
|
||||||
|
"0": "Offline",
|
||||||
|
"1": "Online",
|
||||||
|
"2": "Busy",
|
||||||
|
"3": "Away",
|
||||||
|
"4": "Snooze",
|
||||||
|
"5": "LookingToTrade",
|
||||||
|
"6": "LookingToPlay",
|
||||||
|
"7": "Max",
|
||||||
|
};
|
||||||
27
resources/EPersonaStateFlag.js
Normal file
27
resources/EPersonaStateFlag.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* @enum EPersonaStateFlag
|
||||||
|
*/
|
||||||
|
module.exports = {
|
||||||
|
"HasRichPresence": 1,
|
||||||
|
"InJoinableGame": 2,
|
||||||
|
"Golden": 4, // removed "no longer has any effect"
|
||||||
|
"OnlineUsingWeb": 256, // removed "renamed to ClientTypeWeb"
|
||||||
|
"ClientTypeWeb": 256,
|
||||||
|
"OnlineUsingMobile": 512, // removed "renamed to ClientTypeMobile"
|
||||||
|
"ClientTypeMobile": 512,
|
||||||
|
"OnlineUsingBigPicture": 1024, // removed "renamed to ClientTypeTenfoot"
|
||||||
|
"ClientTypeTenfoot": 1024,
|
||||||
|
"OnlineUsingVR": 2048, // removed "renamed to ClientTypeVR"
|
||||||
|
"ClientTypeVR": 2048,
|
||||||
|
"LaunchTypeGamepad": 4096,
|
||||||
|
|
||||||
|
// Value-to-name mapping for convenience
|
||||||
|
"1": "HasRichPresence",
|
||||||
|
"2": "InJoinableGame",
|
||||||
|
"4": "Golden",
|
||||||
|
"256": "ClientTypeWeb",
|
||||||
|
"512": "ClientTypeMobile",
|
||||||
|
"1024": "ClientTypeTenfoot",
|
||||||
|
"2048": "ClientTypeVR",
|
||||||
|
"4096": "LaunchTypeGamepad",
|
||||||
|
};
|
||||||
240
resources/EResult.js
Normal file
240
resources/EResult.js
Normal file
@@ -0,0 +1,240 @@
|
|||||||
|
/**
|
||||||
|
* @enum EResult
|
||||||
|
*/
|
||||||
|
module.exports = {
|
||||||
|
"Invalid": 0,
|
||||||
|
"OK": 1,
|
||||||
|
"Fail": 2,
|
||||||
|
"NoConnection": 3,
|
||||||
|
"InvalidPassword": 5,
|
||||||
|
"LoggedInElsewhere": 6,
|
||||||
|
"InvalidProtocolVer": 7,
|
||||||
|
"InvalidParam": 8,
|
||||||
|
"FileNotFound": 9,
|
||||||
|
"Busy": 10,
|
||||||
|
"InvalidState": 11,
|
||||||
|
"InvalidName": 12,
|
||||||
|
"InvalidEmail": 13,
|
||||||
|
"DuplicateName": 14,
|
||||||
|
"AccessDenied": 15,
|
||||||
|
"Timeout": 16,
|
||||||
|
"Banned": 17,
|
||||||
|
"AccountNotFound": 18,
|
||||||
|
"InvalidSteamID": 19,
|
||||||
|
"ServiceUnavailable": 20,
|
||||||
|
"NotLoggedOn": 21,
|
||||||
|
"Pending": 22,
|
||||||
|
"EncryptionFailure": 23,
|
||||||
|
"InsufficientPrivilege": 24,
|
||||||
|
"LimitExceeded": 25,
|
||||||
|
"Revoked": 26,
|
||||||
|
"Expired": 27,
|
||||||
|
"AlreadyRedeemed": 28,
|
||||||
|
"DuplicateRequest": 29,
|
||||||
|
"AlreadyOwned": 30,
|
||||||
|
"IPNotFound": 31,
|
||||||
|
"PersistFailed": 32,
|
||||||
|
"LockingFailed": 33,
|
||||||
|
"LogonSessionReplaced": 34,
|
||||||
|
"ConnectFailed": 35,
|
||||||
|
"HandshakeFailed": 36,
|
||||||
|
"IOFailure": 37,
|
||||||
|
"RemoteDisconnect": 38,
|
||||||
|
"ShoppingCartNotFound": 39,
|
||||||
|
"Blocked": 40,
|
||||||
|
"Ignored": 41,
|
||||||
|
"NoMatch": 42,
|
||||||
|
"AccountDisabled": 43,
|
||||||
|
"ServiceReadOnly": 44,
|
||||||
|
"AccountNotFeatured": 45,
|
||||||
|
"AdministratorOK": 46,
|
||||||
|
"ContentVersion": 47,
|
||||||
|
"TryAnotherCM": 48,
|
||||||
|
"PasswordRequiredToKickSession": 49,
|
||||||
|
"AlreadyLoggedInElsewhere": 50,
|
||||||
|
"Suspended": 51,
|
||||||
|
"Cancelled": 52,
|
||||||
|
"DataCorruption": 53,
|
||||||
|
"DiskFull": 54,
|
||||||
|
"RemoteCallFailed": 55,
|
||||||
|
"PasswordNotSet": 56, // removed "renamed to PasswordUnset"
|
||||||
|
"PasswordUnset": 56,
|
||||||
|
"ExternalAccountUnlinked": 57,
|
||||||
|
"PSNTicketInvalid": 58,
|
||||||
|
"ExternalAccountAlreadyLinked": 59,
|
||||||
|
"RemoteFileConflict": 60,
|
||||||
|
"IllegalPassword": 61,
|
||||||
|
"SameAsPreviousValue": 62,
|
||||||
|
"AccountLogonDenied": 63,
|
||||||
|
"CannotUseOldPassword": 64,
|
||||||
|
"InvalidLoginAuthCode": 65,
|
||||||
|
"AccountLogonDeniedNoMailSent": 66, // removed "renamed to AccountLogonDeniedNoMail"
|
||||||
|
"AccountLogonDeniedNoMail": 66,
|
||||||
|
"HardwareNotCapableOfIPT": 67,
|
||||||
|
"IPTInitError": 68,
|
||||||
|
"ParentalControlRestricted": 69,
|
||||||
|
"FacebookQueryError": 70,
|
||||||
|
"ExpiredLoginAuthCode": 71,
|
||||||
|
"IPLoginRestrictionFailed": 72,
|
||||||
|
"AccountLocked": 73, // removed "renamed to AccountLockedDown"
|
||||||
|
"AccountLockedDown": 73,
|
||||||
|
"AccountLogonDeniedVerifiedEmailRequired": 74,
|
||||||
|
"NoMatchingURL": 75,
|
||||||
|
"BadResponse": 76,
|
||||||
|
"RequirePasswordReEntry": 77,
|
||||||
|
"ValueOutOfRange": 78,
|
||||||
|
"UnexpectedError": 79,
|
||||||
|
"Disabled": 80,
|
||||||
|
"InvalidCEGSubmission": 81,
|
||||||
|
"RestrictedDevice": 82,
|
||||||
|
"RegionLocked": 83,
|
||||||
|
"RateLimitExceeded": 84,
|
||||||
|
"AccountLogonDeniedNeedTwoFactorCode": 85, // removed "renamed to AccountLoginDeniedNeedTwoFactor"
|
||||||
|
"AccountLoginDeniedNeedTwoFactor": 85,
|
||||||
|
"ItemOrEntryHasBeenDeleted": 86, // removed "renamed to ItemDeleted"
|
||||||
|
"ItemDeleted": 86,
|
||||||
|
"AccountLoginDeniedThrottle": 87,
|
||||||
|
"TwoFactorCodeMismatch": 88,
|
||||||
|
"TwoFactorActivationCodeMismatch": 89,
|
||||||
|
"AccountAssociatedToMultiplePlayers": 90, // removed "renamed to AccountAssociatedToMultiplePartners"
|
||||||
|
"AccountAssociatedToMultiplePartners": 90,
|
||||||
|
"NotModified": 91,
|
||||||
|
"NoMobileDeviceAvailable": 92, // removed "renamed to NoMobileDevice"
|
||||||
|
"NoMobileDevice": 92,
|
||||||
|
"TimeIsOutOfSync": 93, // removed "renamed to TimeNotSynced"
|
||||||
|
"TimeNotSynced": 93,
|
||||||
|
"SMSCodeFailed": 94,
|
||||||
|
"TooManyAccountsAccessThisResource": 95, // removed "renamed to AccountLimitExceeded"
|
||||||
|
"AccountLimitExceeded": 95,
|
||||||
|
"AccountActivityLimitExceeded": 96,
|
||||||
|
"PhoneActivityLimitExceeded": 97,
|
||||||
|
"RefundToWallet": 98,
|
||||||
|
"EmailSendFailure": 99,
|
||||||
|
"NotSettled": 100,
|
||||||
|
"NeedCaptcha": 101,
|
||||||
|
"GSLTDenied": 102,
|
||||||
|
"GSOwnerDenied": 103,
|
||||||
|
"InvalidItemType": 104,
|
||||||
|
"IPBanned": 105,
|
||||||
|
"GSLTExpired": 106,
|
||||||
|
"InsufficientFunds": 107,
|
||||||
|
"TooManyPending": 108,
|
||||||
|
"NoSiteLicensesFound": 109,
|
||||||
|
"WGNetworkSendExceeded": 110,
|
||||||
|
"AccountNotFriends": 111,
|
||||||
|
"LimitedUserAccount": 112,
|
||||||
|
|
||||||
|
// Value-to-name mapping for convenience
|
||||||
|
"0": "Invalid",
|
||||||
|
"1": "OK",
|
||||||
|
"2": "Fail",
|
||||||
|
"3": "NoConnection",
|
||||||
|
"5": "InvalidPassword",
|
||||||
|
"6": "LoggedInElsewhere",
|
||||||
|
"7": "InvalidProtocolVer",
|
||||||
|
"8": "InvalidParam",
|
||||||
|
"9": "FileNotFound",
|
||||||
|
"10": "Busy",
|
||||||
|
"11": "InvalidState",
|
||||||
|
"12": "InvalidName",
|
||||||
|
"13": "InvalidEmail",
|
||||||
|
"14": "DuplicateName",
|
||||||
|
"15": "AccessDenied",
|
||||||
|
"16": "Timeout",
|
||||||
|
"17": "Banned",
|
||||||
|
"18": "AccountNotFound",
|
||||||
|
"19": "InvalidSteamID",
|
||||||
|
"20": "ServiceUnavailable",
|
||||||
|
"21": "NotLoggedOn",
|
||||||
|
"22": "Pending",
|
||||||
|
"23": "EncryptionFailure",
|
||||||
|
"24": "InsufficientPrivilege",
|
||||||
|
"25": "LimitExceeded",
|
||||||
|
"26": "Revoked",
|
||||||
|
"27": "Expired",
|
||||||
|
"28": "AlreadyRedeemed",
|
||||||
|
"29": "DuplicateRequest",
|
||||||
|
"30": "AlreadyOwned",
|
||||||
|
"31": "IPNotFound",
|
||||||
|
"32": "PersistFailed",
|
||||||
|
"33": "LockingFailed",
|
||||||
|
"34": "LogonSessionReplaced",
|
||||||
|
"35": "ConnectFailed",
|
||||||
|
"36": "HandshakeFailed",
|
||||||
|
"37": "IOFailure",
|
||||||
|
"38": "RemoteDisconnect",
|
||||||
|
"39": "ShoppingCartNotFound",
|
||||||
|
"40": "Blocked",
|
||||||
|
"41": "Ignored",
|
||||||
|
"42": "NoMatch",
|
||||||
|
"43": "AccountDisabled",
|
||||||
|
"44": "ServiceReadOnly",
|
||||||
|
"45": "AccountNotFeatured",
|
||||||
|
"46": "AdministratorOK",
|
||||||
|
"47": "ContentVersion",
|
||||||
|
"48": "TryAnotherCM",
|
||||||
|
"49": "PasswordRequiredToKickSession",
|
||||||
|
"50": "AlreadyLoggedInElsewhere",
|
||||||
|
"51": "Suspended",
|
||||||
|
"52": "Cancelled",
|
||||||
|
"53": "DataCorruption",
|
||||||
|
"54": "DiskFull",
|
||||||
|
"55": "RemoteCallFailed",
|
||||||
|
"56": "PasswordUnset",
|
||||||
|
"57": "ExternalAccountUnlinked",
|
||||||
|
"58": "PSNTicketInvalid",
|
||||||
|
"59": "ExternalAccountAlreadyLinked",
|
||||||
|
"60": "RemoteFileConflict",
|
||||||
|
"61": "IllegalPassword",
|
||||||
|
"62": "SameAsPreviousValue",
|
||||||
|
"63": "AccountLogonDenied",
|
||||||
|
"64": "CannotUseOldPassword",
|
||||||
|
"65": "InvalidLoginAuthCode",
|
||||||
|
"66": "AccountLogonDeniedNoMail",
|
||||||
|
"67": "HardwareNotCapableOfIPT",
|
||||||
|
"68": "IPTInitError",
|
||||||
|
"69": "ParentalControlRestricted",
|
||||||
|
"70": "FacebookQueryError",
|
||||||
|
"71": "ExpiredLoginAuthCode",
|
||||||
|
"72": "IPLoginRestrictionFailed",
|
||||||
|
"73": "AccountLockedDown",
|
||||||
|
"74": "AccountLogonDeniedVerifiedEmailRequired",
|
||||||
|
"75": "NoMatchingURL",
|
||||||
|
"76": "BadResponse",
|
||||||
|
"77": "RequirePasswordReEntry",
|
||||||
|
"78": "ValueOutOfRange",
|
||||||
|
"79": "UnexpectedError",
|
||||||
|
"80": "Disabled",
|
||||||
|
"81": "InvalidCEGSubmission",
|
||||||
|
"82": "RestrictedDevice",
|
||||||
|
"83": "RegionLocked",
|
||||||
|
"84": "RateLimitExceeded",
|
||||||
|
"85": "AccountLoginDeniedNeedTwoFactor",
|
||||||
|
"86": "ItemDeleted",
|
||||||
|
"87": "AccountLoginDeniedThrottle",
|
||||||
|
"88": "TwoFactorCodeMismatch",
|
||||||
|
"89": "TwoFactorActivationCodeMismatch",
|
||||||
|
"90": "AccountAssociatedToMultiplePartners",
|
||||||
|
"91": "NotModified",
|
||||||
|
"92": "NoMobileDevice",
|
||||||
|
"93": "TimeNotSynced",
|
||||||
|
"94": "SMSCodeFailed",
|
||||||
|
"95": "AccountLimitExceeded",
|
||||||
|
"96": "AccountActivityLimitExceeded",
|
||||||
|
"97": "PhoneActivityLimitExceeded",
|
||||||
|
"98": "RefundToWallet",
|
||||||
|
"99": "EmailSendFailure",
|
||||||
|
"100": "NotSettled",
|
||||||
|
"101": "NeedCaptcha",
|
||||||
|
"102": "GSLTDenied",
|
||||||
|
"103": "GSOwnerDenied",
|
||||||
|
"104": "InvalidItemType",
|
||||||
|
"105": "IPBanned",
|
||||||
|
"106": "GSLTExpired",
|
||||||
|
"107": "InsufficientFunds",
|
||||||
|
"108": "TooManyPending",
|
||||||
|
"109": "NoSiteLicensesFound",
|
||||||
|
"110": "WGNetworkSendExceeded",
|
||||||
|
"111": "AccountNotFriends",
|
||||||
|
"112": "LimitedUserAccount",
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user