mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-06-04 21:01:17 +08:00
feat: 转发加码动态; fix: 版本号计算带上倍率
This commit is contained in:
parent
c4c97f6732
commit
633571cbb7
@ -1,6 +1,5 @@
|
||||
const Ajax = require('./Ajax');
|
||||
const Base = require('./Base');
|
||||
const config = require("./config");
|
||||
const GlobalVar = require('./GlobalVar.json');
|
||||
|
||||
/**
|
||||
@ -433,10 +432,11 @@ const BiliAPI = {
|
||||
* @param {Number} uid
|
||||
* 自己的UID
|
||||
* @param {string} dyid
|
||||
* @param {string} [msg]
|
||||
* 动态的ID
|
||||
* @returns {Promise<1|0>}
|
||||
*/
|
||||
autoRelay: (uid, dyid) => {
|
||||
autoRelay: (uid, dyid, msg = '转发动态', ctrl = '[]') => {
|
||||
return new Promise((resolve) => {
|
||||
Ajax.post({
|
||||
url: 'https://api.vc.bilibili.com/dynamic_repost/v1/dynamic_repost/repost',
|
||||
@ -445,8 +445,8 @@ const BiliAPI = {
|
||||
data: {
|
||||
uid: `${uid}`,
|
||||
dynamic_id: dyid,
|
||||
content: Base.getRandomStr(config.relay),
|
||||
extension: '{"emoji_type":1}',
|
||||
content: msg,
|
||||
ctrl,
|
||||
csrf: GlobalVar.csrf
|
||||
},
|
||||
success: responseText => {
|
||||
|
||||
@ -70,11 +70,12 @@ class Monitor extends Public {
|
||||
* @property {number} uid 用户标识
|
||||
* @property {string} dyid 动态标识
|
||||
* @property {number} type 动态类型
|
||||
* @property {string} relay_chat 动态类型
|
||||
* @property {string} ctrl 定位@
|
||||
* @property {string} rid 评论类型
|
||||
*/
|
||||
/**
|
||||
* @returns {Promise<LotteryOptions[] | []>
|
||||
}
|
||||
* @returns {Promise<LotteryOptions[] | []>}
|
||||
*/
|
||||
async filterLotteryInfo() {
|
||||
const self = this,
|
||||
@ -84,7 +85,7 @@ class Monitor extends Public {
|
||||
const { model, chatmodel, maxday: _maxday, minfollower, blockword, blacklist } = config;
|
||||
const maxday = _maxday === '-1' || _maxday === '' ? Infinity : (Number(_maxday) * 86400);
|
||||
for (const info of protoLotteryInfo) {
|
||||
const { uid, dyid, official_verify, befilter, rid, des, type, hasOfficialLottery } = info;
|
||||
const { uid, uname, dyid, official_verify, ctrl, befilter, rid, des, type, hasOfficialLottery } = info;
|
||||
const now_ts_10 = Date.now() / 1000;
|
||||
let onelotteryinfo = {};
|
||||
let isLottery = false;
|
||||
@ -123,14 +124,36 @@ class Monitor extends Public {
|
||||
const isRelay = (new RegExp(dyid)).test(self.AllMyLotteryInfo);
|
||||
if ((new RegExp(dyid + '|' + uid)).test(blacklist)) continue;
|
||||
if (!isFollowed) onelotteryinfo.uid = uid;
|
||||
if (!isRelay) onelotteryinfo.dyid = dyid;
|
||||
if (!isRelay) {
|
||||
onelotteryinfo.dyid = dyid;
|
||||
const RandomStr = Base.getRandomStr(config.relay);
|
||||
if (type === 1) {
|
||||
/* 转发内容长度+'//'+'@'+用户名+':'+源内容 */
|
||||
const addlength = RandomStr.length + 2 + uname.length + 1 + 1;
|
||||
onelotteryinfo.relay_chat = RandomStr + `//@${uname}:` + des;
|
||||
let new_ctrl = ctrl.map(item => {
|
||||
item.location += addlength;
|
||||
return item;
|
||||
})
|
||||
new_ctrl.unshift({
|
||||
data: String(uid),
|
||||
location: RandomStr.length + 2,
|
||||
length: uname.length + 1,
|
||||
type: 1
|
||||
})
|
||||
onelotteryinfo.ctrl = JSON.stringify(new_ctrl);
|
||||
} else {
|
||||
onelotteryinfo.relay_chat = RandomStr;
|
||||
onelotteryinfo.ctrl = '[]'
|
||||
}
|
||||
}
|
||||
/* 根据动态的类型决定评论的类型 */
|
||||
onelotteryinfo.type = type === 2 ?
|
||||
11 : type === 4 ?
|
||||
11 : type === 4 || type === 1 ?
|
||||
17 : type === 8 ?
|
||||
1 : 0;
|
||||
/* 是否评论 */
|
||||
if(isSendChat) onelotteryinfo.rid = rid;
|
||||
if (isSendChat) onelotteryinfo.rid = rid;
|
||||
if (typeof onelotteryinfo.uid === 'undefined' && typeof onelotteryinfo.dyid === 'undefined') continue;
|
||||
alllotteryinfo.push(onelotteryinfo);
|
||||
}
|
||||
@ -143,7 +166,7 @@ class Monitor extends Public {
|
||||
* @returns {Promise<number>} sucess:1 err:0
|
||||
*/
|
||||
async go(option) {
|
||||
const { uid, dyid, type, rid } = option;
|
||||
const { uid, dyid, type, rid, relay_chat, ctrl } = option;
|
||||
if (typeof dyid === 'string') {
|
||||
if (typeof rid === 'string' && type !== 0) {
|
||||
if (await BiliAPI.sendChat(rid, Base.getRandomStr(config.chat), type) === 0) return 0;
|
||||
@ -153,7 +176,7 @@ class Monitor extends Public {
|
||||
await Base.delay(5000);
|
||||
if (await BiliAPI.movePartition(uid, this.tagid) === 0) return 0;
|
||||
}
|
||||
if (await BiliAPI.autoRelay(GlobalVar.myUID, dyid) === 0) return 0;
|
||||
if (await BiliAPI.autoRelay(GlobalVar.myUID, dyid, relay_chat, ctrl) === 0) return 0;
|
||||
if (await BiliAPI.autolike(dyid) === 0) return 0;
|
||||
await Base.delay(Number(config.wait) + Math.floor(Math.random() * 60000 - 30000));
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@ class Public {
|
||||
* @property {number} type
|
||||
* @property {string} description
|
||||
* @property {boolean} hasOfficialLottery
|
||||
* @property {Array<Object.<string,string|number>>} ctrl
|
||||
*
|
||||
* @property {number} origin_uid
|
||||
* @property {string} origin_uname
|
||||
@ -118,11 +119,12 @@ class Public {
|
||||
obj.uname = info.uname;/* 转发者的name */
|
||||
obj.official_verify = official_verify.type > -1 ? true : false; /* 是否官方号 */
|
||||
obj.createtime = desc.timestamp /* 动态的ts10 */
|
||||
obj.rid_str = desc.rid_str;/* 用于发送评论 */
|
||||
obj.type = desc.type /* 动态类型 */
|
||||
obj.rid_str = obj.type === 1 ? desc.dynamic_id_str : desc.rid_str;/* 用于发送评论 */
|
||||
obj.orig_type = desc.orig_type /* 源动态类型 */
|
||||
obj.dynamic_id = desc.dynamic_id_str; /* 转发者的动态ID !!!!此为大数需使用字符串值,不然JSON.parse()会有丢失精度 */
|
||||
const { extension } = onecard;
|
||||
const { extension, extend_json } = onecard;
|
||||
obj.ctrl = (typeof extend_json === 'undefined') ? [] : strToJson(extend_json).ctrl || []; /* 定位@信息 */
|
||||
obj.hasOfficialLottery = (typeof extension === 'undefined') ? false : typeof extension.lott === 'undefined' ? false : true; /* 是否有官方抽奖 */
|
||||
const item = cardToJson.item || {};
|
||||
obj.description = item.content || item.description || ''; /* 转发者的描述 */
|
||||
@ -131,9 +133,13 @@ class Public {
|
||||
obj.origin_rid_str = desc.origin.rid_str /* 被转发者的rid(用于发评论) */
|
||||
obj.origin_dynamic_id = desc.orig_dy_id_str; /* 被转发者的动态的ID !!!!此为大数需使用字符串值,不然JSON.parse()会有丢失精度 */
|
||||
const { origin_extension, origin_user } = cardToJson;
|
||||
obj.origin_official_verify = typeof origin_user === 'undefined' ?
|
||||
false : origin_user.card.official_verify.type < 0 ?
|
||||
false : true; /* 是否官方号 */
|
||||
try {
|
||||
obj.origin_official_verify = typeof origin_user === 'undefined' ?
|
||||
false : origin_user.card.official_verify.type < 0 ?
|
||||
false : true; /* 是否官方号 */
|
||||
} catch (error) {
|
||||
obj.origin_official_verify = false;
|
||||
}
|
||||
obj.origin_hasOfficialLottery = typeof origin_extension === 'undefined' ?
|
||||
false : typeof origin_extension.lott === 'undefined' ?
|
||||
false : true; /* 是否有官方抽奖 */
|
||||
@ -153,6 +159,8 @@ class Public {
|
||||
/**
|
||||
* @typedef {object} LotteryInfo
|
||||
* @property {number} uid
|
||||
* @property {string} uname
|
||||
* @property {Array<{}>} ctrl
|
||||
* @property {string} dyid
|
||||
* @property {boolean} befilter
|
||||
* @property {boolean} official_verify 官方认证
|
||||
@ -179,13 +187,16 @@ class Public {
|
||||
for (let index = 0; index < 3; index++) {
|
||||
const newdy = await BiliAPI.getOneDynamicInfoByTag(tag_name, next_offset);
|
||||
const _modify = self.modifyDynamicRes(newdy);
|
||||
if (_modify === null) return null;
|
||||
mDRdata.push.apply(mDRdata, _modify.modifyDynamicResArray);
|
||||
next_offset = _modify.nextinfo.next_offset;
|
||||
}
|
||||
const fomatdata = mDRdata.map(o => {
|
||||
const hasOrigin = o.type === 1
|
||||
const hasOrigin = o.type === 1;
|
||||
return {
|
||||
uid: o.uid,
|
||||
uname: o.uname,
|
||||
ctrl: o.ctrl,
|
||||
dyid: o.dynamic_id,
|
||||
official_verify: o.official_verify,
|
||||
befilter: hasOrigin,
|
||||
@ -193,7 +204,7 @@ class Public {
|
||||
des: o.description,
|
||||
type: o.type,
|
||||
hasOfficialLottery: o.hasOfficialLottery
|
||||
}
|
||||
};
|
||||
})
|
||||
console.log(`成功获取带话题#${tag_name}#的动态信息`);
|
||||
return fomatdata
|
||||
@ -215,6 +226,8 @@ class Public {
|
||||
_fomatdata = mDRdata.map(o => {
|
||||
return {
|
||||
uid: o.origin_uid,
|
||||
uname: o.origin_uname,
|
||||
ctrl: [],
|
||||
dyid: o.origin_dynamic_id,
|
||||
official_verify: o.origin_official_verify,
|
||||
befilter: false,
|
||||
|
||||
@ -1,16 +1,17 @@
|
||||
module.exports = {
|
||||
version: '|version: 3.8.1|in nodejs',
|
||||
version: '|version: 3.8.2|in nodejs',
|
||||
author: '@shanmite',
|
||||
UIDs: [
|
||||
15363359,
|
||||
31252386,
|
||||
80158015,
|
||||
35719643,
|
||||
223748830
|
||||
223748830,
|
||||
689277291
|
||||
],
|
||||
TAGs: [
|
||||
'抽奖',
|
||||
'互动抽奖',
|
||||
'抽奖',
|
||||
'转发抽奖',
|
||||
'动态抽奖',
|
||||
]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user