yz-yuki-plugin 1.0.1-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.puppeteerrc.cjs +4 -0
- package/CHANGELOG.md +7 -0
- package/LICENSE +21 -0
- package/README.md +195 -0
- package/defaultConfig/bilibili/config.yaml +41 -0
- package/defaultConfig/bilibili/push.yaml +0 -0
- package/defaultConfig/help/help.yaml +86 -0
- package/defaultConfig/weibo/config.yaml +41 -0
- package/defaultConfig/weibo/push.yaml +0 -0
- package/lib/apps/bilibili.js +402 -0
- package/lib/apps/help.js +37 -0
- package/lib/apps/index.js +4 -0
- package/lib/apps/version.js +34 -0
- package/lib/apps/weibo.js +252 -0
- package/lib/components/dynamic/Account.js +26 -0
- package/lib/components/dynamic/Content.js +118 -0
- package/lib/components/dynamic/Footer.js +36 -0
- package/lib/components/dynamic/ForwardContent.js +15 -0
- package/lib/components/dynamic/LogoText.js +10 -0
- package/lib/components/dynamic/MainPage.js +22 -0
- package/lib/components/help/Help.js +33 -0
- package/lib/components/index.js +6 -0
- package/lib/components/loginQrcode/Page.js +21 -0
- package/lib/components/version/Version.js +27 -0
- package/lib/index.js +29 -0
- package/lib/models/bilibili/bilibili.api.js +49 -0
- package/lib/models/bilibili/bilibili.get.web.data.js +80 -0
- package/lib/models/bilibili/bilibili.models.js +484 -0
- package/lib/models/bilibili/bilibili.query.js +393 -0
- package/lib/models/bilibili/bilibili.task.js +256 -0
- package/lib/models/bilibili/bilibili.wbi.js +49 -0
- package/lib/models/help/help.js +20 -0
- package/lib/models/version/version.js +62 -0
- package/lib/models/weibo/weibo.api.js +19 -0
- package/lib/models/weibo/weibo.get.web.data.js +55 -0
- package/lib/models/weibo/weibo.query.js +323 -0
- package/lib/models/weibo/weibo.task.js +215 -0
- package/lib/types/apps/bilibili.d.ts +6 -0
- package/lib/types/apps/help.d.ts +6 -0
- package/lib/types/apps/index.d.ts +4 -0
- package/lib/types/apps/version.d.ts +6 -0
- package/lib/types/apps/weibo.d.ts +6 -0
- package/lib/types/components/dynamic/Account.d.ts +13 -0
- package/lib/types/components/dynamic/Content.d.ts +12 -0
- package/lib/types/components/dynamic/Footer.d.ts +11 -0
- package/lib/types/components/dynamic/ForwardContent.d.ts +6 -0
- package/lib/types/components/dynamic/LogoText.d.ts +9 -0
- package/lib/types/components/dynamic/MainPage.d.ts +34 -0
- package/lib/types/components/help/Help.d.ts +12 -0
- package/lib/types/components/index.d.ts +5 -0
- package/lib/types/components/loginQrcode/Page.d.ts +7 -0
- package/lib/types/components/version/Version.d.ts +8 -0
- package/lib/types/index.d.ts +5 -0
- package/lib/types/models/bilibili/bilibili.api.d.ts +47 -0
- package/lib/types/models/bilibili/bilibili.buid.fp.d.ts +2 -0
- package/lib/types/models/bilibili/bilibili.get.web.data.d.ts +6 -0
- package/lib/types/models/bilibili/bilibili.models.d.ts +20 -0
- package/lib/types/models/bilibili/bilibili.query.d.ts +13 -0
- package/lib/types/models/bilibili/bilibili.task.d.ts +18 -0
- package/lib/types/models/bilibili/bilibili.wbi.d.ts +5 -0
- package/lib/types/models/help/help.d.ts +8 -0
- package/lib/types/models/version/version.d.ts +7 -0
- package/lib/types/models/weibo/weibo.api.d.ts +17 -0
- package/lib/types/models/weibo/weibo.get.web.data.d.ts +8 -0
- package/lib/types/models/weibo/weibo.query.d.ts +18 -0
- package/lib/types/models/weibo/weibo.task.d.ts +17 -0
- package/lib/types/utils/config.d.ts +21 -0
- package/lib/types/utils/image.d.ts +10 -0
- package/lib/types/utils/paths.d.ts +10 -0
- package/lib/types/utils/puppeteer.render.d.ts +23 -0
- package/lib/utils/config.js +108 -0
- package/lib/utils/image.js +26 -0
- package/lib/utils/paths.js +18 -0
- package/lib/utils/puppeteer.render.js +102 -0
- package/package.json +110 -0
- package/public/output.css +1 -0
- package/resources/css/dynamic/Account.css +68 -0
- package/resources/css/dynamic/Content.box.grid.4.css +4 -0
- package/resources/css/dynamic/Content.box.grid.9.css +4 -0
- package/resources/css/dynamic/Content.css +87 -0
- package/resources/css/dynamic/Footer.css +44 -0
- package/resources/css/dynamic/ForwardContent.css +11 -0
- package/resources/css/dynamic/LogoText.css +15 -0
- package/resources/css/dynamic/MainPage.css +93 -0
- package/resources/css/help/help.css +182 -0
- package/resources/css/loginQrcode/Page.css +55 -0
- package/resources/css/version/version.css +116 -0
- package/resources/fonts/iconfont.16acc2.ttf +0 -0
- package/resources/img/background/Girl.png +0 -0
- package/resources/img/icon/dynamic/bili-rich-text-module-goods-taobao.svg +1 -0
- package/resources/img/icon/dynamic/bili-rich-text-module-lottery.svg +1 -0
- package/resources/img/icon/dynamic/bilibili.svg +6 -0
- package/resources/img/icon/dynamic/weibo.svg +43 -0
- package/resources/img/icon/puplic/archaic_stone.png +0 -0
- package/resources/img/icon/puplic/condessence_crystal.png +0 -0
- package/resources/img/icon/puplic/delightful_encounter.png +0 -0
- package/resources/img/icon/puplic/diagram.png +0 -0
- package/resources/img/icon/puplic/essence_of_pure_sacred_dewdrop.png +0 -0
- package/resources/img/icon/puplic/everamber.png +0 -0
- package/resources/img/icon/puplic/flower_1.png +0 -0
- package/resources/img/icon/puplic/flower_2.png +0 -0
- package/resources/img/icon/puplic/kamera.png +0 -0
- package/resources/img/icon/puplic/lumidouce_bell.png +0 -0
- package/resources/img/icon/puplic/mora.png +0 -0
- package/resources/img/icon/puplic/pluie_lotus.png +0 -0
- package/resources/img/icon/puplic/restaurant_smoothie.png +0 -0
- package/resources/img/icon/puplic/romaritime_flower.png +0 -0
- package/resources/img/icon/puplic/shell.png +0 -0
- package/resources/img/icon/puplic/spring_of_pure_sacred_dewdrop.png +0 -0
- package/resources/img/icon/puplic/surging_sacred_chalice.png +0 -0
- package/resources/img/icon/puplic/tourbillon_device.png +0 -0
- package/resources/img/icon/puplic/unfading_silky_grace.png +0 -0
- package/resources/img/icon/puplic/wisdom.png +0 -0
- package/resources/img/icon/puplic/wondrous_lovely_flower.png +0 -0
- package/resources/img/icon/puplic//345/262/251/347/245/236/347/236/263/345/205/261/351/270/243/347/237/263.png +0 -0
- package/resources/img/icon/puplic//346/260/264/347/245/236/347/236/263/345/205/261/351/270/243/347/237/263.png +0 -0
- package/resources/img/icon/puplic//350/215/211/347/245/236/347/236/263/345/205/261/351/270/243/347/237/263.png +0 -0
- package/resources/img/icon/puplic//351/222/223/351/261/274.png +0 -0
- package/resources/img/icon/puplic//351/233/267/347/245/236/347/236/263/345/205/261/351/270/243/347/237/263.png +0 -0
- package/resources/img/icon/puplic//351/243/216/347/245/236/347/236/263/345/205/261/351/270/243/347/237/263.png +0 -0
- package/resources/img/icon/puplic//351/243/216/350/275/246.png +0 -0
- package/resources/img/readme/girl.png +0 -0
- package/resources/img/readme/min-Girl.png +0 -0
- package/resources/img/readme/mini-help.jpg +0 -0
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
import JSON from 'json5';
|
|
2
|
+
import lodash from 'lodash';
|
|
3
|
+
import { Messages, setBotTask, Bot, Redis } from 'yunzai';
|
|
4
|
+
import { BiliQuery } from '../models/bilibili/bilibili.query.js';
|
|
5
|
+
import { BiliTask } from '../models/bilibili/bilibili.task.js';
|
|
6
|
+
import Config from '../utils/config.js';
|
|
7
|
+
import { BiliGetWebData } from '../models/bilibili/bilibili.get.web.data.js';
|
|
8
|
+
import { applyLoginQRCode, pollLoginQRCode, saveLoginCookie, postGateway, exitBiliLogin, checkBiliLogin, readSavedCookieItems, saveLocalBiliCk, readSyncCookie, getNewTempCk, readTempCk } from '../models/bilibili/bilibili.models.js';
|
|
9
|
+
|
|
10
|
+
const message = new Messages('message');
|
|
11
|
+
let biliConfigData = Config.getConfigData("config", "bilibili", "config");
|
|
12
|
+
let biliPushData = Config.getConfigData("config", "bilibili", "push");
|
|
13
|
+
setBotTask(async (Bot) => {
|
|
14
|
+
try {
|
|
15
|
+
newPushTask();
|
|
16
|
+
if (biliConfigData.pushTaskLog) {
|
|
17
|
+
Bot.logger.mark("yuki插件---B站动态推送定时任务");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
console.error('B站动态推送定时任务', err);
|
|
22
|
+
}
|
|
23
|
+
}, biliConfigData.pushStatus ? biliConfigData.pushTime : "");
|
|
24
|
+
async function newPushTask(e) {
|
|
25
|
+
await new BiliTask(e).runTask();
|
|
26
|
+
}
|
|
27
|
+
message.use(async (e) => {
|
|
28
|
+
await newPushTask(e);
|
|
29
|
+
}, [/^(#|\/)(yuki|优纪)?执行(b站|B站|bili|bilibili|哔哩|哔哩哔哩)任务$/]);
|
|
30
|
+
message.use(async (e) => {
|
|
31
|
+
if (!e.isMaster) {
|
|
32
|
+
e.reply("未取得bot主人身份,无权限添加B站动态订阅");
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const uid = e.msg.replace(/^(#|\/)(yuki|优纪)?(订阅|添加|add|ADD)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)推送\s*(视频\s*|图文\s*|文章\s*|转发\s*|直播\s*)*/g, "").trim();
|
|
36
|
+
if (!uid) {
|
|
37
|
+
e.reply(`请在指令末尾指定订阅的B站up主的UID!`);
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
let subData = biliPushData || { group: {}, private: {} };
|
|
41
|
+
let chatType = e.isGroup ? "group" : "private";
|
|
42
|
+
let chatId = e.isGroup ? e.group_id : e.user_id;
|
|
43
|
+
if (!subData[chatType][chatId]) {
|
|
44
|
+
subData[chatType][chatId] = [];
|
|
45
|
+
}
|
|
46
|
+
const upData = subData[chatType][chatId].find((item) => item.uid === uid);
|
|
47
|
+
if (upData) {
|
|
48
|
+
upData.type = BiliQuery.typeHandle(upData, e.msg, "add");
|
|
49
|
+
biliPushData = subData;
|
|
50
|
+
Config.saveConfig("config", "bilibili", "push", subData);
|
|
51
|
+
e.reply(`修改b站推送动态类型成功~\n${upData.name}:${uid}`);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const res = await new BiliGetWebData(e).getBiliDynamicListDataByUid(uid);
|
|
55
|
+
if (res.statusText !== "OK") {
|
|
56
|
+
e.reply("出了点网络问题,等会再试试吧~");
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
const resData = res.data || {};
|
|
60
|
+
if (resData.code !== 0) {
|
|
61
|
+
e.reply(`订阅校验失败~\nup主uid:${uid} 可能是无效的,或遭遇了风控,请稍后再试~`);
|
|
62
|
+
logger.mark(`yuki-plugin addDynamicSub Failed:${JSON.stringify(resData)}`);
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
const { items } = resData.data || {};
|
|
66
|
+
let name = items.length > 0 ? (items[0].modules.module_author?.name || uid) : uid;
|
|
67
|
+
subData[chatType][chatId].push({
|
|
68
|
+
bot_id: e.self_id,
|
|
69
|
+
uid,
|
|
70
|
+
name: name,
|
|
71
|
+
type: BiliQuery.typeHandle({ uid, name }, e.msg, "add"),
|
|
72
|
+
});
|
|
73
|
+
biliPushData = subData;
|
|
74
|
+
Config.saveConfig("config", "bilibili", "push", subData);
|
|
75
|
+
e.reply(`添加b站推送成功~\n${name}:${uid}`);
|
|
76
|
+
}
|
|
77
|
+
}, [/^(#|\/)(yuki|优纪)?(订阅|添加|add|ADD)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)推送\s*(视频\s*|图文\s*|文章\s*|转发\s*|直播\s*)*.*$/]);
|
|
78
|
+
message.use(async (e) => {
|
|
79
|
+
if (!e.isMaster) {
|
|
80
|
+
e.reply("未取得bot主人身份,无权限删除B站动态订阅");
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
const uid = e.msg.replace(/^(#|\/)(yuki|优纪)?(取消|删除|del|DEL)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)推送\s*(视频\s*|图文\s*|文章\s*|转发\s*|直播\s*)*/g, "").trim();
|
|
84
|
+
if (!uid) {
|
|
85
|
+
e.reply(`请在指令末尾指定订阅的B站up主的UID!`);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
let subData = Config.getConfigData("config", "bilibili", "push") || { group: {}, private: {} };
|
|
89
|
+
let chatType = e.isGroup ? "group" : "private";
|
|
90
|
+
let chatId = e.isGroup ? e.group_id : e.user_id;
|
|
91
|
+
if (!subData[chatType][chatId]) {
|
|
92
|
+
subData[chatType][chatId] = [];
|
|
93
|
+
}
|
|
94
|
+
const upData = subData[chatType][chatId].find((item) => item.uid == uid);
|
|
95
|
+
if (!upData) {
|
|
96
|
+
e.reply(`订阅列表中没有找到该UID~\n${uid}可能是无效的`);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const newType = BiliQuery.typeHandle(upData, e.msg, "del");
|
|
100
|
+
let isDel = false;
|
|
101
|
+
if (newType.length) {
|
|
102
|
+
subData[chatType][chatId] = subData[chatType][chatId].map((item) => {
|
|
103
|
+
if (item.uid == uid) {
|
|
104
|
+
item.type = newType;
|
|
105
|
+
}
|
|
106
|
+
return item;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
isDel = true;
|
|
111
|
+
subData[chatType][chatId] = subData[chatType][chatId].filter((item) => item.uid !== uid);
|
|
112
|
+
}
|
|
113
|
+
Config.saveConfig("config", "bilibili", "push", subData);
|
|
114
|
+
e.reply(`${isDel ? "删除" : "修改"}b站推送成功~\n${uid}`);
|
|
115
|
+
}
|
|
116
|
+
}, [/^(#|\/)(yuki|优纪)?(取消|删除|del|DEL)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)推送\s*(视频\s*|图文\s*|文章\s*|转发\s*|直播\s*)*.*$/]);
|
|
117
|
+
message.use(async (e) => {
|
|
118
|
+
if (e.isMaster) {
|
|
119
|
+
try {
|
|
120
|
+
const token = await applyLoginQRCode(e);
|
|
121
|
+
let biliLoginCk = await pollLoginQRCode(e, token);
|
|
122
|
+
if (lodash.trim(biliLoginCk).length != 0) {
|
|
123
|
+
await saveLoginCookie(e, biliLoginCk);
|
|
124
|
+
e.reply(`get bilibili LoginCk:成功!`);
|
|
125
|
+
const result = await postGateway(biliLoginCk);
|
|
126
|
+
const { code, data } = await result.data;
|
|
127
|
+
switch (code) {
|
|
128
|
+
case 0:
|
|
129
|
+
(logger ?? Bot.logger)?.mark(`优纪插件:获取biliLoginCK,Gateway校验成功:${JSON.stringify(data)}`);
|
|
130
|
+
break;
|
|
131
|
+
default:
|
|
132
|
+
(logger ?? Bot.logger)?.mark(`优纪插件:获取biliLoginCK,Gateway校验失败:${JSON.stringify(data)}`);
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
e.reply(`get bilibili LoginCk:失败X﹏X`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
catch (Error) {
|
|
141
|
+
(logger ?? Bot.logger)?.info(`yuki-plugin Login bilibili Failed:${Error}`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
e.reply("未取得bot主人身份,无权限配置B站登录ck");
|
|
146
|
+
}
|
|
147
|
+
}, [/^(#|\/)(yuki|优纪)?(扫码|添加|ADD|add)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)登录$/]);
|
|
148
|
+
message.use(async (e) => {
|
|
149
|
+
if (e.isMaster) {
|
|
150
|
+
await exitBiliLogin(e);
|
|
151
|
+
await Redis.set("Yz:yuki:bili:loginCookie", "", { EX: 3600 * 24 * 180 });
|
|
152
|
+
e.reply(`登陆的B站ck并已删除~`);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
e.reply("未取得bot主人身份,无权限删除B站登录ck");
|
|
156
|
+
}
|
|
157
|
+
}, [/^(#|\/)(yuki|优纪)?(取消|删除|del|DEL)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)登录$/]);
|
|
158
|
+
message.use(async (e) => {
|
|
159
|
+
if (e.isMaster) {
|
|
160
|
+
await checkBiliLogin(e);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
e.reply("未取得bot主人身份,无权限查看B站登录状态");
|
|
164
|
+
}
|
|
165
|
+
}, [/^(#|\/)(yuki|优纪)?我的(b站|B站|bili|bilibili|哔哩|哔哩哔哩)登录$/]);
|
|
166
|
+
message.use(async (e) => {
|
|
167
|
+
if (e.isMaster) {
|
|
168
|
+
if (e.isPrivate) {
|
|
169
|
+
await e.reply('请注意账号安全,请手动撤回发送的cookie,并私聊进行添加绑定!');
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
let localBiliCookie = e.msg.replace(/^(#|\/)(yuki|优纪)?(绑定|添加|ADD|add)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)(ck|CK|cookie|COOKIE)(:|:)?/g, "").trim();
|
|
173
|
+
let param = {};
|
|
174
|
+
localBiliCookie.split(';').forEach((v) => {
|
|
175
|
+
let tmp = lodash.trim(v).replace('=', '$').split('$');
|
|
176
|
+
param[tmp[0]] = tmp[1];
|
|
177
|
+
});
|
|
178
|
+
if (!param.buvid3 || !param._uuid || !param.buvid4 || !param.DedeUserID) {
|
|
179
|
+
await e.reply('发送的cookie字段缺失\n请添加完整cookie\n获取方法查看仓库主页。');
|
|
180
|
+
const missingCookies = [];
|
|
181
|
+
if (!param.buvid3 || param.buvid3.length === 0) {
|
|
182
|
+
missingCookies.push('buvid3');
|
|
183
|
+
}
|
|
184
|
+
if (!param.buvid4 || param.buvid4.length === 0) {
|
|
185
|
+
missingCookies.push('buvid4');
|
|
186
|
+
}
|
|
187
|
+
if (!param._uuid || param._uuid.length === 0) {
|
|
188
|
+
missingCookies.push('_uuid');
|
|
189
|
+
}
|
|
190
|
+
if (!param.DedeUserID || param.DedeUserID.length === 0) {
|
|
191
|
+
missingCookies.push('DedeUserID');
|
|
192
|
+
}
|
|
193
|
+
if (missingCookies.length > 0) {
|
|
194
|
+
await e.reply(`当前缺失字段:\n${missingCookies.join('\n')}`);
|
|
195
|
+
}
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
localBiliCookie = await readSavedCookieItems(localBiliCookie, ['buvid3', 'buvid4', '_uuid', 'SESSDATA', 'DedeUserID', 'DedeUserID__ckMd5', 'bili_jct', 'b_nut', 'b_lsid'], false);
|
|
199
|
+
await saveLocalBiliCk(localBiliCookie);
|
|
200
|
+
logger.mark(`${e.logFnc} 保存B站cookie成功 [UID:${param.DedeUserID}]`);
|
|
201
|
+
let uidMsg = [`好耶~绑定B站cookie成功:\n${param.DedeUserID}`];
|
|
202
|
+
await e.reply(uidMsg);
|
|
203
|
+
const result = await postGateway(localBiliCookie);
|
|
204
|
+
const { code, data } = await result.data;
|
|
205
|
+
switch (code) {
|
|
206
|
+
case 0:
|
|
207
|
+
(logger ?? Bot.logger)?.mark(`优纪插件:绑定localCK,Gateway校验成功:${JSON.stringify(data)}`);
|
|
208
|
+
break;
|
|
209
|
+
default:
|
|
210
|
+
(logger ?? Bot.logger)?.mark(`优纪插件:绑定localCK,Gateway校验失败:${JSON.stringify(data)}`);
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
e.reply("未取得bot主人身份,无权限配置B站登录ck");
|
|
217
|
+
}
|
|
218
|
+
}, [/^^(#|\/)(yuki|优纪)?(绑定|添加|ADD|add)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)本地(ck|CK|cookie|COOKIE)(:|:)?.*$/]);
|
|
219
|
+
message.use(async (e) => {
|
|
220
|
+
if (e.isMaster) {
|
|
221
|
+
await saveLocalBiliCk("");
|
|
222
|
+
await e.reply(`手动绑定的B站ck已删除~`);
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
e.reply("未取得bot主人身份,无权限删除B站登录ck");
|
|
226
|
+
}
|
|
227
|
+
}, [/^(#|\/)(yuki|优纪)?(取消|删除|del|DEL)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)本地(ck|CK|cookie|COOKIE)$/]);
|
|
228
|
+
message.use(async (e) => {
|
|
229
|
+
if (e.isGroup) {
|
|
230
|
+
await e.reply('注意账号安全,请私聊查看叭');
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
if (e.isMaster) {
|
|
234
|
+
let { cookie, mark } = await readSyncCookie();
|
|
235
|
+
if (mark === "localCk") {
|
|
236
|
+
e.reply(`当前使用本地获取的B站cookie:`);
|
|
237
|
+
e.reply(`${cookie}`);
|
|
238
|
+
}
|
|
239
|
+
else if (mark === "loginCk") {
|
|
240
|
+
e.reply(`当前使用扫码登录的B站cookie:`);
|
|
241
|
+
e.reply(`${cookie}`);
|
|
242
|
+
}
|
|
243
|
+
else if (mark === "tempCk") {
|
|
244
|
+
e.reply(`当前使用自动获取的临时B站cookie:`);
|
|
245
|
+
e.reply(`${cookie}`);
|
|
246
|
+
}
|
|
247
|
+
else if (mark == 'ckIsEmpty') {
|
|
248
|
+
e.reply(`当前无可使用的B站cookie。`);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
e.reply("未取得bot主人身份,无权限查看当前使用的B站cookie");
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}, [/^(#|\/)(yuki|优纪)?(取消|删除|del|DEL)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)本地(ck|CK|cookie|COOKIE)$/]);
|
|
256
|
+
message.use(async (e) => {
|
|
257
|
+
try {
|
|
258
|
+
await getNewTempCk();
|
|
259
|
+
let newTempCk = await readTempCk();
|
|
260
|
+
if ((newTempCk !== null) && (newTempCk !== undefined) && (newTempCk.length !== 0) && (newTempCk !== '')) {
|
|
261
|
+
e.reply(`~yuki-plugin:\n临时b站ck刷新成功~❤~\n接下来如果获取动态失败,请重启bot(手动或发送指令 #重启)刷新状态~\n如果重启续仍不可用,请考虑 #优纪添加b站登录 吧~`);
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
e.reply(`~yuki-plugin:\n临时b站ck刷新失败X﹏X\n请重启bot(手动或发送指令 #重启)后重试`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
e.reply(`~yuki-plugin:\n临时b站ck刷新失败X﹏X\n请重启bot(手动或发送指令 #重启)后重试`);
|
|
269
|
+
(logger ?? Bot.logger)?.mark(`优纪插件:B站临时ck刷新error:${error}`);
|
|
270
|
+
}
|
|
271
|
+
}, [/^(#|\/)(yuki|优纪)?刷新(b站|B站|bili|bilibili|哔哩|哔哩哔哩)临时(ck|CK|cookie|COOKIE)$/]);
|
|
272
|
+
message.use(async (e) => {
|
|
273
|
+
if (!e.isMaster) {
|
|
274
|
+
e.reply("未取得bot主人身份,无权限查看Bot的全部B站订阅列表");
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
let subData = Config.getConfigData("config", "bilibili", "push") || { group: {}, private: {} };
|
|
278
|
+
const messages = [];
|
|
279
|
+
const typeMap = {
|
|
280
|
+
DYNAMIC_TYPE_AV: "视频",
|
|
281
|
+
DYNAMIC_TYPE_WORD: "图文",
|
|
282
|
+
DYNAMIC_TYPE_DRAW: "图文",
|
|
283
|
+
DYNAMIC_TYPE_ARTICLE: "文章",
|
|
284
|
+
DYNAMIC_TYPE_FORWARD: "转发",
|
|
285
|
+
DYNAMIC_TYPE_LIVE_RCMD: "直播",
|
|
286
|
+
};
|
|
287
|
+
if (subData.group && Object.keys(subData.group).length > 0) {
|
|
288
|
+
messages.push("------群组B站订阅------");
|
|
289
|
+
Object.keys(subData.group).forEach((groupId) => {
|
|
290
|
+
messages.push(`群组ID:${groupId}:`);
|
|
291
|
+
subData.group[groupId].forEach((item) => {
|
|
292
|
+
const types = new Set();
|
|
293
|
+
if (item.type && item.type.length) {
|
|
294
|
+
item.type.forEach((typeItem) => {
|
|
295
|
+
if (typeMap[typeItem]) {
|
|
296
|
+
types.add(typeMap[typeItem]);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
messages.push(`${item.name}:${item.uid} ${types.size ? `[${Array.from(types).join("、")}]` : " [全部动态]"}`);
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
if (subData.private && Object.keys(subData.private).length > 0) {
|
|
305
|
+
messages.push("------私聊B站订阅------");
|
|
306
|
+
Object.keys(subData.private).forEach((userId) => {
|
|
307
|
+
messages.push(`用户ID:${userId}:`);
|
|
308
|
+
subData.private[userId].forEach((item) => {
|
|
309
|
+
const types = new Set();
|
|
310
|
+
if (item.type && item.type.length) {
|
|
311
|
+
item.type.forEach((typeItem) => {
|
|
312
|
+
if (typeMap[typeItem]) {
|
|
313
|
+
types.add(typeMap[typeItem]);
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
messages.push(`${item.name}:${item.uid} ${types.size ? `[${Array.from(types).join("、")}]` : " [全部动态]"}`);
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
e.reply(`推送列表如下:\n${messages.join("\n")}`);
|
|
322
|
+
}
|
|
323
|
+
}, [/^(#|\/)(yuki|优纪)?(b站|B站|bili|bilibili|哔哩|哔哩哔哩)全部(推送|动态|订阅)列表$/]);
|
|
324
|
+
message.use(async (e) => {
|
|
325
|
+
let subData = Config.getConfigData("config", "bilibili", "push") || { group: {}, private: {} };
|
|
326
|
+
const messages = [];
|
|
327
|
+
const typeMap = {
|
|
328
|
+
DYNAMIC_TYPE_AV: "视频",
|
|
329
|
+
DYNAMIC_TYPE_WORD: "图文",
|
|
330
|
+
DYNAMIC_TYPE_DRAW: "图文",
|
|
331
|
+
DYNAMIC_TYPE_ARTICLE: "文章",
|
|
332
|
+
DYNAMIC_TYPE_FORWARD: "转发",
|
|
333
|
+
DYNAMIC_TYPE_LIVE_RCMD: "直播",
|
|
334
|
+
};
|
|
335
|
+
let chatType = e.isGroup ? "group" : "private";
|
|
336
|
+
let chatId = e.isGroup ? e.group_id : e.user_id;
|
|
337
|
+
if (!subData[chatType][chatId]) {
|
|
338
|
+
subData[chatType][chatId] = [];
|
|
339
|
+
}
|
|
340
|
+
subData[chatType][chatId].forEach((item) => {
|
|
341
|
+
const types = new Set();
|
|
342
|
+
if (item.type && item.type.length) {
|
|
343
|
+
item.type.forEach((typeItem) => {
|
|
344
|
+
if (typeMap[typeItem]) {
|
|
345
|
+
types.add(typeMap[typeItem]);
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
messages.push(`${item.name}:${item.uid} ${types.size ? `[${Array.from(types).join("、")}]` : " [全部动态]"}`);
|
|
350
|
+
});
|
|
351
|
+
e.reply(`推送列表如下:\n${messages.join("\n")}`);
|
|
352
|
+
}, [/^(#|\/)(yuki|优纪)?(b站|B站|bili|bilibili|哔哩|哔哩哔哩)(推送|动态|订阅)列表$/]);
|
|
353
|
+
message.use(async (e) => {
|
|
354
|
+
let uid = e.msg.replace(/^(#|\/)(yuki|优纪)?(b站|B站|bili|bilibili|哔哩|哔哩哔哩)(up|UP)主/g, "").trim();
|
|
355
|
+
const res = await new BiliGetWebData(e).getBilibiUserInfoByUid(uid);
|
|
356
|
+
if (res.statusText !== 'OK') {
|
|
357
|
+
e.reply("诶嘿,出了点网络问题,等会再试试吧~");
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
const { code, data } = res.data || {};
|
|
361
|
+
if (code === -799) {
|
|
362
|
+
e.reply("遭遇风控:请求过于频繁,请稍后再试。");
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
else if (code === -404) {
|
|
366
|
+
e.reply("输入的uid无效。");
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
const message = [
|
|
370
|
+
`昵称:${data?.name}`,
|
|
371
|
+
`\n性别:${data?.sex}`,
|
|
372
|
+
`\n等级:${data?.level}`,
|
|
373
|
+
];
|
|
374
|
+
if (data.live_room) {
|
|
375
|
+
message.push(`\n***********\n---直播信息---`, `\n直播标题:${data?.live_room?.title}`, `\n直播房间:${data?.live_room?.roomid}`, `\n直播状态:${data?.live_room?.liveStatus ? "直播中" : "未开播"}`, `\n直播链接:${data?.live_room?.url}`, `\n观看人数:${data?.live_room?.watched_show?.num}人`);
|
|
376
|
+
}
|
|
377
|
+
e.reply(message);
|
|
378
|
+
}, [/^(#|\/)(yuki|优纪)?(b站|B站|bili|bilibili|哔哩|哔哩哔哩)(up|UP)主.*$/]);
|
|
379
|
+
message.use(async (e) => {
|
|
380
|
+
let keyword = e.msg.replace(/^(#|\/)(yuki|优纪)?搜索(b站|B站|bili|bilibili|哔哩|哔哩哔哩)(up|UP)主/g, "").trim();
|
|
381
|
+
const res = await new BiliGetWebData(e).searchBiliUserInfoByKeyword(keyword);
|
|
382
|
+
if (res.statusText !== 'OK') {
|
|
383
|
+
e.reply("诶嘿,出了点网络问题,等会再试试吧~");
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
const { code, data } = await res.data || {};
|
|
387
|
+
if (code !== 0 || !data.result) {
|
|
388
|
+
e.reply("哦豁~没有搜索到该用户捏,请换个关键词试试吧~");
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
const messages = [];
|
|
392
|
+
data.result.map((item, index) => {
|
|
393
|
+
if (index < 5) {
|
|
394
|
+
messages.push(`${item.uname}\nUID:${item.mid}\n粉丝数:${item.fans}${index < 4 ? "\n" : ""}`);
|
|
395
|
+
}
|
|
396
|
+
return item;
|
|
397
|
+
});
|
|
398
|
+
e.reply(messages.join("\n"));
|
|
399
|
+
}, [/^(#|\/)(yuki|优纪)?搜索(b站|B站|bili|bilibili|哔哩|哔哩哔哩)(up|UP)主.*$/]);
|
|
400
|
+
const YukiBli = message.ok;
|
|
401
|
+
|
|
402
|
+
export { YukiBli };
|
package/lib/apps/help.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Messages, Segment } from 'yunzai';
|
|
2
|
+
import Image from '../utils/image.js';
|
|
3
|
+
import Help from '../models/help/help.js';
|
|
4
|
+
|
|
5
|
+
const message = new Messages('message');
|
|
6
|
+
message.use(async (e) => {
|
|
7
|
+
const helpData = await Help.get();
|
|
8
|
+
const renderData = {
|
|
9
|
+
data: helpData.map((item) => ({
|
|
10
|
+
group: item.group,
|
|
11
|
+
list: item.list.map((listItem) => ({
|
|
12
|
+
icon: listItem.icon,
|
|
13
|
+
title: listItem.title,
|
|
14
|
+
desc: listItem.desc
|
|
15
|
+
}))
|
|
16
|
+
}))
|
|
17
|
+
};
|
|
18
|
+
const ScreenshotOptionsData = {
|
|
19
|
+
isSplit: false,
|
|
20
|
+
modelName: 'yukiHelp',
|
|
21
|
+
};
|
|
22
|
+
const helpImg = await Image.renderPage("help", "Help", renderData, ScreenshotOptionsData);
|
|
23
|
+
let imgRes;
|
|
24
|
+
if (helpImg !== false) {
|
|
25
|
+
const { img } = helpImg;
|
|
26
|
+
imgRes = { img };
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
let msg = [];
|
|
32
|
+
msg.push(Segment.image(imgRes.img[0]));
|
|
33
|
+
await e.reply(msg);
|
|
34
|
+
}, [/^(#|\/)(yuki|优纪)帮助$/]);
|
|
35
|
+
const YukiHelp = message.ok;
|
|
36
|
+
|
|
37
|
+
export { YukiHelp };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Messages, Segment } from 'yunzai';
|
|
2
|
+
import Image from '../utils/image.js';
|
|
3
|
+
import VersionData from '../models/version/version.js';
|
|
4
|
+
|
|
5
|
+
const message = new Messages('message');
|
|
6
|
+
message.use(async (e) => {
|
|
7
|
+
const version = new VersionData;
|
|
8
|
+
const versionData = await version.getChangelogContent();
|
|
9
|
+
const renderData = {
|
|
10
|
+
data: versionData.map((item) => ({
|
|
11
|
+
version: item.version,
|
|
12
|
+
data: item.data
|
|
13
|
+
}))
|
|
14
|
+
};
|
|
15
|
+
const ScreenshotOptionsData = {
|
|
16
|
+
isSplit: false,
|
|
17
|
+
modelName: 'yukiVersion',
|
|
18
|
+
};
|
|
19
|
+
const helpImg = await Image.renderPage("version", "Version", renderData, ScreenshotOptionsData);
|
|
20
|
+
let imgRes;
|
|
21
|
+
if (helpImg !== false) {
|
|
22
|
+
const { img } = helpImg;
|
|
23
|
+
imgRes = { img };
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
let msg = [];
|
|
29
|
+
msg.push(Segment.image(imgRes.img[0]));
|
|
30
|
+
await e.reply(msg);
|
|
31
|
+
}, [/^(#|\/)(yuki|优纪)版本$/]);
|
|
32
|
+
const YukiVersion = message.ok;
|
|
33
|
+
|
|
34
|
+
export { YukiVersion };
|