Compare commits

...
2 Commits
Author SHA1 Message Date
shanmite 1e2c04f6bc docs: 更新CHANGELOG 2023-01-05 10:21:52 +08:00
shanmite 92f1ad2085 fix: 自动评论没有正确评论所有抽奖 (#235)
Fixed #235
2023-01-05 10:19:34 +08:00
6 changed files with 29 additions and 18 deletions
+5
View File
@@ -1,5 +1,10 @@
<!-- markdownlint-disable MD036 MD024-->
# CHANGELOG
## 主要变化(2.7.1)
* 92f1ad2 fix: 自动评论没有正确评论所有抽奖 (#235)
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.7.0)
* c84cb3f feat: 评论内容从评论区随机获取 (#134)
* 4fa6d9a feat: 可关闭预约抽奖转发 (#196)
+4 -15
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;
/* 预约抽奖信息 */
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "lottery-auto-script",
"version": "2.7.0",
"version": "2.7.1",
"description": "自动参与B站动态抽奖",
"main": "main.js",
"scripts": {
+1 -1
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# version: <major.minor.patch>
level=minor
level=patch
npm version $level \
--no-commit-hooks \
+6
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"))
}
+12 -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)
},
])