Compare commits

...
2 Commits
Author SHA1 Message Date
shanmite c06f69457a pref: 时区+8(#13) 2021-08-14 13:24:54 +08:00
shanmite 155332751f fix: 解构赋初值异常 2021-08-14 13:02:46 +08:00
4 changed files with 11 additions and 11 deletions
+4 -4
View File
@@ -86,8 +86,8 @@ function parseDynamicCard(dynamic_detail_card) {
*/
function modifyDynamicRes(res) {
const
{ data = {}, code } = utils.strToJson(res),
{ cards = [], has_more, offset } = data;
{ data, code } = utils.strToJson(res),
{ cards = [], has_more, offset } = data || {};
if (code !== 0) {
log.error('处理动态数据', '获取动态数据出错,可能是访问太频繁 \n' + res);
@@ -320,8 +320,8 @@ class Searcher {
if (!isRelayed) {
log.info('获取动态', `查看动态(${dyid})的细节 (${length--})`)
const res = await bili.getOneDynamicByDyid(dyid)
, { code, data = {} } = utils.strToJson(res)
, { card } = data;
, { code, data } = utils.strToJson(res)
, { card } = data || {};
if (code !== 0) {
log.error('获取动态', '获取动态数据出错,可能是访问太频繁 \n' + res)
+2 -2
View File
@@ -161,8 +161,8 @@ const bili_client = {
const sessions = res.data.session_list || [];
const has_more = res.data.has_more;
const data = sessions.map(session => {
const { session_ts, last_msg = {}, unread_count, talker_id } = session;
const { content = '', timestamp = 0, sender_uid = 0, msg_seqno } = last_msg;
const { session_ts, last_msg, unread_count, talker_id } = session;
const { content = '', timestamp = 0, sender_uid = 0, msg_seqno } = last_msg || {};
return { session_ts, content, timestamp, sender_uid, unread_count, talker_id, msg_seqno }
})
return { has_more, data }
+4 -4
View File
@@ -184,20 +184,20 @@ const utils = {
debug(context, msg) {
if (this.level > 3) {
if (msg instanceof Object) msg = JSON.stringify(msg, null, 4);
this.proPrint([chalk.hex('#64B3FF')(`[${new Date().toISOString()}]`), chalk.grey("[Debug]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#0070BB')(`[\n${msg}\n]`)])
this.proPrint([chalk.hex('#64B3FF')(`[${new Date(Date.now() + 288e5).toISOString()}]`), chalk.grey("[Debug]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#0070BB')(`[\n${msg}\n]`)])
}
},
info(context, msg) {
if (this.level > 2)
this.proPrint([chalk.hex('#64B3FF')(`[${new Date().toISOString()}]`), chalk.grey("[Info]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#48BB31')(`[${msg}]`)])
this.proPrint([chalk.hex('#64B3FF')(`[${new Date(Date.now() + 288e5).toISOString()}]`), chalk.grey("[Info]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#48BB31')(`[${msg}]`)])
},
warn(context, msg) {
if (this.level > 1)
this.proPrint([chalk.hex('#64B3FF')(`[${new Date().toISOString()}]`), chalk.grey("[Warn]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#BBBB23')(`[${msg}]`)])
this.proPrint([chalk.hex('#64B3FF')(`[${new Date(Date.now() + 288e5).toISOString()}]`), chalk.grey("[Warn]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#BBBB23')(`[${msg}]`)])
},
error(context, msg) {
if (this.level > 0)
this.proPrint([chalk.hex('#64B3FF')(`[${new Date().toISOString()}]`), chalk.grey("[Error]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#FF0006')(`[${msg}]`)])
this.proPrint([chalk.hex('#64B3FF')(`[${new Date(Date.now() + 288e5).toISOString()}]`), chalk.grey("[Error]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#FF0006')(`[${msg}]`)])
}
},
/**
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "lottery-auto-script",
"version": "2.0.6",
"version": "2.0.7",
"description": "自动参与B站动态抽奖",
"main": "main.js",
"scripts": {