Compare commits

...
12 Commits
Author SHA1 Message Date
shanmite 3d5b2780af docs: 更新CHANGELOG 2023-01-03 15:58:38 +08:00
shanmite c84cb3f2b7 feat: 评论内容从评论区随机获取 (#134)
Fixed #134
2023-01-03 14:50:42 +08:00
shanmite 4fa6d9ace4 feat: 可关闭预约抽奖转发 (#196)
Fixed #196
2023-01-03 13:01:21 +08:00
shanmite 0814154c7a feat: 关注分区移动可关闭 (#228)
Fixed #228
2023-01-03 12:39:46 +08:00
shanmite 5097f2af39 feat: 清理动态时显示UID保护列表 (#229) 2023-01-03 12:06:08 +08:00
shanmite cb08e7afe0 feat: 过滤掉充电包月抽奖 (#224)
Fixed #224
2023-01-03 11:59:39 +08:00
shanmite 7b5a1778ea refactor: 调整推送格式 (#223) 2022-11-16 15:12:46 +08:00
shanmite 63b550edca ci(mirror): shallow update not allowed 2022-11-15 15:08:56 +08:00
shanmite 1bf0bd7d19 docs: 更新CHANGELOG 2022-11-15 14:51:36 +08:00
shanmite 28fc79ea33 fix: 通知内不显示抽奖信息 2022-11-15 14:49:57 +08:00
shanmite 9e6fe661ca fix: free log._cache 2022-11-15 14:21:04 +08:00
shanmite 5b50611ffe ci: update actions 2022-11-09 18:49:28 +08:00
22 changed files with 235 additions and 52 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
+3 -1
View File
@@ -10,7 +10,9 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Mirror + trigger CI
uses: SvanBoxel/gitlab-mirror-and-ci-action@master
with:
+1 -1
View File
@@ -12,7 +12,7 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
+5 -5
View File
@@ -30,16 +30,16 @@ jobs:
nodev: 12
steps:
- name: "Checkout codes"
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: "Use Node.js"
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: "*"
- name: "Pkg this"
run: |
npm run pkg "node${{ matrix.nodev }}-${{ matrix.platform }}-x64"
- name: "Upload to artifact"
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: node${{ matrix.nodev }}-${{ matrix.platform }}-x64
path: "dist/*.zip"
@@ -63,12 +63,12 @@ jobs:
- platform: alpine
steps:
- name: "Checkout codes"
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: "Pkg this"
run: |
npm run pkg "${{ matrix.platform }}-arm64"
- name: "Upload to artifact"
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: arm64
path: "dist/*.zip"
+18
View File
@@ -1,5 +1,23 @@
<!-- markdownlint-disable MD036 MD024-->
# CHANGELOG
## 主要变化(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`
* 5b50611 ci: update actions
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.6.8)
* 847e680 feat: 丰富推送内容(#135)(#194)(#211)
* 8bf5070 fix: `flatMap` is not a function (#218)
+3 -3
View File
@@ -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'
}
+1
View File
@@ -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
+52 -22
View File
@@ -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', '分区获取失败')
@@ -66,7 +67,10 @@ class Monitor extends Searcher {
case 2004:
log.warn('账号异常', `UID(${global_var.get('myUID')})异常号只会对部分UP出现关注异常`)
if (!config.is_exception) {
await sendNotify('[动态抽奖]账号异常通知', `UID: ${global_var.get('myUID')}\n异常号只会对部分UP出现关注异常\n可在设置中令is_exception为true关闭此推送\n${log._cache.filter(it => /Error|\[抽奖信息\]/.test(it)).join('\n')}`)
await sendNotify(
'[动态抽奖]账号异常通知',
`UID: ${global_var.get('myUID')}\n异常号只会对部分UP出现关注异常\n可在设置中令is_exception为true关闭此推送\n${log._cache.filter(it => /Error|\s抽奖信息\]/.test(it)).join('\n')}`
)
}
config.is_exception = true;
event_bus.emit('Turn_on_the_Monitor')
@@ -74,7 +78,10 @@ class Monitor extends Searcher {
case 2005:
log.warn('关注已达上限', `UID(${global_var.get('myUID')})关注已达上限,已临时进入只转已关注模式`)
if (!config.is_outof_maxfollow) {
await sendNotify('[动态抽奖]关注已达上限', `UID: ${global_var.get('myUID')}\n关注已达上限,已临时进入只转已关注模式\n可在设置中令is_outof_maxfollow为true关闭此推送\n${log._cache.filter(it => /Error|\[抽奖信息\]/.test(it)).join('\n')}`)
await sendNotify(
'[动态抽奖]关注已达上限',
`UID: ${global_var.get('myUID')}\n关注已达上限,已临时进入只转已关注模式\n可在设置中令is_outof_maxfollow为true关闭此推送\n${log._cache.filter(it => /Error|\s抽奖信息\]/.test(it)).join('\n')}`
)
}
config.is_outof_maxfollow = true;
config.only_followed = true;
@@ -256,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;
/**
@@ -318,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;
@@ -344,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),
@@ -418,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
}
}
}
}
@@ -500,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) {
@@ -561,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,
@@ -601,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
+43 -6
View File
@@ -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 是否官方
@@ -75,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;
/* 定位@信息 */
@@ -96,6 +108,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 +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)
@@ -112,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;
/* 预约抽奖信息 */
@@ -131,6 +157,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 +285,7 @@ class Searcher {
return ({ allModifyDynamicResArray, offset });
}
/**
* 获取最新动态信息(转发子动态)
* 并初步整理
@@ -307,9 +337,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 +352,7 @@ class Searcher {
return fomatdata;
}
/**
* 获取tag下的抽奖信息(转发母动态)
* 并初步整理
@@ -367,7 +400,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 +412,7 @@ class Searcher {
return fomatdata
}
/**
* 从专栏中获取抽奖信息
* @param {string} key_words
@@ -457,7 +493,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 +586,4 @@ class Searcher {
}
}
module.exports = { Searcher };
module.exports = { Searcher, parseDynamicCard };
+15
View File
@@ -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,
/**
* 是否关注异常
*/
+1 -1
View File
@@ -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([
+6 -4
View File
@@ -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('随机动态', '已有非抽奖动态故无需创建');
@@ -55,9 +55,11 @@ function start(num) {
event_bus.on('Turn_off_the_Monitor', async (msg) => {
log.info('结束抽奖', '原因: ' + msg);
if (config.notice_running_state) {
sendNotify(`动态抽奖-帐号${num}结束抽奖`, `${log._cache.filter(it => /抽奖\]|Error|\[抽奖信息\]/.test(it)).join('\n')}`);
sendNotify(
`动态抽奖-帐号${num}结束抽奖`,
`${log._cache.filter(it => /抽奖\]|Error|\s抽奖信息\]/.test(it)).join('\n')}`
);
}
log._cache.length = 0;
await createRandomDynamic(config.create_dy_num);
event_bus.flush();
resolve();
+2 -1
View File
@@ -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',
})
+29
View File
@@ -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
View File
@@ -1,4 +1,3 @@
//@ts-check
/**
* @typedef {import("http").IncomingHttpHeaders} HttpHeaders 头部信息
*
+1
View File
@@ -52,6 +52,7 @@ async function main() {
const { start, isMe, clear, checkCookie } = require("./lib/index");
log.info('main', '当前为第' + NUMBER + '个账号');
log._cache.length = 0
if (await checkCookie(NUMBER)) {
const mode = process.env.lottery_mode;
+16
View File
@@ -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
View File
@@ -1,6 +1,6 @@
{
"name": "lottery-auto-script",
"version": "2.6.8",
"version": "2.7.0",
"description": "自动参与B站动态抽奖",
"main": "main.js",
"scripts": {
+1 -1
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# version: <major.minor.patch>
level=patch
level=minor
npm version $level \
--no-commit-hooks \
+2 -2
View File
@@ -5,7 +5,7 @@ const util = require('./util');
(async () => {
assert(await bili_client.getMyinfo());
await util.par_run([
await util.par_run([0, 1, 2, 3, 4], [
async () => {
assert.equal((await bili_client.getTopRcmd()).length, 10)
},
@@ -32,7 +32,7 @@ const util = require('./util');
assert.notEqual(await bili_client.sendChat("703886913053917267", "t", 17), 1)
},
async () => {
// assert(!await bili_client.createDynamic("123"))
assert(!await bili_client.createDynamic("1"))
}
])
+29
View File
@@ -0,0 +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());
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")
},
])
console.log("dynamic_card.test ... ok!");
})()
+5 -2
View File
@@ -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 = {