mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-06-04 21:01:17 +08:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9bb9268b96 | ||
|
|
2294ad9f3f | ||
|
|
fe0258a84a | ||
|
|
a14af8e710 | ||
|
|
e0c18b0a1a | ||
|
|
ad6289006f | ||
|
|
1c369415ef | ||
|
|
2f4734c9de | ||
|
|
8e63e072dd | ||
|
|
d879c6336f | ||
|
|
a1a0474299 | ||
|
|
3af17e59ed | ||
|
|
d3cc24c43b |
10
.github/workflows/docker.yml
vendored
10
.github/workflows/docker.yml
vendored
@ -16,18 +16,18 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
uses: docker/setup-qemu-action@v4
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
uses: docker/setup-buildx-action@v4
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v2
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v3
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
push: true
|
||||
tags: ${{ secrets.DOCKERHUB_REPO }}
|
||||
|
||||
2
.github/workflows/mirror.yml
vendored
2
.github/workflows/mirror.yml
vendored
@ -10,7 +10,7 @@ jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Mirror + trigger CI
|
||||
|
||||
18
.github/workflows/npmp.yml
vendored
18
.github/workflows/npmp.yml
vendored
@ -1,18 +0,0 @@
|
||||
name: "Publishing to NPM"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "package.json"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: JS-DevTools/npm-publish@v1
|
||||
with:
|
||||
token: ${{ secrets.NPM_TOKEN }}
|
||||
32
.github/workflows/pkg.yml
vendored
32
.github/workflows/pkg.yml
vendored
@ -26,31 +26,29 @@ jobs:
|
||||
nodev: 18
|
||||
- platform: win
|
||||
nodev: 18
|
||||
# - platform: win
|
||||
# nodev: 12
|
||||
steps:
|
||||
- name: "Checkout codes"
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
- name: "Use Node.js"
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: "*"
|
||||
- name: "Pkg this"
|
||||
run: |
|
||||
npm run pkg "node${{ matrix.nodev }}-${{ matrix.platform }}-x64"
|
||||
- name: "Upload to artifact"
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: node${{ matrix.nodev }}-${{ matrix.platform }}-x64
|
||||
path: "dist/*.zip"
|
||||
- name: "Upload to release draft"
|
||||
uses: xresloader/upload-to-github-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
uses: softprops/action-gh-release@v3
|
||||
with:
|
||||
file: "dist/*.zip"
|
||||
files: "dist/*.zip"
|
||||
tag_name: "v2"
|
||||
overwrite: true
|
||||
draft: true
|
||||
overwrite_files: true
|
||||
token: ${{ secrets.GH_TOKEN }}
|
||||
arm64:
|
||||
runs-on: ubuntu-latest
|
||||
name: node18-${{ matrix.platform }}-arm64
|
||||
@ -62,20 +60,20 @@ jobs:
|
||||
- platform: alpine
|
||||
steps:
|
||||
- name: "Checkout codes"
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
- name: "Pkg this"
|
||||
run: |
|
||||
npm run pkg "node18-${{ matrix.platform }}-arm64"
|
||||
- name: "Upload to artifact"
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: node18-${{ matrix.platform }}-arm64
|
||||
path: "dist/*.zip"
|
||||
- name: "Upload to release draft"
|
||||
uses: xresloader/upload-to-github-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
uses: softprops/action-gh-release@v3
|
||||
with:
|
||||
file: "dist/*.zip"
|
||||
files: "dist/*.zip"
|
||||
tag_name: "v2"
|
||||
overwrite: true
|
||||
draft: true
|
||||
overwrite_files: true
|
||||
token: ${{ secrets.GH_TOKEN }}
|
||||
|
||||
19
CHANGELOG.md
19
CHANGELOG.md
@ -1,5 +1,24 @@
|
||||
<!-- markdownlint-disable MD036 MD024-->
|
||||
# CHANGELOG
|
||||
## 主要变化(2.11.1)
|
||||
* 2294ad9 fix: ai返回增加类型检查
|
||||
* fe0258a feat: ai过滤过期抽奖
|
||||
* a14af8e fix: ai模式带话题和错误at好友
|
||||
* e0c18b0 chore: 更新action
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.11.0)
|
||||
* 1c36941 fix: origin is null
|
||||
* 2f4734c chore: 不再推送至npm
|
||||
* 8e63e07 fix: @信息未获取导致转发错误标蓝
|
||||
* d879c63 fix: 转发类型动态获取不到rid无法评论 (#466)
|
||||
* a1a0474 fix: 监控uid模式获取不到动态内容
|
||||
* 3af17e5 feat: 可在设置接入AI判断动态是否是抽奖动态
|
||||
* d3cc24c feat: debug日志输出网络请求
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.10.3)
|
||||
* a2c461b fix: clear异常循环 (#484)
|
||||
* abe660b fix: prevent is_repost_then_chat from overriding AI-generated comments (#485)
|
||||
|
||||
@ -24,8 +24,6 @@
|
||||
|
||||
[](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/docker.yml)
|
||||
|
||||
[](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/npmp.yml)
|
||||
|
||||
[](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/mirror.yml)
|
||||
|
||||
已实现功能:
|
||||
@ -198,6 +196,8 @@ buvid3亦可不填 使用随机生成值
|
||||
|
||||
关键词有限 可能会有**漏掉**的或**误报**
|
||||
|
||||
可在设置开启AI判断
|
||||
|
||||
### 中奖推送
|
||||
|
||||
> 填写在env.js内
|
||||
|
||||
@ -10,6 +10,7 @@ module.exports = Object.freeze({
|
||||
* ## 高级功能
|
||||
* - `ENABLE_CHAT_CAPTCHA_OCR` 开启评论验证码识别 使用方法见README
|
||||
* - `CHAT_CAPTCHA_OCR_URL` 验证码识别接口 POST `url`->`code`
|
||||
* - `ENABLE_AI_JUDGE` 是否启用AI判断抽奖过滤过期抽奖
|
||||
* - `ENABLE_AI_COMMENTS` 是否启用AI评论
|
||||
*
|
||||
* ## 调试相关
|
||||
@ -34,6 +35,7 @@ module.exports = Object.freeze({
|
||||
|
||||
ENABLE_CHAT_CAPTCHA_OCR: false,
|
||||
CHAT_CAPTCHA_OCR_URL: 'http://127.0.0.1:9898/ocr/url/text',
|
||||
ENABLE_AI_JUDGE: false,
|
||||
ENABLE_AI_COMMENTS: false,
|
||||
|
||||
ENABLE_MULTIPLE_ACCOUNT: false,
|
||||
|
||||
@ -127,6 +127,13 @@ class Monitor extends Searcher {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (hasEnv('ENABLE_AI_JUDGE') && lottery.drawtime !== -1 && lottery.drawtime < Date.now() / 1000) {
|
||||
log.info('AI过滤', '已过开奖时间');
|
||||
d_storage.updateDyid(lottery.dyid);
|
||||
await delay(filter_wait);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lottery.isOfficialLottery) {
|
||||
let { ts } = await bili.getLotteryNotice(lottery.dyid);
|
||||
const ts_10 = Date.now() / 1000;
|
||||
@ -250,6 +257,7 @@ class Monitor extends Searcher {
|
||||
* @property {number[]} uid 用户标识
|
||||
* @property {string} dyid 动态标识
|
||||
* @property {boolean} isOfficialLottery 是否官方抽奖
|
||||
* @property {number} drawtime 开奖时间t10
|
||||
* @property {string} relay_chat 转发词
|
||||
* @property {string} ctrl 定位@
|
||||
* @property {string} [rid] 评论标识
|
||||
@ -282,7 +290,8 @@ class Monitor extends Searcher {
|
||||
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, ai_comments_parm
|
||||
only_followed, at_users, blockword, blacklist, ai_comments_parm,
|
||||
ai_judge_parm,
|
||||
} = config,
|
||||
now_ts = Date.now() / 1000;
|
||||
|
||||
@ -356,7 +365,7 @@ class Monitor extends Searcher {
|
||||
log.debug('正在筛选的动态信息', lottery_info);
|
||||
|
||||
if (des === '') {
|
||||
log.info('筛选动态', `获取动态内容为空(https://t.bilibili.com/${dyid})风控`);
|
||||
log.info('筛选动态', `获取动态内容为空(https://t.bilibili.com/${dyid})风控或是视频动态`);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -384,7 +393,7 @@ class Monitor extends Searcher {
|
||||
return false;
|
||||
}
|
||||
|
||||
const
|
||||
let
|
||||
[m_uid, ori_uid] = uids,
|
||||
mIsFollowed = !m_uid || (new RegExp(m_uid)).test(attentionList),
|
||||
oriIsFollowed = !ori_uid || (new RegExp(ori_uid)).test(attentionList),
|
||||
@ -405,6 +414,7 @@ class Monitor extends Searcher {
|
||||
isSendChat =
|
||||
(hasOfficialLottery && chatmodel[0] === '1')
|
||||
|| (!hasOfficialLottery && chatmodel[1] === '1'),
|
||||
drawtime = -1,
|
||||
keys = [dyid, m_uid, ori_uid];
|
||||
|
||||
log.debug('筛选动态', { real_uid, mIsFollowed, oriIsFollowed, realIsFollowed, needAt, needTopic, type, isRelayDynamic, key_words, has_key_words, blockword, isBlock, isLottery, isSendChat });
|
||||
@ -435,7 +445,7 @@ class Monitor extends Searcher {
|
||||
|
||||
if (reserve_id) {
|
||||
if (disable_reserve_lottery) {
|
||||
log.info('已关闭预约抽奖功能');
|
||||
log.info('预约抽奖', '已关闭预约抽奖功能');
|
||||
} else {
|
||||
log.info('预约抽奖', '开始');
|
||||
log.info('预约抽奖', `奖品: ${reserve_lottery_text}`);
|
||||
@ -452,8 +462,45 @@ class Monitor extends Searcher {
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasOfficialLottery && model[1] === '1' && !has_key_words && description) {
|
||||
log.warn('筛选动态', `无关键词动态的描述: ${description}\n\n考虑是否修改设置key_words:\n${key_words.join('\n且满足: ')}`);
|
||||
if (!hasOfficialLottery && model[1] === '1') {
|
||||
if (hasEnv('ENABLE_AI_JUDGE')) {
|
||||
let msg = await getAiContent(
|
||||
ai_judge_parm.url,
|
||||
ai_judge_parm.body,
|
||||
ai_judge_parm.prompt,
|
||||
lottery_info.des
|
||||
);
|
||||
try {
|
||||
let msg_json = JSON.parse(msg);
|
||||
if (typeof msg_json.has_key_words == 'boolean') {
|
||||
has_key_words = msg_json.has_key_words;
|
||||
isLottery = has_key_words;
|
||||
} else {
|
||||
log.warn('ai判断抽奖', 'no has_key_words');
|
||||
}
|
||||
if (typeof msg_json.needAt == 'boolean') {
|
||||
needAt = msg_json.needAt;
|
||||
} else {
|
||||
log.warn('ai判断抽奖', 'no needAt');
|
||||
}
|
||||
if (typeof msg_json.needTopic == 'string') {
|
||||
needTopic = msg_json.needTopic;
|
||||
} else {
|
||||
log.warn('ai判断抽奖', 'no needTopic');
|
||||
}
|
||||
if (typeof msg_json.drawtime == 'number') {
|
||||
drawtime = msg_json.drawtime;
|
||||
} else {
|
||||
log.warn('ai判断抽奖', 'no drawtime');
|
||||
}
|
||||
log.info('ai判断抽奖', msg_json.more);
|
||||
} catch (_) {
|
||||
log.error('ai判断抽奖', `未返回JSON格式${msg}`);
|
||||
}
|
||||
}
|
||||
if (!has_key_words && description) {
|
||||
log.warn('筛选动态', `无关键词动态的描述: ${description}\n\n考虑是否修改设置key_words或ai提示词`);
|
||||
}
|
||||
}
|
||||
|
||||
/**若勾选只转已关注 */
|
||||
@ -469,6 +516,8 @@ class Monitor extends Searcher {
|
||||
|
||||
onelotteryinfo.isOfficialLottery = hasOfficialLottery;
|
||||
|
||||
onelotteryinfo.drawtime = drawtime;
|
||||
|
||||
/**初始化待关注列表 */
|
||||
onelotteryinfo.uid = [];
|
||||
|
||||
@ -717,4 +766,4 @@ class Monitor extends Searcher {
|
||||
}
|
||||
|
||||
|
||||
module.exports = { Monitor };
|
||||
module.exports = { Monitor };
|
||||
|
||||
@ -24,18 +24,18 @@ const { log } = utils;
|
||||
* @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} 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
|
||||
* @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} 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
|
||||
*
|
||||
* 整理后的抽奖信息
|
||||
* @typedef {object} LotteryInfo
|
||||
@ -59,10 +59,6 @@ const { log } = utils;
|
||||
* @return {UsefulDynamicInfo}
|
||||
*/
|
||||
function parseDynamicCard(data) {
|
||||
if (data?.card?.desc?.uid) {
|
||||
return oldParseDynamicCard(data?.card);
|
||||
}
|
||||
|
||||
// 如果是多个 items,返回一个数组
|
||||
if (Array.isArray(data?.items)) {
|
||||
return data.items.map(item => parseDynamicCard({ item }));
|
||||
@ -96,10 +92,10 @@ function parseDynamicCard(data) {
|
||||
obj.create_time = ditem?.modules?.module_author?.pub_ts || 0;
|
||||
/* 动态类型 */
|
||||
obj.type = dy_typeenum2num.get(ditem?.type) || 0;
|
||||
/* 用于发送评论 */
|
||||
/* 用于发送评论 无法获取到源动态的rid_str*/
|
||||
obj.rid_str = ditem?.basic?.comment_id_str || '';
|
||||
/* 用于发送评论 */
|
||||
obj.chat_type = ditem?.basic?.comment_type || 0;
|
||||
obj.chat_type = dy_type2chat_type.get(ditem?.type) || 0;
|
||||
/* 转发者的动态ID !!!!此为大数需使用字符串值,不然JSON.parse()会有丢失精度 */
|
||||
obj.dynamic_id = ditem?.id_str || '';
|
||||
/* 定位@信息 */
|
||||
@ -146,7 +142,7 @@ function parseDynamicCard(data) {
|
||||
}
|
||||
/* 预约抽奖信息 */
|
||||
obj.reserve_id = ditem?.modules?.module_dynamic?.additional?.reserve?.rid || 0;
|
||||
obj.reserve_lottery_text = ditem?.modules?.module_dynamic?.additional?.reserve?.title || '信息丢失';
|
||||
obj.reserve_lottery_text = ditem?.modules?.module_dynamic?.additional?.reserve?.title || '未获取到';
|
||||
/* 充电抽奖 */
|
||||
obj.is_charge_lottery = false;
|
||||
if (ditem?.modules?.module_dynamic?.additional?.type === 'ADDITIONAL_TYPE_UPOWER_LOTTERY') {
|
||||
@ -154,208 +150,9 @@ function parseDynamicCard(data) {
|
||||
}
|
||||
/* 转发 */
|
||||
if (obj.type === 1) {
|
||||
/* 被转发者的UID */
|
||||
obj.origin_uid = ditem?.orig?.modules?.module_author?.mid || 0;
|
||||
/* 被转发者的name */
|
||||
obj.origin_uname = ditem?.orig?.modules?.module_author?.name || '';
|
||||
/* 源动态的ts10 */
|
||||
obj.origin_create_time = ditem?.orig?.modules?.module_author?.pub_ts || 0;
|
||||
/* 源动态类型 */
|
||||
obj.origin_type = dy_typeenum2num.get(ditem?.orig?.type) || 0;
|
||||
/* 被转发者的rid(用于发评论) */
|
||||
switch (ditem?.orig?.type) {
|
||||
case 'DYNAMIC_TYPE_DRAW':
|
||||
obj.origin_rid_str = ditem?.orig?.modules?.module_dynamic?.major?.draw?.id?.toString() || '';
|
||||
break;
|
||||
case 'DYNAMIC_TYPE_AV':
|
||||
obj.origin_rid_str = ditem?.orig?.modules?.module_dynamic?.major?.archive?.aid || '';
|
||||
break;
|
||||
case 'DYNAMIC_TYPE_ARTICLE':
|
||||
obj.origin_rid_str = ditem?.orig?.modules?.module_dynamic?.major?.article?.id?.toString() || '';
|
||||
break;
|
||||
default:
|
||||
obj.origin_rid_str = ditem?.orig?.id_str || '';
|
||||
break;
|
||||
}
|
||||
/* 用于发送评论 */
|
||||
obj.origin_chat_type = dy_type2chat_type.get(ditem?.orig?.type) || 0;
|
||||
/* 被转发者的动态的ID !!!!此为大数需使用字符串值,不然JSON.parse()会有丢失精度 */
|
||||
obj.origin_dynamic_id = ditem?.orig?.id_str || '';
|
||||
/* 预约抽奖信息 */
|
||||
obj.origin_reserve_id = ditem?.orig?.modules?.module_dynamic?.additional?.reserve?.rid || 0;
|
||||
obj.origin_reserve_lottery_text = ditem?.orig?.modules?.module_dynamic?.additional?.reserve?.title || '信息丢失';
|
||||
/* 充电抽奖 */
|
||||
obj.origin_is_charge_lottery = false;
|
||||
if (ditem?.orig?.modules?.module_dynamic?.additional?.type === 'ADDITIONAL_TYPE_UPOWER_LOTTERY') {
|
||||
obj.origin_is_charge_lottery = true;
|
||||
}
|
||||
/* 是否有官方抽奖 */
|
||||
obj.origin_hasOfficialLottery = false;
|
||||
/* 转发描述 */
|
||||
obj.origin_description = '';
|
||||
if (Array.isArray(ditem?.orig?.modules?.module_dynamic?.desc?.rich_text_nodes)) {
|
||||
ditem?.orig?.modules?.module_dynamic?.desc?.rich_text_nodes.forEach(node => {
|
||||
/* 是否有官方抽奖 */
|
||||
if (node.type === 'RICH_TEXT_NODE_TYPE_LOTTERY') {
|
||||
obj.origin_hasOfficialLottery = true;
|
||||
}
|
||||
obj.origin_description += node.orig_text;
|
||||
});
|
||||
} else {
|
||||
ditem?.orig.modules?.module_dynamic?.major?.opus?.summary?.rich_text_nodes.forEach(node => {
|
||||
/* 是否有官方抽奖 */
|
||||
if (node.type === 'RICH_TEXT_NODE_TYPE_LOTTERY') {
|
||||
obj.origin_hasOfficialLottery = true;
|
||||
}
|
||||
obj.origin_description += node.orig_text;
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
log.error('动态卡片解析', e);
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} dynamic_detail_card
|
||||
* @return {UsefulDynamicInfo}
|
||||
*/
|
||||
function oldParseDynamicCard(dynamic_detail_card) {
|
||||
const { strToJson } = utils;
|
||||
/**临时储存单个动态中的信息 */
|
||||
let obj = {};
|
||||
try {
|
||||
const { desc, card, extension, extend_json = '{}', display = {} } = dynamic_detail_card
|
||||
, { is_liked = 1, user_profile = {} } = desc
|
||||
, { info = {} } = user_profile || {}
|
||||
, cardToJson = strToJson(card)
|
||||
, extendjsonToJson = strToJson(extend_json)
|
||||
, { add_on_card_info = [] } = display || {}
|
||||
, { item } = cardToJson;
|
||||
const dy_type2chat_type = new Map([[1, 17], [2, 11], [4, 17], [8, 1], [64, 12]]);
|
||||
/* 转发者的UID */
|
||||
obj.uid = desc.uid;
|
||||
/* 转发者的name */
|
||||
obj.uname = info.uname || '';
|
||||
/* 动态是否点过赞 */
|
||||
obj.is_liked = is_liked > 0;
|
||||
/* 动态的ts10 */
|
||||
obj.create_time = desc.timestamp;
|
||||
/* 动态类型 */
|
||||
obj.type = desc.type;
|
||||
/* 用于发送评论 */
|
||||
obj.rid_str = desc.rid_str.length > 12 ? desc.dynamic_id_str : desc.rid_str;
|
||||
/* 用于发送评论 */
|
||||
obj.chat_type = dy_type2chat_type.get(obj.type) || 0;
|
||||
/* 转发者的动态ID !!!!此为大数需使用字符串值,不然JSON.parse()会有丢失精度 */
|
||||
obj.dynamic_id = desc.dynamic_id_str;
|
||||
/* 定位@信息 */
|
||||
obj.ctrl = (extendjsonToJson.ctrl) || [];
|
||||
/* 预约抽奖信息 */
|
||||
obj.reserve_id = '';
|
||||
obj.reserve_lottery_text = '信息丢失';
|
||||
if (add_on_card_info.length > 0) {
|
||||
const [status, oid_str, text] = add_on_card_info
|
||||
.filter(it => typeof it.reserve_attach_card !== 'undefined'
|
||||
&& typeof it.reserve_attach_card.reserve_lottery !== 'undefined'
|
||||
&& typeof it.reserve_attach_card.reserve_button !== 'undefined')
|
||||
.map(({ reserve_attach_card }) => [
|
||||
reserve_attach_card.reserve_button.status,
|
||||
reserve_attach_card.oid_str,
|
||||
reserve_attach_card.reserve_lottery.text])[0] || [];
|
||||
if (status === 1) {
|
||||
obj.reserve_id = oid_str;
|
||||
obj.reserve_lottery_text = text;
|
||||
}
|
||||
}
|
||||
if (extendjsonToJson['']) {
|
||||
let r = extendjsonToJson[''].reserve || {};
|
||||
let { reserve_id, reserve_lottery } = r;
|
||||
if (reserve_lottery === 1) {
|
||||
obj.reserve_id = reserve_id + '';
|
||||
obj.reserve_lottery_text = '信息丢失';
|
||||
}
|
||||
}
|
||||
obj.is_charge_lottery = false;
|
||||
if (extend_json.match(/"":\{"lottery/)) {
|
||||
obj.is_charge_lottery = true;
|
||||
}
|
||||
/* 是否有官方抽奖 */
|
||||
obj.hasOfficialLottery = extension && extension.lott && true || false;
|
||||
/* 转发者的描述 纯文字内容 图片动态描述 后两个分别是视频动态的描述和视频本身的描述*/
|
||||
obj.description =
|
||||
(item && ((item.content || '') + (item.description || '')))
|
||||
|| (
|
||||
(cardToJson.dynamic || '')
|
||||
+ (cardToJson.desc || '')
|
||||
+ (cardToJson.vest && cardToJson.vest.content || '')
|
||||
)
|
||||
|| '';
|
||||
if (obj.description.startsWith('互动抽奖 ')) {
|
||||
obj.hasOfficialLottery = true;
|
||||
}
|
||||
/* 转发 */
|
||||
if (obj.type === 1) {
|
||||
const { origin_extension, origin, origin_extend_json = '{}' } = cardToJson
|
||||
, originToJson = strToJson(origin)
|
||||
, { add_on_card_info = [] } = display.origin || {}
|
||||
, originExtendjsonToJson = strToJson(origin_extend_json)
|
||||
, { user, item } = originToJson;
|
||||
/* 源动态的ts10 */
|
||||
obj.origin_create_time = desc.origin.timestamp;
|
||||
/* 被转发者的UID */
|
||||
obj.origin_uid = desc.origin.uid;
|
||||
/* 源动态类型 */
|
||||
obj.origin_type = desc.orig_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 = dy_type2chat_type.get(obj.origin_type) || 0;
|
||||
/* 被转发者的动态的ID !!!!此为大数需使用字符串值,不然JSON.parse()会有丢失精度 */
|
||||
obj.origin_dynamic_id = desc.orig_dy_id_str;
|
||||
/* 预约抽奖信息 */
|
||||
obj.origin_reserve_id = '';
|
||||
obj.origin_reserve_lottery_text = '信息丢失';
|
||||
if (add_on_card_info.length > 0) {
|
||||
const [status, oid_str, text] = add_on_card_info
|
||||
.filter(it => typeof it.reserve_attach_card !== 'undefined'
|
||||
&& typeof it.reserve_attach_card.reserve_lottery !== 'undefined'
|
||||
&& typeof it.reserve_attach_card.reserve_button !== 'undefined')
|
||||
.map(({ reserve_attach_card }) => [
|
||||
reserve_attach_card.reserve_button.status,
|
||||
reserve_attach_card.oid_str,
|
||||
reserve_attach_card.reserve_lottery.text])[0] || [];
|
||||
if (status === 1) {
|
||||
obj.origin_reserve_id = oid_str;
|
||||
obj.origin_reserve_lottery_text = text;
|
||||
}
|
||||
}
|
||||
if (originExtendjsonToJson['']) {
|
||||
let r = originExtendjsonToJson[''].reserve || {};
|
||||
let { reserve_id, reserve_lottery } = r;
|
||||
if (reserve_lottery === 1) {
|
||||
obj.origin_reserve_id = reserve_id + '';
|
||||
obj.origin_reserve_lottery_text = '信息丢失';
|
||||
}
|
||||
}
|
||||
obj.origin_is_charge_lottery = false;
|
||||
if (origin_extend_json.match(/"":\{"lottery/)) {
|
||||
obj.origin_is_charge_lottery = true;
|
||||
}
|
||||
/* 是否有官方抽奖 */
|
||||
obj.origin_hasOfficialLottery = origin_extension && origin_extension.lott || false;
|
||||
/* 被转发者的name */
|
||||
obj.origin_uname = (user && (user.name || user.uname)) || '';
|
||||
/* 被转发者的描述 */
|
||||
obj.origin_description =
|
||||
(item && (item.content || '' + item.description || ''))
|
||||
|| (originToJson.dynamic || '' + originToJson.desc || '')
|
||||
|| '';
|
||||
if (obj.origin_description.startsWith('互动抽奖 ')) {
|
||||
obj.origin_hasOfficialLottery = true;
|
||||
}
|
||||
obj.origin = parseDynamicCard({item: ditem.orig});
|
||||
} else {
|
||||
obj.origin = {};
|
||||
}
|
||||
} catch (e) {
|
||||
log.error('动态卡片解析', e);
|
||||
@ -513,36 +310,31 @@ class Searcher {
|
||||
}
|
||||
})
|
||||
.reduce(async (pre, cur) => {
|
||||
let
|
||||
results = await pre,
|
||||
{ origin_dynamic_id } = cur,
|
||||
is_liked = false;
|
||||
let results = await pre;
|
||||
|
||||
if (!check_if_duplicated || check_if_duplicated >= 2) {
|
||||
const card = await bili.getOneDynamicByDyid(origin_dynamic_id);
|
||||
log.info('获取动态', `查看源动态(${origin_dynamic_id})是否点赞 (${length--})`);
|
||||
if (card) {
|
||||
({ is_liked } = parseDynamicCard(card));
|
||||
}
|
||||
await utils.delay(get_dynamic_detail_wait);
|
||||
const card = await bili.getOneDynamicByDyid(cur.origin.dynamic_id);
|
||||
log.info('获取动态', `查看源动态(${cur.origin.dynamic_id})详细信息获取rid用于评论 (${length--})`);
|
||||
if (card) {
|
||||
cur.origin = parseDynamicCard(card);
|
||||
}
|
||||
await utils.delay(get_dynamic_detail_wait);
|
||||
|
||||
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,
|
||||
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.origin_type,
|
||||
hasOfficialLottery: cur.origin_hasOfficialLottery
|
||||
create_time: cur.origin.create_time,
|
||||
is_liked: cur.origin.is_liked,
|
||||
uids: [cur.uid, cur.origin.uid],
|
||||
uname: cur.origin.uname,
|
||||
ctrl: cur.origin.ctrl,
|
||||
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.origin.type,
|
||||
hasOfficialLottery: cur.origin.hasOfficialLottery
|
||||
});
|
||||
|
||||
return results;
|
||||
@ -595,7 +387,7 @@ class Searcher {
|
||||
lottery_info_type: 'tag',
|
||||
create_time: o.create_time,
|
||||
is_liked: o.is_liked,
|
||||
uids: [o.uid, o.origin_uid],
|
||||
uids: [o.uid, o.origin.uid],
|
||||
uname: o.uname,
|
||||
ctrl: o.ctrl,
|
||||
dyid: o.dynamic_id,
|
||||
@ -688,7 +480,7 @@ class Searcher {
|
||||
lottery_info_type: 'article',
|
||||
create_time: o.create_time,
|
||||
is_liked: o.is_liked,
|
||||
uids: [o.uid, o.origin_uid],
|
||||
uids: [o.uid, o.origin.uid],
|
||||
uname: o.uname,
|
||||
ctrl: o.ctrl,
|
||||
dyid: o.dynamic_id,
|
||||
@ -829,7 +621,7 @@ class Searcher {
|
||||
lottery_info_type: 'txt',
|
||||
create_time: o.create_time,
|
||||
is_liked: o.is_liked,
|
||||
uids: [o.uid, o.origin_uid],
|
||||
uids: [o.uid, o.origin.uid],
|
||||
uname: o.uname,
|
||||
ctrl: o.ctrl,
|
||||
dyid: o.dynamic_id,
|
||||
|
||||
@ -86,6 +86,12 @@ const config = {
|
||||
'[转关评粉]|参与'
|
||||
],
|
||||
|
||||
ai_judge_parm: {
|
||||
url: '',
|
||||
body: {},
|
||||
prompt: ''
|
||||
},
|
||||
|
||||
/**
|
||||
* - '00' 关闭自动抽奖
|
||||
* - '10' 只转发官方抽奖
|
||||
@ -484,4 +490,4 @@ const config = {
|
||||
};
|
||||
|
||||
|
||||
module.exports = config;
|
||||
module.exports = config;
|
||||
|
||||
@ -5,7 +5,6 @@ module.exports = Object.freeze({
|
||||
DYNAMIC_REPOST_SHARE: 'https://api.vc.bilibili.com/dynamic_repost/v1/dynamic_repost/share',
|
||||
DYNAMIC_SVR_CREATE_DRAW: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/create_draw',
|
||||
DYNAMIC_SVR_CREATE: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/create',
|
||||
DYNAMIC_SVR_GET_DYNAMIC_DETAIL: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/get_dynamic_detail',
|
||||
DYNAMIC_SVR_RM_DYNAMIC: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/rm_dynamic',
|
||||
FEED_GET_ATTENTION_LIST: 'https://api.vc.bilibili.com/feed/v1/feed/get_attention_list',
|
||||
FEED_SETUSERFOLLOW: 'https://api.vc.bilibili.com/feed/v1/feed/SetUserFollow',
|
||||
|
||||
@ -98,8 +98,8 @@ function get({ url, config, contents, query }) {
|
||||
},
|
||||
query,
|
||||
contents,
|
||||
success: res => resolve(res.body),
|
||||
failure: err => resolve(err)
|
||||
success: res => resolve(log.debug_return(url, res.body)),
|
||||
failure: err => resolve(log.debug_return(url, err))
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -122,8 +122,8 @@ function post({ url, config, contents, query }) {
|
||||
},
|
||||
query,
|
||||
contents,
|
||||
success: res => resolve(res.body),
|
||||
failure: err => resolve(err)
|
||||
success: res => resolve(log.debug_return(url, res.body)),
|
||||
failure: err => resolve(log.debug_return(url, err))
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -423,13 +423,6 @@ const bili_client = {
|
||||
features: 'itemOpusStyle'
|
||||
}
|
||||
}),
|
||||
(dynamic_id) => get({
|
||||
url: API.DYNAMIC_SVR_GET_DYNAMIC_DETAIL,
|
||||
config: { retry: false },
|
||||
query: {
|
||||
dynamic_id
|
||||
}
|
||||
}),
|
||||
]
|
||||
, responseText => {
|
||||
const
|
||||
@ -464,6 +457,7 @@ const bili_client = {
|
||||
query: {
|
||||
host_mid,
|
||||
offset,
|
||||
features: 'itemOpusStyle'
|
||||
},
|
||||
config: {
|
||||
retry: false
|
||||
|
||||
14
lib/utils.js
14
lib/utils.js
@ -242,6 +242,10 @@ const utils = {
|
||||
this.proPrint(color_text_pair.map(([color, text]) => color(text)));
|
||||
}
|
||||
},
|
||||
debug_return(context, obj) {
|
||||
this.debug(context, obj);
|
||||
return obj;
|
||||
},
|
||||
info(context, msg) {
|
||||
if (this._level >= 3) {
|
||||
let color_text_pair = [
|
||||
@ -510,7 +514,7 @@ const utils = {
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 获取ai评论
|
||||
* 获取ai
|
||||
* @param {string} url
|
||||
* @param {object} body
|
||||
* @param {string} prompt
|
||||
@ -526,10 +530,12 @@ const utils = {
|
||||
'authorization': 'Bearer ' + process.env.AI_API_KEY,
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
config: {
|
||||
timeout: 120000
|
||||
},
|
||||
contents: {
|
||||
...body,
|
||||
'stream': false,
|
||||
'enable_thinking': true,
|
||||
'response_format': { 'type': 'text' },
|
||||
'messages': [
|
||||
{
|
||||
@ -544,7 +550,7 @@ const utils = {
|
||||
},
|
||||
success: res => {
|
||||
const data = utils.strToJson(res.body);
|
||||
resolve(data?.choices?.[0]?.message?.content || null);
|
||||
resolve(utils.log.debug_return(content, data?.choices?.[0]?.message?.content) || null);
|
||||
},
|
||||
failure: () => {
|
||||
resolve(null);
|
||||
@ -555,4 +561,4 @@ const utils = {
|
||||
};
|
||||
|
||||
|
||||
module.exports = utils;
|
||||
module.exports = utils;
|
||||
|
||||
@ -90,6 +90,19 @@ module.exports = Object.freeze({
|
||||
'[转关评粉]|参与'
|
||||
],
|
||||
|
||||
/**
|
||||
* AI 判断抽奖
|
||||
* https://learn.microsoft.com/en-us/azure/ai-foundry/openai/reference#chat-completions
|
||||
*/
|
||||
ai_judge_parm: {
|
||||
/**
|
||||
* /chat/completions
|
||||
*/
|
||||
url: '',
|
||||
body: {},
|
||||
prompt: ''
|
||||
},
|
||||
|
||||
/**
|
||||
* - '00' 关闭自动抽奖
|
||||
* - '10' 只转发官方抽奖
|
||||
@ -496,23 +509,22 @@ module.exports = Object.freeze({
|
||||
|
||||
APIs: [],
|
||||
|
||||
/**
|
||||
* 默认为硅基流动,可以修改为其他AI服务
|
||||
*/
|
||||
ai_comments_parm: {
|
||||
url: 'https://api.siliconflow.cn/v1/chat/completions',
|
||||
ai_judge_parm: {
|
||||
url: 'https://api.deepseek.com/chat/completions',
|
||||
body: {
|
||||
'model': 'Qwen/Qwen3-32B',
|
||||
'max_tokens': 512,
|
||||
'thinking_budget': 4096,
|
||||
'min_p': 0.05,
|
||||
'temperature': 0.7,
|
||||
'top_p': 0.7,
|
||||
'top_k': 50,
|
||||
'frequency_penalty': 0.5,
|
||||
'n': 1,
|
||||
'enable_thinking': true,
|
||||
},
|
||||
prompt: '请根据以下内容直接生成一条简短评论,无需说明信息,且不包含任何敏感词汇。'
|
||||
prompt: '你是一个B站用户,需要判断动态内容是否是抽奖动态,以及参与条件,以json格式输出,仅需包含key:has_key_words(bool 是否是抽奖动态),needAt(bool 参与抽奖是否需要@自己的好友),needTopic(string 参与抽奖需要带的话题,返回话题需要用#号括起来),drawtime(number 开奖时间的10位数时间戳未获取到返回-1),more(string 总结参与抽奖的条件).回答不要包含markdown标记文本,输出纯json文本'
|
||||
},
|
||||
|
||||
ai_comments_parm: {
|
||||
url: 'https://api.deepseek.com/chat/completions',
|
||||
body: {
|
||||
'model': 'Qwen/Qwen3-32B',
|
||||
'enable_thinking': true,
|
||||
},
|
||||
prompt: '你是一个B站用户,请根据以下内容直接生成一条模拟真实用户的评论,不要使用表情,无需说明信息,且不包含任何敏感词汇。'
|
||||
},
|
||||
|
||||
save_lottery_info_to_file: true,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "lottery-auto-script",
|
||||
"version": "2.10.3",
|
||||
"version": "2.11.1",
|
||||
"description": "自动参与B站动态抽奖",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
||||
@ -3,30 +3,30 @@
|
||||
# version: <major.minor.patch>
|
||||
level=patch
|
||||
|
||||
npm version $level \
|
||||
--no-commit-hooks \
|
||||
--no-git-tag-version
|
||||
|
||||
OLD_VERSION_ARRAY=($(npm view lottery-auto-script version | tr '.' ' '))
|
||||
OLD_VERSION_ARRAY=($(npm pkg get version | tr -d '"' | tr '.' ' '))
|
||||
major=${OLD_VERSION_ARRAY[0]}
|
||||
minor=${OLD_VERSION_ARRAY[1]}
|
||||
patch=${OLD_VERSION_ARRAY[2]}
|
||||
|
||||
case "${level}" in
|
||||
"major")
|
||||
((major += 1))
|
||||
minor=0
|
||||
patch=0
|
||||
;;
|
||||
((major += 1))
|
||||
minor=0
|
||||
patch=0
|
||||
;;
|
||||
"minor")
|
||||
((minor += 1))
|
||||
patch=0
|
||||
;;
|
||||
((minor += 1))
|
||||
patch=0
|
||||
;;
|
||||
*)
|
||||
((patch += 1))
|
||||
;;
|
||||
((patch += 1))
|
||||
;;
|
||||
esac
|
||||
|
||||
npm version $level \
|
||||
--no-commit-hooks \
|
||||
--no-git-tag-version
|
||||
|
||||
NEW_VERSION="$major.$minor.$patch"
|
||||
|
||||
echo "New Version: $NEW_VERSION"
|
||||
|
||||
54
test/ai.test.js
Normal file
54
test/ai.test.js
Normal file
@ -0,0 +1,54 @@
|
||||
const util = require('./util');
|
||||
const utils = require('../lib/utils.js');
|
||||
const config = require('../lib/data/config');
|
||||
|
||||
(async () => {
|
||||
await util.par_run([0], [
|
||||
// 0
|
||||
async () => {
|
||||
let msg = await utils.getAiContent(
|
||||
config.ai_judge_parm.url,
|
||||
config.ai_judge_parm.body,
|
||||
config.ai_judge_parm.prompt,
|
||||
'#胜利女神新的希望# #nikke# \n【一周年评论盖楼挑战③】拿来吧妮……的表情包!\n\n指挥官的手机里,\n一定存着几张出场率超高的妮姬表情包吧?\n和妮姬们相遇的一周年已至,这些也成了旅途中的一段快乐印记~是时候公开自己的库存了yo!\n\n无论是新收新做的趣味表情,还是珍藏一年的经典老图——\n现在,让它们登场吧!\n\n评论区交出您的表情包库存,看看这一年谁的“收藏”最cool!!\n🎁我们将在6月9日于本条评论区随机抽选:\n▶1位指挥官赠送【周边大礼盒】× 1\n▶10位指挥官赠送【Q版印章小立牌】× 1\n\n💝盖楼目标达成奖励:\n5月20日~22日期间,参与【一周年评论盖楼挑战】系列话题活动! 当全平台评论数累计达成 【2026】 楼时,我们将从本平台参与系列话题活动的用户中额外抽取2位幸运指挥官,每人送出【哈曼卡顿音响】× 1!\n\n————————————\n✦《胜利女神:新的希望》一周年庆典版本「OLD TALES 尘封童话」现已上线!游戏多端互通,前往Bilibili游戏中心搜索《胜利女神:新的希望》即可下载。'
|
||||
);
|
||||
console.log(JSON.parse(msg));
|
||||
msg = await utils.getAiContent(
|
||||
config.ai_comments_parm.url,
|
||||
config.ai_comments_parm.body,
|
||||
config.ai_comments_parm.prompt,
|
||||
'#胜利女神新的希望# #nikke# \n【一周年评论盖楼挑战③】拿来吧妮……的表情包!\n\n指挥官的手机里,\n一定存着几张出场率超高的妮姬表情包吧?\n和妮姬们相遇的一周年已至,这些也成了旅途中的一段快乐印记~是时候公开自己的库存了yo!\n\n无论是新收新做的趣味表情,还是珍藏一年的经典老图——\n现在,让它们登场吧!\n\n评论区交出您的表情包库存,看看这一年谁的“收藏”最cool!!\n🎁我们将在6月9日于本条评论区随机抽选:\n▶1位指挥官赠送【周边大礼盒】× 1\n▶10位指挥官赠送【Q版印章小立牌】× 1\n\n💝盖楼目标达成奖励:\n5月20日~22日期间,参与【一周年评论盖楼挑战】系列话题活动! 当全平台评论数累计达成 【2026】 楼时,我们将从本平台参与系列话题活动的用户中额外抽取2位幸运指挥官,每人送出【哈曼卡顿音响】× 1!\n\n————————————\n✦《胜利女神:新的希望》一周年庆典版本「OLD TALES 尘封童话」现已上线!游戏多端互通,前往Bilibili游戏中心搜索《胜利女神:新的希望》即可下载。'
|
||||
);
|
||||
console.log(msg);
|
||||
msg = await utils.getAiContent(
|
||||
config.ai_judge_parm.url,
|
||||
config.ai_judge_parm.body,
|
||||
config.ai_judge_parm.prompt,
|
||||
'#全民掉线行动#今日启动!参与活动,领GT7、X1心动优惠 2022年助你去线去烦恼,乐享焕新声活!活动规则见下图。 #供电局福利社# #互动抽奖##抽奖# 【关注】@Haylou嘿喽 ,带话题#全民掉线行动#,【转发+评论+赞】本动态,小嘿将随机抽4个欧皇送出以下福利: 一等奖:Haylou X1 双降噪蓝牙耳机 1台 二等奖:Haylou GT7 真无线蓝牙耳机1台 三等奖:50元京东卡*2 并且小嘿特意又申请了意外惊喜,加码福利送上,大家冲鸭: 截至抽奖结束: 【转发超1w】,再抽一位小可爱送50元京东卡*1 【粉丝超1.5w】,再抽一位小可爱送Haylou T17运动蓝牙耳机*1台 开奖时间1月27日,中奖名单将通过第三方抽奖工具选出。冲冲冲! *一定要时刻关注@Haylou嘿喽 哦!开奖后的3天内,未回复小嘿私信领奖的粉丝按照自动弃奖处理哦! '
|
||||
);
|
||||
console.log(JSON.parse(msg));
|
||||
msg = await utils.getAiContent(
|
||||
config.ai_comments_parm.url,
|
||||
config.ai_comments_parm.body,
|
||||
config.ai_comments_parm.prompt,
|
||||
'#全民掉线行动#今日启动!参与活动,领GT7、X1心动优惠 2022年助你去线去烦恼,乐享焕新声活!活动规则见下图。 #供电局福利社# #互动抽奖##抽奖# 【关注】@Haylou嘿喽 ,带话题#全民掉线行动#,【转发+评论+赞】本动态,小嘿将随机抽4个欧皇送出以下福利: 一等奖:Haylou X1 双降噪蓝牙耳机 1台 二等奖:Haylou GT7 真无线蓝牙耳机1台 三等奖:50元京东卡*2 并且小嘿特意又申请了意外惊喜,加码福利送上,大家冲鸭: 截至抽奖结束: 【转发超1w】,再抽一位小可爱送50元京东卡*1 【粉丝超1.5w】,再抽一位小可爱送Haylou T17运动蓝牙耳机*1台 开奖时间1月27日,中奖名单将通过第三方抽奖工具选出。冲冲冲! *一定要时刻关注@Haylou嘿喽 哦!开奖后的3天内,未回复小嘿私信领奖的粉丝按照自动弃奖处理哦! '
|
||||
);
|
||||
console.log(msg);
|
||||
msg = await utils.getAiContent(
|
||||
config.ai_judge_parm.url,
|
||||
config.ai_judge_parm.body,
|
||||
config.ai_judge_parm.prompt,
|
||||
'#全民掉线行动#今日启动!参与活动,领GT7、X1心动优惠 2022年助你去线去烦恼,乐享焕新声活!活动规则见下图。 #供电局福利社# #互动抽奖##抽奖# 【关注】@Haylou嘿喽 ,带话题#全民掉线行动#,【转发+评论+赞】本动态,小嘿将随机抽4个欧皇送出以下福利: 一等奖:Haylou X1 双降噪蓝牙耳机 1台 二等奖:Haylou GT7 真无线蓝牙耳机1台 三等奖:50元京东卡*2 并且小嘿特意又申请了意外惊喜,加码福利送上,大家冲鸭: 截至抽奖结束: 【转发超1w】,再抽一位小可爱送50元京东卡*1 【粉丝超1.5w】,再抽一位小可爱送Haylou T17运动蓝牙耳机*1台,中奖名单将通过第三方抽奖工具选出。冲冲冲! *一定要时刻关注@Haylou嘿喽 哦!开奖后的3天内,未回复小嘿私信领奖的粉丝按照自动弃奖处理哦! '
|
||||
);
|
||||
console.log(JSON.parse(msg));
|
||||
msg = await utils.getAiContent(
|
||||
config.ai_comments_parm.url,
|
||||
config.ai_comments_parm.body,
|
||||
config.ai_comments_parm.prompt,
|
||||
'#全民掉线行动#今日启动!参与活动,领GT7、X1心动优惠 2022年助你去线去烦恼,乐享焕新声活!活动规则见下图。 #供电局福利社# #互动抽奖##抽奖# 【关注】@Haylou嘿喽 ,带话题#全民掉线行动#,【转发+评论+赞】本动态,小嘿将随机抽4个欧皇送出以下福利: 一等奖:Haylou X1 双降噪蓝牙耳机 1台 二等奖:Haylou GT7 真无线蓝牙耳机1台 三等奖:50元京东卡*2 并且小嘿特意又申请了意外惊喜,加码福利送上,大家冲鸭: 截至抽奖结束: 【转发超1w】,再抽一位小可爱送50元京东卡*1 【粉丝超1.5w】,再抽一位小可爱送Haylou T17运动蓝牙耳机*1台 开奖时间1月27日,中奖名单将通过第三方抽奖工具选出。冲冲冲! *一定要时刻关注@Haylou嘿喽 哦!开奖后的3天内,未回复小嘿私信领奖的粉丝按照自动弃奖处理哦! '
|
||||
);
|
||||
console.log(msg);
|
||||
},
|
||||
]);
|
||||
console.log('ai.test ... ok!');
|
||||
})();
|
||||
@ -1,70 +1,17 @@
|
||||
const assert = require('assert');
|
||||
//const assert = require('assert');
|
||||
const bili_client = require('../lib/net/bili');
|
||||
const searcher = require('../lib/core/searcher');
|
||||
const util = require('./util');
|
||||
|
||||
(async () => {
|
||||
await util.par_run([0, 1], [
|
||||
await util.par_run([], [
|
||||
// 0
|
||||
async () => {
|
||||
let info = await bili_client.getOneDynamicByDyid('728424890210713624');
|
||||
assert(searcher.parseDynamicCard(info).is_charge_lottery);
|
||||
info = await bili_client.getOneDynamicByDyid('1143258210499559428');
|
||||
assert(searcher.parseDynamicCard(info).is_charge_lottery);
|
||||
},
|
||||
// 1
|
||||
async () => {
|
||||
let info = await bili_client.getOneDynamicByDyid('1150096953788334085');
|
||||
assert(searcher.parseDynamicCard(info).origin_is_charge_lottery);
|
||||
},
|
||||
// 2
|
||||
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][0] == 'string');
|
||||
},
|
||||
// 3
|
||||
async () => {
|
||||
let card = searcher.parseDynamicCard(await bili_client.getOneDynamicByDyid('900172162530279445'));
|
||||
assert.equal(card.chat_type, 11);
|
||||
card = searcher.parseDynamicCard(await bili_client.getOneDynamicByDyid('926978638295859236'));
|
||||
assert.equal(card.chat_type, 17);
|
||||
assert.equal(card.origin_chat_type, 11);
|
||||
},
|
||||
// 4
|
||||
async () => {
|
||||
// assert.equal(await bili_client.getOneDynamicByDyid("111111111111111111"), undefined);
|
||||
// assert.notEqual(await bili_client.getOneDynamicByDyid("746824225190314008"), undefined);
|
||||
// assert.equal(await bili_client.getOneDynamicByDyid("761475750233636886"), undefined);
|
||||
},
|
||||
// 5
|
||||
async () => {
|
||||
let card = searcher.parseDynamicCard(await bili_client.getOneDynamicByDyid('762591475338838053'));
|
||||
let chats = await bili_client.getChat(card.rid_str, card.chat_type);
|
||||
assert.equal(chats.length, 19);
|
||||
card = searcher.parseDynamicCard(await bili_client.getOneDynamicByDyid('762502724122050647'));
|
||||
chats = await bili_client.getChat(card.rid_str, card.chat_type);
|
||||
assert.equal(chats.filter(it => it[0] === '六的月').length, 0);
|
||||
},
|
||||
// 6
|
||||
async () => {
|
||||
const dy = await bili_client.getOneDynamicByDyid('774973685666676768');
|
||||
const card = searcher.parseDynamicCard(dy);
|
||||
assert.notEqual(card.description + '', undefined + '');
|
||||
},
|
||||
// 7
|
||||
async () => {
|
||||
const dy = await bili_client.getOneDynamicByDyid('924676093465591832');
|
||||
const card = searcher.parseDynamicCard(dy);
|
||||
assert.equal(card.reserve_id, '3715576');
|
||||
},
|
||||
// 8
|
||||
async () => {
|
||||
const dy = await bili_client.getOneDynamicByDyid('925061227481137187');
|
||||
const card = searcher.parseDynamicCard(dy);
|
||||
assert.equal(card.origin_reserve_id, '3715576');
|
||||
let info = await bili_client.getOneDynamicByDyid('1207028214165143570');
|
||||
let card = searcher.parseDynamicCard(info);
|
||||
console.log(JSON.stringify(card, null, 4));
|
||||
},
|
||||
]);
|
||||
|
||||
console.log('dynamic_card.test ... ok!');
|
||||
})();
|
||||
})();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user