mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-07-22 21:13:47 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1e2c04f6bc | ||
|
|
92f1ad2085 | ||
|
|
3d5b2780af | ||
|
|
c84cb3f2b7 | ||
|
|
4fa6d9ace4 | ||
|
|
0814154c7a | ||
|
|
5097f2af39 | ||
|
|
cb08e7afe0 | ||
|
|
7b5a1778ea | ||
|
|
63b550edca |
@@ -11,6 +11,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Mirror + trigger CI
|
||||
uses: SvanBoxel/gitlab-mirror-and-ci-action@master
|
||||
with:
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
<!-- 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)
|
||||
* 0814154 feat: 关注分区移动可关闭 (#228)
|
||||
* 5097f2a feat: 清理动态时显示UID保护列表 (#229)
|
||||
* cb08e7a feat: 过滤掉充电包月抽奖 (#224)
|
||||
* 7b5a177 refactor: 调整推送格式 (#223)
|
||||
* 63b550e ci(mirror): shallow update not allowed
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.6.9)
|
||||
* 28fc79e fix: 通知内不显示抽奖信息
|
||||
* 9e6fe66 fix: free `log._cache`
|
||||
|
||||
+3
-3
@@ -25,7 +25,7 @@ async function isMe(num) {
|
||||
desp += '- - - -\n\n'
|
||||
desp += `发生时间: ${new Date(at_time * 1000).toLocaleString()}\n\n`
|
||||
desp += `用户: ${up_uname}\n\n`
|
||||
desp += `在${business}中@了你(https://space.bilibili.com/${global_var.get("myUID")})\n\n`
|
||||
desp += `在${business}中@了[你](https://space.bilibili.com/${global_var.get("myUID")})\n\n`
|
||||
desp += `原内容为: ${source_content}\n\n`
|
||||
desp += `[直达链接](${url})\n\n`
|
||||
desp += '- - - -\n\n'
|
||||
@@ -43,7 +43,7 @@ async function isMe(num) {
|
||||
desp += '- - - -\n\n'
|
||||
desp += `发生时间: ${new Date(timestamp * 1000).toLocaleString()}\n\n`
|
||||
desp += `用户: ${nickname}\n\n`
|
||||
desp += `回复你(https://space.bilibili.com/${global_var.get("myUID")})说:\n${source}\n\n`
|
||||
desp += `回复[你](https://space.bilibili.com/${global_var.get("myUID")})说:\n${source}\n\n`
|
||||
desp += `[直达链接](${uri})\n\n`
|
||||
desp += '- - - -\n\n'
|
||||
}
|
||||
@@ -66,7 +66,7 @@ async function isMe(num) {
|
||||
desp += '- - - -\n\n'
|
||||
desp += `发生时间: ${new Date(timestamp * 1000).toLocaleString()}\n\n`
|
||||
desp += `用户: ${sender_uid}\n\n`
|
||||
desp += `私信你(https://space.bilibili.com/${global_var.get("myUID")})说:\n${content}\n\n`
|
||||
desp += `私信[你](https://space.bilibili.com/${global_var.get("myUID")})说:\n${content}\n\n`
|
||||
desp += `[直达链接](https://message.bilibili.com/#/whisper/mid${sender_uid})\n\n`
|
||||
desp += '- - - -\n\n'
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ async function clear() {
|
||||
const days_ago = (Now - create_time) / 86400;
|
||||
|
||||
if (days_ago > clear_max_day) {
|
||||
log.info('清理动态', `当前UID保护列表:\n${before_separate.join(',')}\n`)
|
||||
/* 移除动态 */
|
||||
if (dynamic_id
|
||||
&& clear_remove_dynamic
|
||||
|
||||
+44
-20
@@ -37,7 +37,8 @@ class Monitor extends Searcher {
|
||||
event_bus.emit('Turn_off_the_Monitor', '已关闭所有转发行为')
|
||||
return
|
||||
}
|
||||
if (!this.tagid) {
|
||||
if (!this.tagid
|
||||
&& config.is_not_create_partition !== true) {
|
||||
this.tagid = await bili.checkMyPartition() /* 检查关注分区 */
|
||||
if (!this.tagid) {
|
||||
event_bus.emit('Turn_off_the_Monitor', '分区获取失败')
|
||||
@@ -262,7 +263,16 @@ class Monitor extends Searcher {
|
||||
/** 所有抽奖信息 */
|
||||
let alllotteryinfo = [];
|
||||
const
|
||||
{ check_if_duplicated, save_lottery_info_to_file, set_lottery_info_url, disable_reserve_lottery, reserve_lottery_wait, sneaktower, key_words, model, chatmodel, chat: chats, relay: relays, block_dynamic_type, max_create_time, is_imitator, only_followed, at_users, blockword, blacklist, use_public_blacklist } = config,
|
||||
{
|
||||
check_if_duplicated, save_lottery_info_to_file,
|
||||
set_lottery_info_url, disable_reserve_lottery,
|
||||
is_not_relay_reserve_lottery,
|
||||
reserve_lottery_wait, sneaktower, key_words,
|
||||
model, chatmodel, chat: chats, relay: relays,
|
||||
block_dynamic_type, max_create_time, is_imitator,
|
||||
only_followed, at_users, blockword, blacklist,
|
||||
use_public_blacklist
|
||||
} = config,
|
||||
now_ts = Date.now() / 1000;
|
||||
|
||||
/**
|
||||
@@ -324,7 +334,10 @@ class Monitor extends Searcher {
|
||||
await try_for_each(protoLotteryInfo, async function (lottery_info) {
|
||||
const {
|
||||
lottery_info_type, is_liked,
|
||||
uids, uname, dyid, reserve_id, reserve_lottery_text, create_time,
|
||||
uids, uname, dyid, reserve_id,
|
||||
reserve_lottery_text,
|
||||
is_charge_lottery,
|
||||
create_time, chat_type,
|
||||
ctrl, rid, des, type,
|
||||
hasOfficialLottery
|
||||
} = lottery_info;
|
||||
@@ -350,6 +363,11 @@ class Monitor extends Searcher {
|
||||
return false
|
||||
}
|
||||
|
||||
if (is_charge_lottery) {
|
||||
log.info("筛选动态", `充电抽奖(https://t.bilibili.com/${dyid})`)
|
||||
return false
|
||||
}
|
||||
|
||||
const
|
||||
[m_uid, ori_uid] = uids,
|
||||
mIsFollowed = !m_uid || (new RegExp(m_uid)).test(attentionList),
|
||||
@@ -424,6 +442,10 @@ class Monitor extends Searcher {
|
||||
} else {
|
||||
await delay(reserve_lottery_wait);
|
||||
await bili.reserve_lottery(reserve_id)
|
||||
if (is_not_relay_reserve_lottery === true) {
|
||||
log.info("预约抽奖", "已关闭预约抽奖转发功能");
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -506,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) {
|
||||
@@ -567,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 } = 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,
|
||||
@@ -607,13 +625,19 @@ class Monitor extends Searcher {
|
||||
if (status) {
|
||||
log.warn("抽奖信息", `dyid: ${dyid}, uid: ${u}`)
|
||||
return true
|
||||
} else if (await bili.movePartition(u, this.tagid)) {
|
||||
log.warn("抽奖信息", `dyid: ${dyid}, uid: ${u} tagid: ${this.tagid}`)
|
||||
/* 3000系错误 */
|
||||
status = 1001
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
if (is_not_create_partition !== true) {
|
||||
if (await bili.movePartition(u, this.tagid)) {
|
||||
log.warn("抽奖信息", `dyid: ${dyid}, uid: ${u} tagid: ${this.tagid}`)
|
||||
/* 3000系错误 */
|
||||
status = 1001
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
})
|
||||
if (status) return 2000 + status
|
||||
|
||||
+32
-6
@@ -15,22 +15,26 @@ 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
|
||||
* @property {string} reserve_id
|
||||
* @property {string} reserve_lottery_text
|
||||
* @property {boolean} is_charge_lottery
|
||||
* @property {boolean} hasOfficialLottery
|
||||
* @property {Array<Object.<string,string|number>>} ctrl
|
||||
* @property {number} origin_create_time 10
|
||||
* @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
|
||||
* @property {boolean} origin_is_charge_lottery
|
||||
* @property {boolean} origin_hasOfficialLottery
|
||||
*
|
||||
* 整理后的抽奖信息
|
||||
@@ -44,7 +48,9 @@ const { log } = utils
|
||||
* @property {string} dyid
|
||||
* @property {string} reserve_id
|
||||
* @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 是否官方
|
||||
@@ -63,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 */
|
||||
@@ -75,8 +82,8 @@ 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 = dy_type2chat_type.get(obj.type) || 0;
|
||||
/* 转发者的动态ID !!!!此为大数需使用字符串值,不然JSON.parse()会有丢失精度 */
|
||||
obj.dynamic_id = desc.dynamic_id_str;
|
||||
/* 定位@信息 */
|
||||
@@ -96,6 +103,9 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
obj.reserve_lottery_text = text;
|
||||
}
|
||||
}
|
||||
if (JSON.stringify(add_on_card_info).match(/充电专属抽奖/)) {
|
||||
obj.is_charge_lottery = true
|
||||
}
|
||||
/* 是否有官方抽奖 */
|
||||
obj.hasOfficialLottery = extension && extension.lott && true;
|
||||
/* 转发者的描述 纯文字内容 图片动态描述 后两个分别是视频动态的描述和视频本身的描述*/
|
||||
@@ -103,6 +113,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)
|
||||
@@ -112,8 +123,12 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
obj.origin_create_time = desc.origin.timestamp;
|
||||
/* 被转发者的UID */
|
||||
obj.origin_uid = desc.origin.uid;
|
||||
/* 源动态类型 */
|
||||
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 = dy_type2chat_type.get(obj.origin_type) || 0
|
||||
/* 被转发者的动态的ID !!!!此为大数需使用字符串值,不然JSON.parse()会有丢失精度 */
|
||||
obj.origin_dynamic_id = desc.orig_dy_id_str;
|
||||
/* 预约抽奖信息 */
|
||||
@@ -131,6 +146,9 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
obj.origin_reserve_lottery_text = text;
|
||||
}
|
||||
}
|
||||
if (JSON.stringify(add_on_card_info).match(/充电专属抽奖/)) {
|
||||
obj.origin_is_charge_lottery = true
|
||||
}
|
||||
/* 是否有官方抽奖 */
|
||||
obj.origin_hasOfficialLottery = origin_extension && origin_extension.lott;
|
||||
/* 被转发者的name */
|
||||
@@ -256,6 +274,7 @@ class Searcher {
|
||||
|
||||
return ({ allModifyDynamicResArray, offset });
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最新动态信息(转发子动态)
|
||||
* 并初步整理
|
||||
@@ -307,9 +326,11 @@ class Searcher {
|
||||
dyid: cur.origin_dynamic_id,
|
||||
reserve_id: cur.origin_reserve_id,
|
||||
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
|
||||
})
|
||||
|
||||
@@ -320,6 +341,7 @@ class Searcher {
|
||||
|
||||
return fomatdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取tag下的抽奖信息(转发母动态)
|
||||
* 并初步整理
|
||||
@@ -367,7 +389,9 @@ class Searcher {
|
||||
dyid: o.dynamic_id,
|
||||
reserve_id: o.reserve_id,
|
||||
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
|
||||
@@ -377,6 +401,7 @@ class Searcher {
|
||||
|
||||
return fomatdata
|
||||
}
|
||||
|
||||
/**
|
||||
* 从专栏中获取抽奖信息
|
||||
* @param {string} key_words
|
||||
@@ -457,7 +482,9 @@ class Searcher {
|
||||
dyid: o.dynamic_id,
|
||||
reserve_id: o.reserve_id,
|
||||
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
|
||||
@@ -548,5 +575,4 @@ class Searcher {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = { Searcher };
|
||||
module.exports = { Searcher, parseDynamicCard };
|
||||
|
||||
@@ -100,6 +100,11 @@ const config = {
|
||||
*/
|
||||
disable_reserve_lottery: false,
|
||||
|
||||
/**
|
||||
* 不转发预约抽奖
|
||||
* - 预约抽奖可能与转发抽奖并存
|
||||
*/
|
||||
is_not_relay_reserve_lottery: false,
|
||||
|
||||
/**
|
||||
* 检查是否重复转发
|
||||
@@ -326,12 +331,22 @@ const config = {
|
||||
'坚持不懈,迎难而上,开拓创新!', '[OK][OK]', '我来抽个奖', '中中中中中中', '[doge][doge][doge]', '我我我',
|
||||
],
|
||||
|
||||
/**
|
||||
* 是否抄热评
|
||||
*/
|
||||
is_copy_chat: false,
|
||||
|
||||
/**
|
||||
* - 抽奖UP用户分组id(网页端点击分区后地址栏中的tagid)
|
||||
* - 自动获取
|
||||
*/
|
||||
partition_id: 0,
|
||||
|
||||
/**
|
||||
* - 是否不为抽奖UP单独设置关注分区
|
||||
*/
|
||||
is_not_create_partition: false,
|
||||
|
||||
/**
|
||||
* 是否关注异常
|
||||
*/
|
||||
|
||||
@@ -178,7 +178,7 @@ if (process.env.SMTP_TO_USER) {
|
||||
|
||||
async function sendNotify(text, desp, params = {}) {
|
||||
if (process.env.NOTE) {
|
||||
desp += `\n帐号备注: ${process.env.NOTE}`
|
||||
desp = `帐号备注: ${process.env.NOTE}\n${desp}`
|
||||
}
|
||||
//提供多种通知方式
|
||||
await Promise.all([
|
||||
|
||||
+2
-2
@@ -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('随机动态', '已有非抽奖动态故无需创建');
|
||||
|
||||
+2
-1
@@ -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 [];
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 检查分区
|
||||
* 不存在指定分区时创建
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
//@ts-check
|
||||
/**
|
||||
* @typedef {import("http").IncomingHttpHeaders} HttpHeaders 头部信息
|
||||
*
|
||||
|
||||
@@ -102,6 +102,12 @@ module.exports = Object.freeze({
|
||||
*/
|
||||
disable_reserve_lottery: false,
|
||||
|
||||
/**
|
||||
* 不转关预约抽奖
|
||||
* - 预约抽奖可能与转发抽奖并存
|
||||
*/
|
||||
is_not_relay_reserve_lottery: false,
|
||||
|
||||
/**
|
||||
* 检查是否重复转发
|
||||
* - 不检查 -1
|
||||
@@ -332,12 +338,22 @@ module.exports = Object.freeze({
|
||||
'坚持不懈,迎难而上,开拓创新!', '[OK][OK]', '我来抽个奖', '中中中中中中', '[doge][doge][doge]', '我我我',
|
||||
],
|
||||
|
||||
/**
|
||||
* 是否抄热评
|
||||
*/
|
||||
is_copy_chat: false,
|
||||
|
||||
/**
|
||||
* - 抽奖UP用户分组id(网页端点击分区后地址栏中的tagid)
|
||||
* - 自动获取
|
||||
*/
|
||||
partition_id: 0,
|
||||
|
||||
/**
|
||||
* - 是否不为抽奖UP单独设置关注分区
|
||||
*/
|
||||
is_not_create_partition: false,
|
||||
|
||||
/**
|
||||
* 是否关注异常
|
||||
*/
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "lottery-auto-script",
|
||||
"version": "2.6.9",
|
||||
"version": "2.7.1",
|
||||
"description": "自动参与B站动态抽奖",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
||||
+8
-2
@@ -5,10 +5,12 @@ const util = require('./util');
|
||||
(async () => {
|
||||
assert(await bili_client.getMyinfo());
|
||||
|
||||
await util.par_run([
|
||||
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,14 +28,17 @@ 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("123"))
|
||||
assert(!await bili_client.createDynamic("1"))
|
||||
}
|
||||
])
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
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());
|
||||
|
||||
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)
|
||||
},
|
||||
])
|
||||
|
||||
|
||||
|
||||
|
||||
console.log("dynamic_card.test ... ok!");
|
||||
})()
|
||||
+5
-2
@@ -1,8 +1,11 @@
|
||||
/**
|
||||
* @param {Array<number>} nums
|
||||
* @param {Array<()=>any>} fns
|
||||
*/
|
||||
function par_run(fns) {
|
||||
return Promise.all((fns.map(fn => fn())))
|
||||
function par_run(nums, fns) {
|
||||
return Promise.all(
|
||||
nums.map(num => fns[num]())
|
||||
)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user