fix: 自动评论没有正确评论所有抽奖 (#235)

Fixed #235
This commit is contained in:
shanmite 2023-01-05 10:19:34 +08:00
parent 3d5b2780af
commit 92f1ad2085
3 changed files with 22 additions and 16 deletions

View File

@ -69,6 +69,7 @@ function parseDynamicCard(dynamic_detail_card) {
, extendjsonToJson = strToJson(extend_json)
, { add_on_card_info = [] } = display
, { item } = cardToJson;
const dy_type2chat_type = new Map([[1, 17], [2, 11], [4, 17], [8, 1], [64, 12]]);
/* 转发者的UID */
obj.uid = desc.uid
/* 转发者的name */
@ -82,13 +83,7 @@ function parseDynamicCard(dynamic_detail_card) {
/* 用于发送评论 */
obj.rid_str = desc.rid_str.length > 12 ? desc.dynamic_id_str : desc.rid_str;
/* 用于发送评论 */
obj.chat_type = obj.type === 2
? 11
: obj.type === 4 || obj.type === 1
? 17
: obj.type === 8
? 1
: 0;
obj.chat_type = dy_type2chat_type.get(obj.type) || 0;
/* 转发者的动态ID !!!!此为大数需使用字符串值,不然JSON.parse()会有丢失精度 */
obj.dynamic_id = desc.dynamic_id_str;
/* 定位@信息 */
@ -129,17 +124,11 @@ function parseDynamicCard(dynamic_detail_card) {
/* 被转发者的UID */
obj.origin_uid = desc.origin.uid;
/* 源动态类型 */
obj.origin_type = desc.origin_type
obj.origin_type = desc.orig_type
/* 被转发者的rid(用于发评论) */
obj.origin_rid_str = desc.origin.rid_str.length > 12 ? desc.origin.dynamic_id_str : desc.origin.rid_str;
/* 用于发送评论 */
obj.origin_chat_type = obj.origin_type === 2
? 11
: obj.origin_type === 4 || obj.origin_type === 1
? 17
: obj.origin_type === 8
? 1
: 0;
obj.origin_chat_type = dy_type2chat_type.get(obj.origin_type) || 0
/* 被转发者的动态的ID !!!!此为大数需使用字符串值,不然JSON.parse()会有丢失精度 */
obj.origin_dynamic_id = desc.orig_dy_id_str;
/* 预约抽奖信息 */

View File

@ -6,9 +6,11 @@ const util = require('./util');
assert(await bili_client.getMyinfo());
await util.par_run([0, 1, 2, 3, 4], [
// 0
async () => {
assert.equal((await bili_client.getTopRcmd()).length, 10)
},
// 1
async () => {
assert.equal(await bili_client.sendChat(
(await bili_client.getOneDynamicByDyid("692193323569381399")).desc.rid,
@ -17,6 +19,7 @@ const util = require('./util');
7
)
},
// 2
async () => {
assert.equal(await bili_client.sendChat(
(await bili_client.getOneDynamicByDyid("11229466874154064")).desc.rid,
@ -25,12 +28,15 @@ const util = require('./util');
3
)
},
// 3
async () => {
assert.notEqual((await bili_client.searchArticlesByKeyword("专栏")).length, 0)
},
// 4
async () => {
assert.notEqual(await bili_client.sendChat("703886913053917267", "t", 17), 1)
},
// 5
async () => {
assert(!await bili_client.createDynamic("1"))
}

View File

@ -6,20 +6,31 @@ const util = require('./util');
(async () => {
assert(await bili_client.getMyinfo());
await util.par_run([0, 1, 2], [
await util.par_run([0, 1, 2, 3], [
// 0
async () => {
let info = await bili_client.getOneDynamicByDyid("728424890210713624");
assert(searcher.parseDynamicCard(info).is_charge_lottery);
},
// 1
async () => {
let info = await bili_client.getOneDynamicByDyid("728455586333589522");
assert(searcher.parseDynamicCard(info).origin_is_charge_lottery);
},
// 2
async () => {
let card = searcher.parseDynamicCard(await bili_client.getOneDynamicByDyid("746824225190314008"));
let chats = await bili_client.getChat(card.rid_str, card.chat_type)
assert(chats.length > 0 && typeof chats[0] == "string")
},
// 3
async () => {
let card = searcher.parseDynamicCard(await bili_client.getOneDynamicByDyid("747169355882561625"));
assert(card.chat_type == 11)
card = searcher.parseDynamicCard(await bili_client.getOneDynamicByDyid("747441158580338693"));
assert(card.chat_type == 17)
assert(card.origin_chat_type == 11)
},
])