mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-07-22 21:13:47 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa9cb68c81 | ||
|
|
dd1b1db76a | ||
|
|
86e6b7dbc9 | ||
|
|
731b8475ec | ||
|
|
043fee21e7 | ||
|
|
ae34c691b1 | ||
|
|
7496bc58a8 | ||
|
|
7c455aff9c | ||
|
|
ef969bb2c2 | ||
|
|
0cbacd6ddf | ||
|
|
da75c8c17b | ||
|
|
548ad4b589 | ||
|
|
922dd989bc | ||
|
|
c486abf0ed | ||
|
|
4bbbfc89a7 | ||
|
|
aba17ed0ad | ||
|
|
5a23043466 | ||
|
|
76f715248d | ||
|
|
0d4185d02a | ||
|
|
2ff4ec812b | ||
|
|
20c423fc09 | ||
|
|
6851f29f75 | ||
|
|
77d198bec5 | ||
|
|
0ba6acec31 | ||
|
|
dd994263b9 |
@@ -37,5 +37,5 @@ jobs:
|
||||
with:
|
||||
file: "dist/*.zip"
|
||||
delete_file: "dist/*.zip"
|
||||
tag_name: "v*.*.*"
|
||||
tag_name: "v2"
|
||||
overwrite: true
|
||||
|
||||
@@ -3,6 +3,7 @@ node_modules/
|
||||
tests/
|
||||
dyids/
|
||||
dist/
|
||||
.env
|
||||
*.log
|
||||
package-lock.json
|
||||
env.js
|
||||
|
||||
@@ -1,5 +1,51 @@
|
||||
<!-- markdownlint-disable MD036 MD024-->
|
||||
# CHANGELOG
|
||||
## 主要变化(2.4.7)
|
||||
* dd1b1db feat(update): 优先使用代理更新失败时切回去
|
||||
* 86e6b7d feat: 重命名设置`sneaktower`(#104)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.4.6)
|
||||
* 043fee2 feat: 新增设置`sneaktopic`(#104)
|
||||
* ae34c69 feat: 新增设置`is_repost_then_chat`(#103)
|
||||
* 7496bc5 feat: 中奖检查时增加回复信息读取(#102)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.4.5)
|
||||
* ef969bb feat: 每组显示动态转发数(#97)
|
||||
* 0cbacd6 feat: 推送携带帐号编号(#98)
|
||||
* da75c8c feat: 增加设置屏蔽动态类型`block_dynamic_type`(#99)
|
||||
* 548ad4b fix: pushplus更新域名(#93)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.4.4)
|
||||
* c486abf fix: 黑名单不起作用(#92)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.4.3)
|
||||
* aba17ed feat: 提示关键词修改建议
|
||||
* 5a23043 feat: 只通过是否点赞判断时点赞
|
||||
* 76f7152 fix: 黑名单匹配(#90)
|
||||
* 0d4185d fix(Searcher): getLotteryInfoByUID(#89)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.4.2)
|
||||
* 20c423f fix: "公共黑名单"显示错误(#87)
|
||||
* 6851f29 fix: 描述中出现undefined(#88)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.4.1)
|
||||
* 0ba6ace feat: check_if_duplicated可同时使用多种方式
|
||||
* dd99426 fix: 只转已关注功能失效
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.4.0)
|
||||
* 01562b6 ci: verison升级时小版本号归0
|
||||
* 90ac347 docs: 更新README
|
||||
|
||||
+38
-18
@@ -6,28 +6,48 @@ const bili = require('./net/bili')
|
||||
|
||||
/**
|
||||
* 是否中奖
|
||||
* @param {number} num
|
||||
*/
|
||||
async function isMe() {
|
||||
async function isMe(num) {
|
||||
let desp = '';
|
||||
const
|
||||
{ notice_key_words, update_session_wait, get_session_wait, check_session_pages } = config,
|
||||
UnreadAtNum = await bili.getUnreadAtNum(),
|
||||
UnreadSessionNum = await bili.getUnreadSessionNum(),
|
||||
{ follow_unread, unfollow_unread } = UnreadSessionNum || { unfollow_unread: 0, follow_unread: 0 };
|
||||
if (UnreadAtNum > 0) {
|
||||
{ at: unread_at_num, reply: unread_reply_num } = await bili.getUnreadNum(),
|
||||
unread_session_num = await bili.getUnreadSessionNum(),
|
||||
{ follow_unread, unfollow_unread } = unread_session_num || { unfollow_unread: 0, follow_unread: 0 };
|
||||
if (unread_at_num) {
|
||||
log.info('中奖检测', '<-- 正在检查at');
|
||||
const MyAtInfo = await bili.getMyAtInfo();
|
||||
MyAtInfo.forEach(async AtInfo => {
|
||||
const { at_time, up_uname, business, source_content, url } = AtInfo
|
||||
desp += '## [at]检测结果\n\n'
|
||||
desp += '----------------------------------------------------------------\n\n'
|
||||
desp += `发生时间: ${new Date(at_time * 1000).toLocaleString()}\n\n`
|
||||
desp += `用户: ${up_uname}\n\n`
|
||||
desp += `在${business}中@了你(${global_var.get("myUID")})\n\n`
|
||||
desp += `原内容为: ${source_content}\n\n`
|
||||
desp += `[直达链接](${url})\n\n`
|
||||
desp += '----------------------------------------------------------------\n\n'
|
||||
});
|
||||
MyAtInfo
|
||||
.slice(0, unread_at_num)
|
||||
.forEach(({ at_time, up_uname, business, source_content, url }) => {
|
||||
desp += '## [at]检测结果\n\n'
|
||||
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 += `原内容为: ${source_content}\n\n`
|
||||
desp += `[直达链接](${url})\n\n`
|
||||
desp += '----------------------------------------------------------------\n\n'
|
||||
});
|
||||
log.info('中奖检测', '--> OK');
|
||||
}
|
||||
if (unread_reply_num) {
|
||||
log.info('中奖检测', '<-- 正在检查回复');
|
||||
const replys = await bili.getReplyMsg();
|
||||
replys
|
||||
.slice(0, unread_reply_num)
|
||||
.forEach(({ nickname, uri, source, timestamp }) => {
|
||||
if (judge(source, notice_key_words)) {
|
||||
desp += '## 回复检测结果\n\n'
|
||||
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 += `[直达链接](${uri})\n\n`
|
||||
desp += '----------------------------------------------------------------\n\n'
|
||||
}
|
||||
})
|
||||
log.info('中奖检测', '--> OK');
|
||||
}
|
||||
if (follow_unread + unfollow_unread > 0) {
|
||||
@@ -46,7 +66,7 @@ async function isMe() {
|
||||
desp += '----------------------------------------------------------------\n\n'
|
||||
desp += `发生时间: ${new Date(timestamp * 1000).toLocaleString()}\n\n`
|
||||
desp += `用户: ${sender_uid}\n\n`
|
||||
desp += `私信你(${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'
|
||||
}
|
||||
@@ -75,7 +95,7 @@ async function isMe() {
|
||||
if (desp) {
|
||||
desp += '中奖了别忘给脚本(https://github.com/shanmiteko/LotteryAutoScript)点一个Star哦, 赞助一两块也不是不可以_(:з」∠)_\n\n'
|
||||
log.info('可能中奖了', desp);
|
||||
await sendNotify('可能中奖了', desp);
|
||||
await sendNotify(`帐号${num}可能中奖了`, desp);
|
||||
} else {
|
||||
log.info('中奖检测', "暂未中奖");
|
||||
}
|
||||
|
||||
+85
-48
@@ -103,11 +103,12 @@ class Monitor extends Searcher {
|
||||
|
||||
if (len) {
|
||||
let
|
||||
status = 0,
|
||||
is_exception = 0,
|
||||
is_outof_maxfollow = 0;
|
||||
is_outof_maxfollow = 0,
|
||||
relayed_nums = 0;
|
||||
for (const [index, lottery] of shuffle(allLottery).entries()) {
|
||||
let status = 0;
|
||||
|
||||
let is_shutdown = false;
|
||||
if (
|
||||
is_outof_maxfollow
|
||||
&& lottery.uid.length
|
||||
@@ -121,7 +122,8 @@ class Monitor extends Searcher {
|
||||
let { ts } = await bili.getLotteryNotice(lottery.dyid);
|
||||
const ts_10 = Date.now() / 1000;
|
||||
if (ts < 0) {
|
||||
return 6001
|
||||
status = 6001
|
||||
break;
|
||||
}
|
||||
if (ts < ts_10) {
|
||||
log.info('过滤', '已过开奖时间')
|
||||
@@ -140,7 +142,8 @@ class Monitor extends Searcher {
|
||||
if (minfollower > 0) {
|
||||
const followerNum = await bili.getUserInfo(lottery.uid[0]);
|
||||
if (followerNum < 0) {
|
||||
return 7001
|
||||
status = 7001
|
||||
break;
|
||||
}
|
||||
if (followerNum < minfollower) {
|
||||
log.info('过滤', `粉丝数(${followerNum})小于指定数量`)
|
||||
@@ -165,6 +168,8 @@ class Monitor extends Searcher {
|
||||
status = await this.go(lottery)
|
||||
switch (status) {
|
||||
case 0:
|
||||
relayed_nums += 1
|
||||
break;
|
||||
case 1002:
|
||||
case 1003:
|
||||
case 1004:
|
||||
@@ -190,17 +195,20 @@ class Monitor extends Searcher {
|
||||
case 2001:
|
||||
case 3001:
|
||||
case 5001:
|
||||
return status
|
||||
is_shutdown = true
|
||||
break;
|
||||
}
|
||||
|
||||
if (is_shutdown) break
|
||||
|
||||
d_storage.updateDyid(lottery.dyid)
|
||||
|
||||
await delay(wait * (Math.random() + 0.5));
|
||||
}
|
||||
log.info('抽奖', '开始转发下一组动态');
|
||||
log.info('抽奖', `本轮共转发${relayed_nums}条`);
|
||||
return is_exception
|
||||
|| is_outof_maxfollow
|
||||
|| 0
|
||||
|| status
|
||||
} else {
|
||||
log.info('抽奖', '无未转发抽奖');
|
||||
return 0
|
||||
@@ -236,7 +244,7 @@ class Monitor extends Searcher {
|
||||
/** 所有抽奖信息 */
|
||||
let alllotteryinfo = [];
|
||||
const
|
||||
{ check_if_duplicated, set_lottery_info_url, key_words, model, chatmodel, max_create_time, is_imitator, only_followed, at_users, blockword, blacklist, use_public_blacklist } = config,
|
||||
{ check_if_duplicated, set_lottery_info_url, sneaktower, key_words, model, chatmodel, block_dynamic_type, max_create_time, is_imitator, only_followed, at_users, blockword, blacklist, use_public_blacklist } = config,
|
||||
now_ts = Date.now() / 1000;
|
||||
|
||||
/**
|
||||
@@ -256,13 +264,16 @@ class Monitor extends Searcher {
|
||||
log.info('筛选动态', `去重后(${protoLotteryInfo.length})`);
|
||||
|
||||
/**并发查询dyid */
|
||||
await Promise.all(
|
||||
[...dyids_map.keys()]
|
||||
.map(it => d_storage
|
||||
.searchDyid(it)
|
||||
.then(hasIt => dyids_map.set(it, hasIt))
|
||||
)
|
||||
)
|
||||
if (check_if_duplicated === 1 || check_if_duplicated === 2) {
|
||||
await Promise.all(
|
||||
[...dyids_map.keys()]
|
||||
.map(it => d_storage
|
||||
.searchDyid(it)
|
||||
.then(hasIt => dyids_map.set(it, hasIt))
|
||||
)
|
||||
)
|
||||
log.info('筛选动态', `并发查询本地dyid完毕`);
|
||||
}
|
||||
|
||||
if (lottery_param[0] !== "APIs" && set_lottery_info_url && protoLotteryInfo.length) {
|
||||
log.info("上传抽奖信息", "开始")
|
||||
@@ -297,15 +308,17 @@ class Monitor extends Searcher {
|
||||
|
||||
log.debug('正在筛选的动态信息', lottery_info);
|
||||
|
||||
/* 遇到转发过就退出 */
|
||||
if (
|
||||
(!check_if_duplicated
|
||||
&& is_liked)
|
||||
|| (check_if_duplicated === 1
|
||||
&& dyids_map.get(dyid))
|
||||
) {
|
||||
log.info("筛选动态", `已转发(https://t.bilibili.com/${dyid})`)
|
||||
return false
|
||||
if (lottery_info_type.startsWith('sneak') && sneaktower) {
|
||||
log.info("筛选动态", `偷塔模式不检查是否已转发(https://t.bilibili.com/${dyid})`)
|
||||
} else {
|
||||
/* 遇到转发过就退出 */
|
||||
if (
|
||||
((!check_if_duplicated || check_if_duplicated === 2) && is_liked)
|
||||
|| ((check_if_duplicated === 1 || check_if_duplicated === 2) && dyids_map.get(dyid))
|
||||
) {
|
||||
log.info("筛选动态", `已转发(https://t.bilibili.com/${dyid})`)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/* 超过指定时间退出 */
|
||||
@@ -316,8 +329,8 @@ class Monitor extends Searcher {
|
||||
|
||||
const
|
||||
[m_uid, ori_uid] = uids,
|
||||
mIsFollowed = m_uid && (new RegExp(m_uid)).test(attentionList),
|
||||
oriIsFollowed = ori_uid && (new RegExp(ori_uid)).test(attentionList),
|
||||
mIsFollowed = !m_uid || (new RegExp(m_uid)).test(attentionList),
|
||||
oriIsFollowed = !ori_uid || (new RegExp(ori_uid)).test(attentionList),
|
||||
/**判断是转发源动态还是现动态 实际发奖人*/
|
||||
[real_uid, realIsFollowed] = lottery_info_type === 'uid'
|
||||
? [ori_uid, oriIsFollowed]
|
||||
@@ -335,9 +348,32 @@ class Monitor extends Searcher {
|
||||
isSendChat =
|
||||
(is_imitator && lottery_info_type === 'uid' && chatmodel !== '00')
|
||||
|| (hasOfficialLottery && chatmodel[0] === '1')
|
||||
|| (!hasOfficialLottery && chatmodel[1] === '1');
|
||||
|| (!hasOfficialLottery && chatmodel[1] === '1'),
|
||||
{ blacklist: remote_blacklist } = use_public_blacklist === false
|
||||
? { blacklist: "" }
|
||||
: global_var.get("remoteconfig"),
|
||||
/**
|
||||
* 获取黑名单并去重合并
|
||||
* @type {string[]}
|
||||
*/
|
||||
new_blacklist = remote_blacklist
|
||||
? [
|
||||
...new Set([...blacklist.split(','),
|
||||
...remote_blacklist.split(',')])
|
||||
]
|
||||
: blacklist.split(','),
|
||||
keys = [dyid, m_uid, ori_uid];
|
||||
|
||||
log.debug("筛选动态", { real_uid, mIsFollowed, oriIsFollowed, realIsFollowed, needAt, needTopic, isRelayDynamic, key_words, has_key_words, blockword, isBlock, isLottery, isSendChat })
|
||||
log.debug("筛选动态", { real_uid, mIsFollowed, oriIsFollowed, realIsFollowed, needAt, needTopic, type, isRelayDynamic, key_words, has_key_words, blockword, isBlock, isLottery, isSendChat })
|
||||
|
||||
if (block_dynamic_type.includes(type)) {
|
||||
log.warn("筛选动态", `屏蔽动态类型 ${type}`)
|
||||
return false
|
||||
}
|
||||
|
||||
if (!has_key_words && description) {
|
||||
log.warn("筛选动态", `无关键词动态的描述: ${description}\n\n考虑是否修改设置key_words:\n${key_words.join('\n')}`)
|
||||
}
|
||||
|
||||
/**屏蔽词 */
|
||||
if (isBlock) {
|
||||
@@ -346,29 +382,26 @@ class Monitor extends Searcher {
|
||||
}
|
||||
|
||||
/**若勾选只转已关注 */
|
||||
if (only_followed && !mIsFollowed && !oriIsFollowed) {
|
||||
if (only_followed
|
||||
&& (!mIsFollowed || !oriIsFollowed)
|
||||
) {
|
||||
log.info("筛选动态", `只转已关注(https://t.bilibili.com/${dyid})`)
|
||||
return false
|
||||
}
|
||||
|
||||
const
|
||||
{ blacklist: remote_blacklist } = use_public_blacklist === false
|
||||
? { blacklist: "" }
|
||||
: global_var.get("remoteconfig"),
|
||||
/* 获取黑名单并去重合并 */
|
||||
new_blacklist = remote_blacklist
|
||||
? [
|
||||
...new Set([...blacklist.split(','),
|
||||
...remote_blacklist.split(',')])
|
||||
].join()
|
||||
: blacklist;
|
||||
|
||||
if ((new RegExp(dyid + '|' + m_uid + '|' + ori_uid)).test(new_blacklist)) {
|
||||
log.info("筛选动态", `公共黑名单用户(https://t.bilibili.com/${dyid})`)
|
||||
if (
|
||||
new_blacklist.some(id => keys.some(key => {
|
||||
if (key + '' === id) {
|
||||
log.info("筛选动态", `黑名单匹配(${id})(https://t.bilibili.com/${dyid})`)
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}))
|
||||
) {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
if (isLottery) {
|
||||
let onelotteryinfo = {};
|
||||
|
||||
@@ -408,7 +441,7 @@ class Monitor extends Searcher {
|
||||
}
|
||||
|
||||
/* 是否是转发的动态 */
|
||||
if (isRelayDynamic && real_uid) {
|
||||
if (isRelayDynamic) {
|
||||
/* 转发内容长度+'//'+'@'+用户名+':'+源内容 */
|
||||
const addlength = RandomStr.length + 2 + uname.length + 1 + 1;
|
||||
onelotteryinfo.relay_chat = RandomStr + `//@${uname}:` + des;
|
||||
@@ -488,7 +521,7 @@ class Monitor extends Searcher {
|
||||
let status = 0
|
||||
const
|
||||
{ uid, dyid, chat_type, rid, relay_chat, ctrl } = option,
|
||||
{ chat, check_if_duplicated } = config;
|
||||
{ chat, check_if_duplicated, is_repost_then_chat } = config;
|
||||
|
||||
/* 评论 */
|
||||
if (rid && chat_type) {
|
||||
@@ -496,7 +529,11 @@ class Monitor extends Searcher {
|
||||
status = await retryfn(
|
||||
5,
|
||||
[1, 4],
|
||||
() => bili.sendChat(rid, getRandomOne(chat), chat_type)
|
||||
() => bili.sendChat(
|
||||
rid,
|
||||
is_repost_then_chat ? relay_chat : getRandomOne(chat),
|
||||
chat_type
|
||||
)
|
||||
)
|
||||
|
||||
if (status) {
|
||||
|
||||
+31
-34
@@ -75,10 +75,10 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
obj.ctrl = (extend_json && strToJson(extend_json).ctrl) || [];
|
||||
/* 是否有官方抽奖 */
|
||||
obj.hasOfficialLottery = extension && extension.lott && true;
|
||||
/* 转发者的描述 后两个分别是视频动态的描述和视频本身的描述*/
|
||||
/* 转发者的描述 纯文字内容 图片动态描述 后两个分别是视频动态的描述和视频本身的描述*/
|
||||
obj.description =
|
||||
(item && (item.content + item.description))
|
||||
|| (cardToJson.dynamic + cardToJson.desc)
|
||||
(item && (item.content || '' + item.description || ''))
|
||||
|| (cardToJson.dynamic || '' + cardToJson.desc || '')
|
||||
|| '';
|
||||
if (obj.type === 1) {
|
||||
const { origin_extension, origin } = cardToJson
|
||||
@@ -98,8 +98,8 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
obj.origin_uname = (user && (user.name || user.uname)) || '';
|
||||
/* 被转发者的描述 */
|
||||
obj.origin_description =
|
||||
(item && (item.content + item.description))
|
||||
|| (originToJson.dynamic + originToJson.desc)
|
||||
(item && (item.content || '' + item.description || ''))
|
||||
|| (originToJson.dynamic || '' + originToJson.desc || '')
|
||||
|| '';
|
||||
}
|
||||
|
||||
@@ -241,38 +241,35 @@ class Searcher {
|
||||
}
|
||||
})
|
||||
.reduce(async (pre, cur) => {
|
||||
const results = await pre
|
||||
, { origin_dynamic_id } = cur;
|
||||
|
||||
const card = await bili.getOneDynamicByDyid(origin_dynamic_id)
|
||||
|
||||
if (card) {
|
||||
await utils.delay(get_dynamic_detail_wait)
|
||||
|
||||
const { is_liked } = parseDynamicCard(card)
|
||||
let
|
||||
results = await pre,
|
||||
{ origin_dynamic_id } = cur,
|
||||
is_liked = false;
|
||||
|
||||
if (!check_if_duplicated || check_if_duplicated === 2) {
|
||||
const card = await bili.getOneDynamicByDyid(origin_dynamic_id)
|
||||
log.info('获取动态', `查看源动态(${origin_dynamic_id})是否点赞 (${length--})`)
|
||||
if (is_liked) {
|
||||
log.info('获取动态', `动态(${origin_dynamic_id})已转发过`)
|
||||
} else {
|
||||
return [...results, {
|
||||
lottery_info_type: 'uid',
|
||||
create_time: cur.origin_create_time,
|
||||
is_liked,
|
||||
uids: [cur.uid, cur.origin_uid],
|
||||
uname: cur.origin_uname,
|
||||
ctrl: [],
|
||||
dyid: cur.origin_dynamic_id,
|
||||
rid: cur.origin_rid_str,
|
||||
des: cur.origin_description,
|
||||
type: cur.orig_type,
|
||||
hasOfficialLottery: cur.origin_hasOfficialLottery
|
||||
}]
|
||||
if (card) {
|
||||
({ is_liked } = parseDynamicCard(card))
|
||||
}
|
||||
await utils.delay(get_dynamic_detail_wait)
|
||||
}
|
||||
|
||||
return results
|
||||
results.push({
|
||||
lottery_info_type: 'uid',
|
||||
create_time: cur.origin_create_time,
|
||||
is_liked,
|
||||
uids: [cur.uid, cur.origin_uid],
|
||||
uname: cur.origin_uname,
|
||||
ctrl: [],
|
||||
dyid: cur.origin_dynamic_id,
|
||||
rid: cur.origin_rid_str,
|
||||
des: cur.origin_description,
|
||||
type: cur.orig_type,
|
||||
hasOfficialLottery: cur.origin_hasOfficialLottery
|
||||
})
|
||||
|
||||
return results
|
||||
}, Promise.resolve([]))
|
||||
|
||||
log.info('获取动态', `成功获取用户${UID}的动态信息`);
|
||||
@@ -380,9 +377,9 @@ class Searcher {
|
||||
, { is_liked } = parsed_card;
|
||||
|
||||
if (
|
||||
(!check_if_duplicated
|
||||
((!check_if_duplicated || check_if_duplicated === 2)
|
||||
&& is_liked)
|
||||
|| (check_if_duplicated === 1
|
||||
|| ((check_if_duplicated === 1 || check_if_duplicated === 2)
|
||||
&& await d_storage.searchDyid(dyid))
|
||||
) {
|
||||
log.info('获取动态', `动态(${dyid})已转发过`)
|
||||
@@ -454,7 +451,7 @@ class Searcher {
|
||||
let results = await pre
|
||||
, { dyid } = cur;
|
||||
|
||||
if (!check_if_duplicated) {
|
||||
if (!check_if_duplicated || check_if_duplicated === 2) {
|
||||
log.info('获取动态', `查看动态(${dyid})是否点赞 (${length--})`)
|
||||
const card = await bili.getOneDynamicByDyid(dyid)
|
||||
|
||||
|
||||
+31
-3
@@ -49,8 +49,8 @@ const config = {
|
||||
* 符合js正则表达式的字符串
|
||||
*/
|
||||
key_words: [
|
||||
"[抽奖送]",
|
||||
"[转关评]"
|
||||
"[抽奖送揪]|福利",
|
||||
"[转关评粉]|参与"
|
||||
],
|
||||
|
||||
/**
|
||||
@@ -74,8 +74,30 @@ const config = {
|
||||
* - 不检查 -1
|
||||
* - 通过是否点赞判断 0
|
||||
* - 检索本地dyids文件 1
|
||||
* - 通过是否点赞判断+检索本地dyids文件 2
|
||||
*/
|
||||
check_if_duplicated: 0,
|
||||
check_if_duplicated: 1,
|
||||
|
||||
/**
|
||||
* 偷塔模式不检查是否重复转发
|
||||
* * 偷塔模式: 临近开奖时参与抽奖
|
||||
*/
|
||||
sneaktower: true,
|
||||
|
||||
/**
|
||||
* 屏蔽动态类型
|
||||
*
|
||||
* | 动态类型 | type值 |
|
||||
* | :------- |:----- |
|
||||
* | 转发 | `1` |
|
||||
* | 含图片 | `2` |
|
||||
* | 无图纯文字 | `4` |
|
||||
* | 视频 | `8` |
|
||||
* | 番剧 | `512` |
|
||||
* | 活动 | `2048` |
|
||||
* | 专栏 | `64` |
|
||||
*/
|
||||
block_dynamic_type: [0],
|
||||
|
||||
/**
|
||||
* - 动态创建时间
|
||||
@@ -244,6 +266,12 @@ const config = {
|
||||
*/
|
||||
blockword: ["脚本", "抽奖号", "钓鱼"],
|
||||
|
||||
/**
|
||||
* 转发并评论
|
||||
* - 评论内容与转发内容相同
|
||||
*/
|
||||
is_repost_then_chat: false,
|
||||
|
||||
/**
|
||||
* 转发评语
|
||||
*/
|
||||
|
||||
@@ -621,7 +621,7 @@ function pushPlusNotify(text, desp) {
|
||||
if (PUSH_PLUS_TOKEN) {
|
||||
send({
|
||||
method: 'POST',
|
||||
url: 'https://pushplus.hxtrip.com/send',
|
||||
url: 'http://www.pushplus.plus/send',
|
||||
contents: {
|
||||
token: PUSH_PLUS_TOKEN,
|
||||
title: text,
|
||||
|
||||
@@ -12,6 +12,7 @@ module.exports = Object.freeze({
|
||||
FEED_SETUSERFOLLOW: 'https://api.vc.bilibili.com/feed/v1/feed/SetUserFollow',
|
||||
LOTTERY_SVR_LOTTERY_NOTICE: 'https://api.vc.bilibili.com/lottery_svr/v1/lottery_svr/lottery_notice',
|
||||
MSGFEED_AT: 'https://api.bilibili.com/x/msgfeed/at',
|
||||
MSGFEED_REPLAY: 'https://api.bilibili.com/x/msgfeed/reply',
|
||||
MSGFEED_UNREAD: 'https://api.bilibili.com/x/msgfeed/unread',
|
||||
READ_CV: 'https://www.bilibili.com/read/cv{{cv}}',
|
||||
RELATION_BATCH_MODIFY: 'https://api.bilibili.com/x/relation/batch/modify',
|
||||
|
||||
+36
-8
@@ -185,22 +185,50 @@ const bili_client = {
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 获取未读@
|
||||
* @returns {Promise<number>}
|
||||
* 获取未读信息数量
|
||||
* @returns {Promise<{at: number, reply: number}>}
|
||||
*/
|
||||
async getUnreadAtNum() {
|
||||
async getUnreadNum() {
|
||||
const
|
||||
responseText = await get({
|
||||
url: API.MSGFEED_UNREAD
|
||||
}),
|
||||
res = strToJson(responseText);
|
||||
if (res.code === 0) {
|
||||
const { at } = res.data;
|
||||
log.info('获取未读@', `成功 数量: ${at}`);
|
||||
return at;
|
||||
log.info('获取未读信息', `成功`);
|
||||
return res.data;
|
||||
} else {
|
||||
log.error('获取未读@', `失败\n${responseText}`);
|
||||
return -1;
|
||||
log.error('获取未读信息', `失败\n${responseText}`);
|
||||
return {};
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 获取一页回复
|
||||
* @returns {Promise<Array<{nickname: string, source: string, uri: string, timestamp: number}>}>}
|
||||
*/
|
||||
async getReplyMsg() {
|
||||
const
|
||||
responseText = await get({
|
||||
url: API.MSGFEED_REPLAY
|
||||
}),
|
||||
res = strToJson(responseText);
|
||||
if (res.code === 0) {
|
||||
const data = res.data || {},
|
||||
items = data.items || [];
|
||||
log.info('获取一页回复', `成功(${items.length})`);
|
||||
return items
|
||||
.filter(it => it.item.type === 'reply')
|
||||
.map(it => {
|
||||
return {
|
||||
nickname: it.user.nickname,
|
||||
source: it.item.source_content,
|
||||
uri: it.item.uri,
|
||||
timestamp: it.reply_time
|
||||
}
|
||||
});
|
||||
} else {
|
||||
log.error('获取一页回复', '失败');
|
||||
return []
|
||||
}
|
||||
},
|
||||
/**
|
||||
|
||||
+54
-43
@@ -2,13 +2,25 @@ const { send } = require('./net/http')
|
||||
const { strToJson, download, try_for_each } = require('./utils')
|
||||
const { version, checkVersion, log } = require('./utils')
|
||||
|
||||
const
|
||||
platform = new Map([
|
||||
['win32', 'win'],
|
||||
['linux', 'linux'],
|
||||
['darwin', 'macos']
|
||||
]).get(process.platform),
|
||||
arch = new Map([
|
||||
['x64', 'x64'],
|
||||
['arm', 'armv7'],
|
||||
['arm64', 'arm64']
|
||||
]).get(process.arch);
|
||||
|
||||
/**
|
||||
* 获取下载链接
|
||||
* @param {string} owner
|
||||
* @param {string} repo
|
||||
* @returns {Promise<{ download_url: string[], text: string }>}
|
||||
* @returns {Promise<{ tag_name:string, assets:Object, text:string }>}
|
||||
*/
|
||||
function getLatestReleaseDownloadUrl(owner, repo) {
|
||||
function getLatestRelease(owner, repo) {
|
||||
return new Promise((resolve, reject) => {
|
||||
send({
|
||||
url: `https://api.github.com/repos/${owner}/${repo}/releases/latest`,
|
||||
@@ -19,37 +31,9 @@ function getLatestReleaseDownloadUrl(owner, repo) {
|
||||
retry: false
|
||||
},
|
||||
success: ({ body }) => {
|
||||
const { tag_name, assets, body: text } = strToJson(body)
|
||||
if (tag_name) {
|
||||
if (checkVersion(version) < checkVersion(tag_name)) {
|
||||
const platform = new Map([
|
||||
['win32', 'win'],
|
||||
['linux', 'linux'],
|
||||
['darwin', 'macos']
|
||||
]).get(process.platform)
|
||||
const arch = new Map([
|
||||
['x64', 'x64'],
|
||||
['arm', 'armv7'],
|
||||
['arm64', 'arm64']
|
||||
]).get(process.arch)
|
||||
if (platform && arch) {
|
||||
try {
|
||||
const download_url = assets
|
||||
.filter(({ name }) => name.includes(platform) && name.includes(arch))
|
||||
.map(({ browser_download_url }) => browser_download_url)
|
||||
if (!download_url.length) {
|
||||
reject(`未找到能在此平台(${process.platform})-(${process.arch})上运行的版本`)
|
||||
}
|
||||
resolve({ download_url, text })
|
||||
} catch (err) {
|
||||
reject(err)
|
||||
}
|
||||
} else {
|
||||
reject(`未找到能在此平台(${process.platform})-(${process.arch})上运行的版本`)
|
||||
}
|
||||
} else {
|
||||
reject('当前已是最新版本')
|
||||
}
|
||||
const release = strToJson(body);
|
||||
if (release.tag_name) {
|
||||
resolve(release)
|
||||
} else {
|
||||
reject(body)
|
||||
}
|
||||
@@ -61,21 +45,48 @@ function getLatestReleaseDownloadUrl(owner, repo) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} releases
|
||||
* @return {boolean}
|
||||
*/
|
||||
function checkPlatform(releases) {
|
||||
return releases.includes(platform)
|
||||
&& releases.includes(arch)
|
||||
}
|
||||
|
||||
/**
|
||||
* 半自动更新
|
||||
*/
|
||||
async function update() {
|
||||
try {
|
||||
const { download_url, text } = await getLatestReleaseDownloadUrl('shanmiteko', 'LotteryAutoScript')
|
||||
await try_for_each(download_url.entries(), async ([i, url]) => {
|
||||
let proxy_url = new URL(url)
|
||||
proxy_url.host = 'download.fastgit.org'
|
||||
await download(proxy_url.href, `latest_version${i}.zip`)
|
||||
return false
|
||||
})
|
||||
|
||||
log.info('自动下载', '成功下载到当前目录')
|
||||
log.info('更新说明', '\n' + text + '\n')
|
||||
const { tag_name, assets, body: text } = await getLatestRelease('shanmiteko', 'LotteryAutoScript')
|
||||
if (checkVersion(version) < checkVersion(tag_name)) {
|
||||
const download_url = assets
|
||||
.filter(({ name }) => checkPlatform(name))
|
||||
.map(({ browser_download_url }) => browser_download_url)
|
||||
if (download_url.length) {
|
||||
const proxy_host = ['download.fastgit.org']
|
||||
await try_for_each(download_url.entries(), async ([i, url]) => {
|
||||
let proxy_url = new URL(url)
|
||||
proxy_url.host = proxy_host[0]
|
||||
log.warn('自动下载', `切换代理${proxy_host[0]}`)
|
||||
await download(proxy_url.href, `latest_version${i}.zip`)
|
||||
.catch(async err => {
|
||||
log.error('自动下载', err)
|
||||
proxy_url.host = 'github.com'
|
||||
log.warn('自动下载', `使用原始链接github.com`)
|
||||
await download(proxy_url.href, `latest_version${i}.zip`)
|
||||
})
|
||||
return false
|
||||
})
|
||||
log.info('自动下载', '成功下载到当前目录')
|
||||
log.info('更新说明', '\n' + text + '\n')
|
||||
} else {
|
||||
throw `未找到能在此平台(${process.platform})-(${process.arch})上运行的版本,建议以源码运行`
|
||||
}
|
||||
} else {
|
||||
throw '当前已是最新版本'
|
||||
}
|
||||
} catch (error) {
|
||||
log.error('更新脚本', error)
|
||||
}
|
||||
|
||||
+4
-3
@@ -248,12 +248,13 @@ const utils = {
|
||||
redirect: true,
|
||||
retry: false
|
||||
},
|
||||
success: ({ resStream }) => {
|
||||
success: ({ headers, resStream }) => {
|
||||
const total_len = Number(headers["content-length"]);
|
||||
let recv_length = 0;
|
||||
const wtbs = fs.createWriteStream(file_name);
|
||||
resStream.on('data', chuck => {
|
||||
recv_length += chuck.length
|
||||
utils.log.proPrint(`已收到:${recv_length} Bytes`)
|
||||
utils.log.proPrint(total_len ? `已下载${(recv_length * 100 / total_len + '').slice(0, 5)}%` : `已收到:${recv_length} Bytes`)
|
||||
})
|
||||
resStream.pipe(wtbs)
|
||||
wtbs.on('finish', () => {
|
||||
@@ -261,7 +262,7 @@ const utils = {
|
||||
resolve()
|
||||
}).on('error', error => {
|
||||
wtbs.destroy()
|
||||
resolve(error)
|
||||
reject(error)
|
||||
})
|
||||
},
|
||||
failure: error => {
|
||||
|
||||
@@ -65,7 +65,7 @@ async function main() {
|
||||
case 'check':
|
||||
log.info('中奖检测', '检查是否中奖');
|
||||
loop_wait = check_loop_wait;
|
||||
await isMe();
|
||||
await isMe(NUMBER);
|
||||
break;
|
||||
case 'clear':
|
||||
if (CLEAR) {
|
||||
@@ -88,7 +88,7 @@ async function main() {
|
||||
}
|
||||
} else {
|
||||
log.error('Cookie已失效', '切换账号时不要点击退出账号而应直接删除Cookie退出')
|
||||
return ''
|
||||
return
|
||||
}
|
||||
} else {
|
||||
return '请查看README文件, 在env.js指定位置填入cookie'
|
||||
|
||||
+32
-3
@@ -63,8 +63,8 @@ module.exports = Object.freeze({
|
||||
* 符合js正则表达式的字符串
|
||||
*/
|
||||
key_words: [
|
||||
"[抽奖送]",
|
||||
"[转关评]"
|
||||
"[抽奖送揪]|福利",
|
||||
"[转关评粉]|参与"
|
||||
],
|
||||
|
||||
/**
|
||||
@@ -88,8 +88,30 @@ module.exports = Object.freeze({
|
||||
* - 不检查 -1
|
||||
* - 通过是否点赞判断 0
|
||||
* - 检索本地dyids文件 1
|
||||
* - 通过是否点赞判断+检索本地dyids文件 2
|
||||
*/
|
||||
check_if_duplicated: 0,
|
||||
check_if_duplicated: 1,
|
||||
|
||||
/**
|
||||
* 偷塔模式不检查是否重复转发
|
||||
* * 偷塔模式: 临近开奖时参与抽奖
|
||||
*/
|
||||
sneaktower: true,
|
||||
|
||||
/**
|
||||
* 屏蔽动态类型
|
||||
*
|
||||
* | 动态类型 | type值 |
|
||||
* | :------- |:----- |
|
||||
* | 转发 | `1` |
|
||||
* | 含图片 | `2` |
|
||||
* | 无图纯文字 | `4` |
|
||||
* | 视频 | `8` |
|
||||
* | 番剧 | `512` |
|
||||
* | 活动 | `2048` |
|
||||
* | 专栏 | `64` |
|
||||
*/
|
||||
block_dynamic_type: [0],
|
||||
|
||||
/**
|
||||
* - 动态创建时间
|
||||
@@ -243,6 +265,7 @@ module.exports = Object.freeze({
|
||||
at_users: [['转发抽奖娘', 294887687], ['你的工具人老公', 100680137]],
|
||||
|
||||
/**
|
||||
* - 动态dyid或UID
|
||||
* - 英文逗号分隔 如: 1,2,3
|
||||
*/
|
||||
blacklist: '',
|
||||
@@ -258,6 +281,12 @@ module.exports = Object.freeze({
|
||||
*/
|
||||
blockword: ["脚本", "抽奖号", "钓鱼"],
|
||||
|
||||
/**
|
||||
* 转发并评论
|
||||
* - 评论内容与转发内容相同
|
||||
*/
|
||||
is_repost_then_chat: false,
|
||||
|
||||
/**
|
||||
* 转发评语
|
||||
*/
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "lottery-auto-script",
|
||||
"version": "2.4.0",
|
||||
"version": "2.4.7",
|
||||
"description": "自动参与B站动态抽奖",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# version: <major.minor.patch>
|
||||
level=minor
|
||||
level=patch
|
||||
|
||||
npm version $level \
|
||||
--no-commit-hooks \
|
||||
|
||||
Reference in New Issue
Block a user