tiktok-livestream-chat-connector
Advanced tools
Comparing version 0.9.9 to 0.9.10
@@ -38,2 +38,6 @@ "use strict"; | ||
const { | ||
deserializeMessage | ||
} = require('./lib/webcastProtobuf.js'); | ||
const Config = require('./lib/webcastConfig.js'); | ||
@@ -52,2 +56,4 @@ | ||
QUESTIONNEW: 'questionNew', | ||
LINKMICBATTLE: 'linkMicBattle', | ||
LINKMICARMIES: 'linkMicArmies', | ||
RAWDATA: 'rawData', | ||
@@ -320,3 +326,20 @@ STREAMEND: 'streamEnd', | ||
} | ||
/** | ||
* Decoded a binary webcast data package that you have received via the 'rawData' event (for debugging purposes only) | ||
* @param {string} messageType | ||
* @param {Buffer} messageBuffer | ||
*/ | ||
decodeProtobufMessage(messageType, messageBuffer) { | ||
let webcastMessage = deserializeMessage(messageType, messageBuffer); | ||
_classPrivateMethodGet(this, _processWebcastResponse, _processWebcastResponse2).call(this, { | ||
messages: [{ | ||
decodedData: webcastMessage, | ||
type: messageType | ||
}] | ||
}); | ||
} | ||
} | ||
@@ -508,2 +531,10 @@ | ||
break; | ||
case 'WebcastLinkMicBattle': | ||
this.emit(Events.LINKMICBATTLE, simplifiedObj); | ||
break; | ||
case 'WebcastLinkMicArmies': | ||
this.emit(Events.LINKMICARMIES, simplifiedObj); | ||
break; | ||
} | ||
@@ -510,0 +541,0 @@ }); |
@@ -30,2 +30,32 @@ "use strict"; | ||
if (webcastObject.battleUsers) { | ||
let battleUsers = []; | ||
webcastObject.battleUsers.forEach(user => { | ||
var _user$battleGroup; | ||
if (user !== null && user !== void 0 && (_user$battleGroup = user.battleGroup) !== null && _user$battleGroup !== void 0 && _user$battleGroup.user) { | ||
battleUsers.push(getUserAttributes(user.battleGroup.user)); | ||
} | ||
}); | ||
webcastObject.battleUsers = battleUsers; | ||
} | ||
if (webcastObject.battleItems) { | ||
webcastObject.battleArmies = []; | ||
webcastObject.battleItems.forEach(battleItem => { | ||
battleItem.battleGroups.forEach(battleGroup => { | ||
let group = { | ||
hostUserId: battleItem.hostUserId.toString(), | ||
points: parseInt(battleGroup.points), | ||
participants: [] | ||
}; | ||
battleGroup.users.forEach(user => { | ||
group.participants.push(getUserAttributes(user)); | ||
}); | ||
webcastObject.battleArmies.push(group); | ||
}); | ||
}); | ||
delete webcastObject.battleItems; | ||
} | ||
return Object.assign({}, webcastObject); | ||
@@ -35,12 +65,25 @@ } | ||
function getUserAttributes(webcastUser) { | ||
var _webcastUser$profileP, _webcastUser$extraAtt; | ||
return { | ||
userId: webcastUser.userId.toString(), | ||
uniqueId: webcastUser.uniqueId, | ||
nickname: webcastUser.nickname, | ||
profilePictureUrl: webcastUser.profilePicture.urls[2] | ||
uniqueId: webcastUser.uniqueId !== '' ? webcastUser.uniqueId : undefined, | ||
nickname: webcastUser.nickname !== '' ? webcastUser.nickname : undefined, | ||
profilePictureUrl: (_webcastUser$profileP = webcastUser.profilePicture) === null || _webcastUser$profileP === void 0 ? void 0 : _webcastUser$profileP.urls[2], | ||
followRole: (_webcastUser$extraAtt = webcastUser.extraAttributes) === null || _webcastUser$extraAtt === void 0 ? void 0 : _webcastUser$extraAtt.followRole, | ||
userBadges: mapBadges(webcastUser.badge) | ||
}; | ||
} | ||
function mapBadges(badge) { | ||
if (!badge || !Array.isArray(badge.badges)) return []; | ||
let badges = []; | ||
badge.badges.forEach(badge => { | ||
badges.push(Object.assign({}, badge)); | ||
}); | ||
return badges; | ||
} | ||
module.exports = { | ||
simplifyObject | ||
}; |
@@ -36,2 +36,4 @@ "use strict"; | ||
case 'WebcastQuestionNewMessage': | ||
case 'WebcastLinkMicBattle': | ||
case 'WebcastLinkMicArmies': | ||
message.decodedData = tiktokSchema.lookupType(`TikTok.${message.type}`).decode(message.binary); | ||
@@ -38,0 +40,0 @@ break; |
{ | ||
"name": "tiktok-livestream-chat-connector", | ||
"version": "0.9.9", | ||
"version": "0.9.10", | ||
"description": "Node.js module to receive live stream events like comments and gifts from TikTok LIVE", | ||
@@ -31,3 +31,6 @@ "main": "index.js", | ||
"scraper", | ||
"websocket" | ||
"websocket", | ||
"bot", | ||
"broadcast", | ||
"reader" | ||
], | ||
@@ -34,0 +37,0 @@ "author": "zerodytrash", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49681
709