steamutils 1.2.78 → 1.2.80
Sign up to get free protection for your applications and to get access to all the features.
- package/SteamClient.js +51 -45
- package/index.js +1 -2
- package/package.json +1 -1
package/SteamClient.js
CHANGED
@@ -1079,51 +1079,6 @@ function SteamClient({
|
|
1079
1079
|
"avatar_pending_review": null
|
1080
1080
|
}
|
1081
1081
|
},
|
1082
|
-
async friendMessage(data) {
|
1083
|
-
if (!data) return
|
1084
|
-
data.message_no_bbcode = data.message_no_bbcode?.replaceAll(`ː`, `:`)
|
1085
|
-
data.message = data.message?.replaceAll(`ː`, `:`)
|
1086
|
-
const example = {
|
1087
|
-
"steamid_friend": {
|
1088
|
-
"universe": 1,
|
1089
|
-
"type": 1,
|
1090
|
-
"instance": 1,
|
1091
|
-
"accountid": 1080136620
|
1092
|
-
},
|
1093
|
-
"chat_entry_type": 1,
|
1094
|
-
"from_limited_account": false,
|
1095
|
-
"message": "xxx",
|
1096
|
-
"ordinal": 0,
|
1097
|
-
"local_echo": false,
|
1098
|
-
"message_no_bbcode": "xxx",
|
1099
|
-
"low_priority": false,
|
1100
|
-
"server_timestamp": "2023-05-14T09:26:25.000Z",
|
1101
|
-
"message_bbcode_parsed": [
|
1102
|
-
"xxx"
|
1103
|
-
]
|
1104
|
-
}
|
1105
|
-
const timestamp = new Date(data.server_timestamp).getTime()
|
1106
|
-
const steamId = data.steamid_friend.getSteamID64()
|
1107
|
-
const personas = await getPersonas([steamId])
|
1108
|
-
const player_name = personas.find(p => p.id == steamId)?.player_name || ''
|
1109
|
-
const invite = [`Invited you to play a game!`, `Đã mời bạn chơi một trò chơi!`].includes(data.message_no_bbcode || data.message)
|
1110
|
-
const emotion = (data.message_no_bbcode || '').split(' ').find(m => m.startsWith(':') && m.endsWith(':'))
|
1111
|
-
|
1112
|
-
callEvent(events.friendMessage, {
|
1113
|
-
player_name,
|
1114
|
-
message: data.message_no_bbcode,
|
1115
|
-
invite,
|
1116
|
-
steamId,
|
1117
|
-
timestamp,
|
1118
|
-
from_limited_account: data.from_limited_account,
|
1119
|
-
emotion,
|
1120
|
-
})
|
1121
|
-
},
|
1122
|
-
async friendTyping(steamId, message) {
|
1123
|
-
callEvent(events.friendTyping, {
|
1124
|
-
steamId, message
|
1125
|
-
})
|
1126
|
-
},
|
1127
1082
|
async playingState(playing_blocked, playing_app) {
|
1128
1083
|
playingBlocked = playing_blocked
|
1129
1084
|
if (playing_app === 0) {
|
@@ -1184,6 +1139,53 @@ function SteamClient({
|
|
1184
1139
|
}
|
1185
1140
|
}
|
1186
1141
|
|
1142
|
+
const chatEvents = {
|
1143
|
+
async friendMessage(data) {
|
1144
|
+
if (!data) return
|
1145
|
+
data.message_no_bbcode = data.message_no_bbcode?.replaceAll(`ː`, `:`)
|
1146
|
+
data.message = data.message?.replaceAll(`ː`, `:`)
|
1147
|
+
const example = {
|
1148
|
+
"steamid_friend": {
|
1149
|
+
"universe": 1,
|
1150
|
+
"type": 1,
|
1151
|
+
"instance": 1,
|
1152
|
+
"accountid": 1080136620
|
1153
|
+
},
|
1154
|
+
"chat_entry_type": 1,
|
1155
|
+
"from_limited_account": false,
|
1156
|
+
"message": "xxx",
|
1157
|
+
"ordinal": 0,
|
1158
|
+
"local_echo": false,
|
1159
|
+
"message_no_bbcode": "xxx",
|
1160
|
+
"low_priority": false,
|
1161
|
+
"server_timestamp": "2023-05-14T09:26:25.000Z",
|
1162
|
+
"message_bbcode_parsed": [
|
1163
|
+
"xxx"
|
1164
|
+
]
|
1165
|
+
}
|
1166
|
+
const timestamp = new Date(data.server_timestamp).getTime()
|
1167
|
+
const steamId = data.steamid_friend.getSteamID64()
|
1168
|
+
const personas = await getPersonas([steamId])
|
1169
|
+
const player_name = personas.find(p => p.id == steamId)?.player_name || ''
|
1170
|
+
const invite = [`Invited you to play a game!`, `Đã mời bạn chơi một trò chơi!`].includes(data.message_no_bbcode || data.message)
|
1171
|
+
const emotion = (data.message_no_bbcode || '').split(' ').find(m => m.startsWith(':') && m.endsWith(':'))
|
1172
|
+
|
1173
|
+
callEvent(events.friendMessage, {
|
1174
|
+
player_name,
|
1175
|
+
message: data.message_no_bbcode,
|
1176
|
+
invite,
|
1177
|
+
steamId,
|
1178
|
+
timestamp,
|
1179
|
+
from_limited_account: data.from_limited_account,
|
1180
|
+
emotion,
|
1181
|
+
})
|
1182
|
+
},
|
1183
|
+
async friendTyping(steamId, message) {
|
1184
|
+
callEvent(events.friendTyping, {
|
1185
|
+
steamId, message
|
1186
|
+
})
|
1187
|
+
},
|
1188
|
+
}
|
1187
1189
|
|
1188
1190
|
// steamClient.on('lobbyInvite', (inviterID, lobbyID ) => {
|
1189
1191
|
// joinLobby(lobbyID)
|
@@ -1226,6 +1228,10 @@ function SteamClient({
|
|
1226
1228
|
for (const name in events) {
|
1227
1229
|
steamClient.on(name, events[name])
|
1228
1230
|
}
|
1231
|
+
|
1232
|
+
for (const name in chatEvents) {
|
1233
|
+
steamClient.chat.on(name, chatEvents[name])
|
1234
|
+
}
|
1229
1235
|
}
|
1230
1236
|
|
1231
1237
|
function getFriendList() {
|
package/index.js
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import cheerio from 'cheerio'
|
2
1
|
import {randomBytes} from 'crypto'
|
3
2
|
import sha256 from 'crypto-js/sha256.js'
|
4
3
|
import _ from 'lodash'
|
@@ -15,7 +14,7 @@ import {getTableHasHeaders, table2json} from './cheerio.js'
|
|
15
14
|
import {getJSObjectFronXML} from './xml2json.js'
|
16
15
|
import axios from 'axios'
|
17
16
|
import url from 'url'
|
18
|
-
import * as cheerio from
|
17
|
+
import * as cheerio from 'cheerio'
|
19
18
|
import fs from "fs";
|
20
19
|
import FormData from "form-data";
|
21
20
|
|