mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-06-04 21:01:17 +08:00
parent
4fa6d9ace4
commit
c84cb3f2b7
@ -337,7 +337,7 @@ class Monitor extends Searcher {
|
||||
uids, uname, dyid, reserve_id,
|
||||
reserve_lottery_text,
|
||||
is_charge_lottery,
|
||||
create_time,
|
||||
create_time, chat_type,
|
||||
ctrl, rid, des, type,
|
||||
hasOfficialLottery
|
||||
} = lottery_info;
|
||||
@ -528,14 +528,7 @@ class Monitor extends Searcher {
|
||||
onelotteryinfo.ctrl = JSON.stringify(new_ctrl);
|
||||
|
||||
/* 根据动态的类型决定评论的类型 */
|
||||
onelotteryinfo.chat_type =
|
||||
type === 2
|
||||
? 11
|
||||
: type === 4 || type === 1
|
||||
? 17
|
||||
: type === 8
|
||||
? 1
|
||||
: 0;
|
||||
onelotteryinfo.chat_type = chat_type;
|
||||
|
||||
/* 是否评论 */
|
||||
if (isSendChat) {
|
||||
@ -589,13 +582,16 @@ class Monitor extends Searcher {
|
||||
return 0
|
||||
}
|
||||
|
||||
let status = 0
|
||||
const
|
||||
let
|
||||
status = 0,
|
||||
{ uid, dyid, chat_type, rid, relay_chat, ctrl, chat } = option,
|
||||
{ check_if_duplicated, is_repost_then_chat, is_not_create_partition } = config;
|
||||
{ check_if_duplicated, is_copy_chat, is_repost_then_chat, is_not_create_partition } = config;
|
||||
|
||||
/* 评论 */
|
||||
if (rid && chat_type) {
|
||||
if (is_copy_chat) {
|
||||
chat = getRandomOne(await bili.getChat(rid, chat_type)) || "!!!"
|
||||
}
|
||||
|
||||
status = await retryfn(
|
||||
6,
|
||||
|
||||
@ -15,6 +15,7 @@ const { log } = utils
|
||||
* @property {boolean} is_liked
|
||||
* @property {number} create_time 10
|
||||
* @property {string} rid_str
|
||||
* @property {number} chat_type
|
||||
* @property {string} dynamic_id
|
||||
* @property {number} type
|
||||
* @property {string} description
|
||||
@ -27,8 +28,9 @@ const { log } = utils
|
||||
* @property {number} origin_uid
|
||||
* @property {string} origin_uname
|
||||
* @property {string} origin_rid_str
|
||||
* @property {number} origin_chat_type
|
||||
* @property {string} origin_dynamic_id
|
||||
* @property {number} orig_type
|
||||
* @property {number} origin_type
|
||||
* @property {string} origin_description
|
||||
* @property {string} origin_reserve_id
|
||||
* @property {string} origin_reserve_lottery_text
|
||||
@ -48,6 +50,7 @@ const { log } = utils
|
||||
* @property {string} reserve_lottery_text
|
||||
* @property {boolean} is_charge_lottery
|
||||
* @property {string} rid
|
||||
* @property {number} chat_type
|
||||
* @property {string} des
|
||||
* @property {number} type
|
||||
* @property {boolean} hasOfficialLottery 是否官方
|
||||
@ -78,8 +81,14 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
obj.type = desc.type
|
||||
/* 用于发送评论 */
|
||||
obj.rid_str = desc.rid_str.length > 12 ? desc.dynamic_id_str : desc.rid_str;
|
||||
/* 源动态类型 */
|
||||
obj.orig_type = desc.orig_type
|
||||
/* 用于发送评论 */
|
||||
obj.chat_type = obj.type === 2
|
||||
? 11
|
||||
: obj.type === 4 || obj.type === 1
|
||||
? 17
|
||||
: obj.type === 8
|
||||
? 1
|
||||
: 0;
|
||||
/* 转发者的动态ID !!!!此为大数需使用字符串值,不然JSON.parse()会有丢失精度 */
|
||||
obj.dynamic_id = desc.dynamic_id_str;
|
||||
/* 定位@信息 */
|
||||
@ -109,6 +118,7 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
(item && (item.content || '' + item.description || ''))
|
||||
|| (cardToJson.dynamic || '' + cardToJson.desc || '')
|
||||
|| '';
|
||||
/* 转发 */
|
||||
if (obj.type === 1) {
|
||||
const { origin_extension, origin } = cardToJson
|
||||
, originToJson = strToJson(origin)
|
||||
@ -118,8 +128,18 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
obj.origin_create_time = desc.origin.timestamp;
|
||||
/* 被转发者的UID */
|
||||
obj.origin_uid = desc.origin.uid;
|
||||
/* 源动态类型 */
|
||||
obj.origin_type = desc.origin_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;
|
||||
/* 被转发者的动态的ID !!!!此为大数需使用字符串值,不然JSON.parse()会有丢失精度 */
|
||||
obj.origin_dynamic_id = desc.orig_dy_id_str;
|
||||
/* 预约抽奖信息 */
|
||||
@ -319,8 +339,9 @@ class Searcher {
|
||||
reserve_lottery_text: cur.origin_reserve_lottery_text,
|
||||
is_charge_lottery: cur.origin_is_charge_lottery,
|
||||
rid: cur.origin_rid_str,
|
||||
chat_type: cur.origin_chat_type,
|
||||
des: cur.origin_description,
|
||||
type: cur.orig_type,
|
||||
type: cur.origin_type,
|
||||
hasOfficialLottery: cur.origin_hasOfficialLottery
|
||||
})
|
||||
|
||||
@ -381,6 +402,7 @@ class Searcher {
|
||||
reserve_lottery_text: o.reserve_lottery_text,
|
||||
is_charge_lottery: o.is_charge_lottery,
|
||||
rid: o.rid_str,
|
||||
chat_type: o.chat_type,
|
||||
des: o.description,
|
||||
type: o.type,
|
||||
hasOfficialLottery: o.hasOfficialLottery
|
||||
@ -473,6 +495,7 @@ class Searcher {
|
||||
reserve_lottery_text: o.reserve_lottery_text,
|
||||
is_charge_lottery: o.is_charge_lottery,
|
||||
rid: o.rid_str,
|
||||
chat_type: o.chat_type,
|
||||
des: o.description,
|
||||
type: o.type,
|
||||
hasOfficialLottery: o.hasOfficialLottery
|
||||
|
||||
@ -331,6 +331,11 @@ const config = {
|
||||
'坚持不懈,迎难而上,开拓创新!', '[OK][OK]', '我来抽个奖', '中中中中中中', '[doge][doge][doge]', '我我我',
|
||||
],
|
||||
|
||||
/**
|
||||
* 是否抄热评
|
||||
*/
|
||||
is_copy_chat: false,
|
||||
|
||||
/**
|
||||
* - 抽奖UP用户分组id(网页端点击分区后地址栏中的tagid)
|
||||
* - 自动获取
|
||||
|
||||
@ -17,8 +17,8 @@ async function createRandomDynamic(num) {
|
||||
[null],
|
||||
() => Searcher.checkAllDynamic(global_var.get("myUID"), 1)
|
||||
)) || { allModifyDynamicResArray: [] },
|
||||
{ type, orig_type } = allModifyDynamicResArray[0] || {};
|
||||
if (type === 1 && orig_type !== 8) {
|
||||
{ type, origin_type } = allModifyDynamicResArray[0] || {};
|
||||
if (type === 1 && origin_type !== 8) {
|
||||
await randomDynamic(num)
|
||||
} else {
|
||||
log.info('随机动态', '已有非抽奖动态故无需创建');
|
||||
|
||||
@ -29,10 +29,11 @@ module.exports = Object.freeze({
|
||||
SESSION_SVR_UPDATE_ACK: 'https://api.vc.bilibili.com/session_svr/v1/session_svr/update_ack',
|
||||
SPACE_MYINFO: 'https://api.bilibili.com/x/space/myinfo',
|
||||
TAG_INFO: 'https://api.bilibili.com/x/tag/info',
|
||||
TOP_RCMD: "https://api.bilibili.com/x/web-interface/index/top/rcmd",
|
||||
TOP_FEED_RCMD: "https://api.bilibili.com/x/web-interface/index/top/feed/rcmd",
|
||||
TOP_RCMD: "https://api.bilibili.com/x/web-interface/index/top/rcmd",
|
||||
TOPIC_SVR_TOPIC_HISTORY: 'https://api.vc.bilibili.com/topic_svr/v1/topic_svr/topic_history',
|
||||
TOPIC_SVR_TOPIC_NEW: 'https://api.vc.bilibili.com/topic_svr/v1/topic_svr/topic_new',
|
||||
V2_REPLAY: "https://api.bilibili.com/x/v2/reply",
|
||||
WEB_INTERFACE_CARD: 'https://api.bilibili.com/x/web-interface/card',
|
||||
WEB_INTERFACE_SEARCH_TYPE: 'https://api.bilibili.com/x/web-interface/search/type',
|
||||
})
|
||||
@ -1044,6 +1044,35 @@ const bili_client = {
|
||||
return 1;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 查询评论
|
||||
* @param {*} rid
|
||||
* @param {*} type
|
||||
* @returns {Promise<Array<string>>}
|
||||
*/
|
||||
async getChat(rid, type) {
|
||||
const
|
||||
responseText = await get({
|
||||
url: API.V2_REPLAY,
|
||||
query: {
|
||||
oid: rid,
|
||||
type: type,
|
||||
}
|
||||
}),
|
||||
res = strToJson(responseText);
|
||||
switch (res.code) {
|
||||
case 0:
|
||||
log.info('查询评论', `成功`);
|
||||
try {
|
||||
return res.data.replies.map(it => it.content.message);
|
||||
} catch (_) {
|
||||
return []
|
||||
}
|
||||
default:
|
||||
log.error('查询评论', `未知错误\n${responseText}`);
|
||||
return [];
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 检查分区
|
||||
* 不存在指定分区时创建
|
||||
|
||||
@ -103,7 +103,7 @@ module.exports = Object.freeze({
|
||||
disable_reserve_lottery: false,
|
||||
|
||||
/**
|
||||
* 不转发预约抽奖
|
||||
* 不转关预约抽奖
|
||||
* - 预约抽奖可能与转发抽奖并存
|
||||
*/
|
||||
is_not_relay_reserve_lottery: false,
|
||||
@ -338,6 +338,11 @@ module.exports = Object.freeze({
|
||||
'坚持不懈,迎难而上,开拓创新!', '[OK][OK]', '我来抽个奖', '中中中中中中', '[doge][doge][doge]', '我我我',
|
||||
],
|
||||
|
||||
/**
|
||||
* 是否抄热评
|
||||
*/
|
||||
is_copy_chat: false,
|
||||
|
||||
/**
|
||||
* - 抽奖UP用户分组id(网页端点击分区后地址栏中的tagid)
|
||||
* - 自动获取
|
||||
|
||||
@ -1,17 +1,29 @@
|
||||
const assert = require('assert');
|
||||
const bili_client = require("../lib/net/bili");
|
||||
const searcher = require("../lib/core/searcher");
|
||||
const util = require('./util');
|
||||
|
||||
(async () => {
|
||||
assert(await bili_client.getMyinfo());
|
||||
|
||||
let info = await bili_client.getOneDynamicByDyid("728424890210713624");
|
||||
await util.par_run([0, 1, 2], [
|
||||
async () => {
|
||||
let info = await bili_client.getOneDynamicByDyid("728424890210713624");
|
||||
assert(searcher.parseDynamicCard(info).is_charge_lottery);
|
||||
},
|
||||
async () => {
|
||||
let info = await bili_client.getOneDynamicByDyid("728455586333589522");
|
||||
assert(searcher.parseDynamicCard(info).origin_is_charge_lottery);
|
||||
},
|
||||
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")
|
||||
},
|
||||
])
|
||||
|
||||
assert(searcher.parseDynamicCard(info).is_charge_lottery);
|
||||
|
||||
info = await bili_client.getOneDynamicByDyid("728455586333589522");
|
||||
|
||||
assert(searcher.parseDynamicCard(info).origin_is_charge_lottery);
|
||||
|
||||
console.log("dynamic_card.test ... ok!");
|
||||
})()
|
||||
Loading…
Reference in New Issue
Block a user