diff --git a/lib/core/monitor.js b/lib/core/monitor.js index 82b8fbb..9ead865 100644 --- a/lib/core/monitor.js +++ b/lib/core/monitor.js @@ -223,8 +223,9 @@ class Monitor extends Searcher { * @property {boolean} isOfficialLottery 是否官方抽奖 * @property {string} relay_chat 转发词 * @property {string} ctrl 定位@ - * @property {string} rid 评论标识 + * @property {string} [rid] 评论标识 * @property {number} chat_type 评论类型 + * @property {string} [chat] 评论词 */ /** * @returns {Promise} @@ -244,7 +245,7 @@ class Monitor extends Searcher { /** 所有抽奖信息 */ let alllotteryinfo = []; const - { 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, + { check_if_duplicated, set_lottery_info_url, 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; /** @@ -403,6 +404,7 @@ class Monitor extends Searcher { } if (isLottery) { + const { uname_map = {} } = global_var.get("remoteconfig") let onelotteryinfo = {}; onelotteryinfo.isOfficialLottery = hasOfficialLottery; @@ -418,7 +420,8 @@ class Monitor extends Searcher { let /**转发评语 */ - RandomStr = getRandomOne(config.relay), + RandomStr = getRandomOne(relays) + .replaceAll('${uname}', uname_map[real_uid] || uname), /**控制字段 */ new_ctrl = []; @@ -475,7 +478,11 @@ class Monitor extends Searcher { : 0; /* 是否评论 */ - if (isSendChat) onelotteryinfo.rid = rid; + if (isSendChat) { + onelotteryinfo.rid = rid + onelotteryinfo.chat = getRandomOne(chats) + .replaceAll('${uname}', uname_map[real_uid] || uname) + } alllotteryinfo.push(onelotteryinfo); } else { @@ -520,8 +527,8 @@ class Monitor extends Searcher { let status = 0 const - { uid, dyid, chat_type, rid, relay_chat, ctrl } = option, - { chat, check_if_duplicated, is_repost_then_chat } = config; + { uid, dyid, chat_type, rid, relay_chat, ctrl, chat } = option, + { check_if_duplicated, is_repost_then_chat } = config; /* 评论 */ if (rid && chat_type) { @@ -531,7 +538,7 @@ class Monitor extends Searcher { [1, 4], () => bili.sendChat( rid, - is_repost_then_chat ? relay_chat : getRandomOne(chat), + is_repost_then_chat ? relay_chat : chat, chat_type ) ) diff --git a/lib/utils.js b/lib/utils.js index 424b411..bbdce99 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -303,12 +303,12 @@ const utils = { if (body.node_msg) utils.log.info('公告', '\n' + body.node_msg + '\n'); resolve(body.config) } catch (error) { - resolve(JSON.parse('{}')) + resolve({}) } }, failure: err => { utils.log.error('获取远程设置', '获取远程设置错误: ' + err); - resolve(JSON.parse('{}')); + resolve({}) } }) }) diff --git a/my_config.example.js b/my_config.example.js index 10517e0..88833a4 100644 --- a/my_config.example.js +++ b/my_config.example.js @@ -289,11 +289,15 @@ module.exports = Object.freeze({ /** * 转发评语 + * 支持变量${uname} */ relay: ['转发动态'], /** * 评论内容 + * 支持变量${uname} + * @example + * "祝${uname}早日百大!" */ chat: [ '[OK]', '[星星眼]', '[歪嘴]', '[喜欢]', '[偷笑]', '[笑]', '[喜极而泣]', '[辣眼睛]', '[吃瓜]', '[奋斗]',