feat: 调整
This commit is contained in:
parent
e1f53b1cc6
commit
61b099ce81
|
@ -10,11 +10,20 @@ import { CONFIG_DEFAULT_PATH, CONFIG_INIT_PATH } from './system.js'
|
||||||
* ********
|
* ********
|
||||||
*/
|
*/
|
||||||
class Cfg {
|
class Cfg {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
config = {}
|
config = {}
|
||||||
|
|
||||||
/** 监听文件 */
|
/**
|
||||||
|
* 监听文件
|
||||||
|
*/
|
||||||
watcher = { config: {}, defSet: {} }
|
watcher = { config: {}, defSet: {} }
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
constructor() {
|
constructor() {
|
||||||
this.initCfg()
|
this.initCfg()
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,8 +52,10 @@ function createLog() {
|
||||||
const commandLogger = log4js.getLogger('command')
|
const commandLogger = log4js.getLogger('command')
|
||||||
const errorLogger = log4js.getLogger('error')
|
const errorLogger = log4js.getLogger('error')
|
||||||
|
|
||||||
/** 调整error日志等级 */
|
|
||||||
|
/**
|
||||||
|
* 调整error日志等级
|
||||||
|
*/
|
||||||
const logger = {
|
const logger = {
|
||||||
trace() {
|
trace() {
|
||||||
defaultLogger.trace.call(defaultLogger, ...arguments)
|
defaultLogger.trace.call(defaultLogger, ...arguments)
|
||||||
|
@ -100,7 +102,9 @@ export default function setLog() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 全局变量 logger */
|
/**
|
||||||
|
* 全局变量 logger
|
||||||
|
*/
|
||||||
global.logger = createLog() as any
|
global.logger = createLog() as any
|
||||||
|
|
||||||
logger.chalk = chalk
|
logger.chalk = chalk
|
||||||
|
|
|
@ -4,9 +4,24 @@ import PluginsLoader from './plugins.loader.js'
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export default class EventListener {
|
export default class EventListener {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
prefix = ''
|
prefix = ''
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
event = null
|
event = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
once = false
|
once = false
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
plugins = PluginsLoader
|
plugins = PluginsLoader
|
||||||
/**
|
/**
|
||||||
* 事件监听
|
* 事件监听
|
||||||
|
|
|
@ -13,8 +13,17 @@ import Handler from './plugins/handler.js'
|
||||||
* 加载插件
|
* 加载插件
|
||||||
*/
|
*/
|
||||||
class PluginsLoader {
|
class PluginsLoader {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
priority = []
|
priority = []
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
handler = {}
|
handler = {}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
task = []
|
task = []
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -25,7 +34,9 @@ class PluginsLoader {
|
||||||
*/
|
*/
|
||||||
groupGlobalCD = {}
|
groupGlobalCD = {}
|
||||||
|
|
||||||
//
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
singleCD = {}
|
singleCD = {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,9 +44,21 @@ class PluginsLoader {
|
||||||
*/
|
*/
|
||||||
watcher = {}
|
watcher = {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
eventMap = {
|
eventMap = {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
message: ['post_type', 'message_type', 'sub_type'],
|
message: ['post_type', 'message_type', 'sub_type'],
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
notice: ['post_type', 'notice_type', 'sub_type'],
|
notice: ['post_type', 'notice_type', 'sub_type'],
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
request: ['post_type', 'request_type', 'sub_type']
|
request: ['post_type', 'request_type', 'sub_type']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,6 +112,9 @@ class PluginsLoader {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
pluginCount = null
|
pluginCount = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -436,8 +462,14 @@ class PluginsLoader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
e.logText = ''
|
e.logText = ''
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
if (e.message_type === 'private' || e.notice_type === 'friend') {
|
if (e.message_type === 'private' || e.notice_type === 'friend') {
|
||||||
e.isPrivate = true
|
e.isPrivate = true
|
||||||
|
|
||||||
|
@ -453,6 +485,9 @@ class PluginsLoader {
|
||||||
e.logText = `[私聊][${e.sender.nickname}(${e.user_id})]`
|
e.logText = `[私聊][${e.sender.nickname}(${e.user_id})]`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
if (e.message_type === 'group' || e.notice_type === 'group') {
|
if (e.message_type === 'group' || e.notice_type === 'group') {
|
||||||
e.isGroup = true
|
e.isGroup = true
|
||||||
if (e.sender) {
|
if (e.sender) {
|
||||||
|
@ -480,6 +515,9 @@ class PluginsLoader {
|
||||||
e.isGuild = true
|
e.isGuild = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
if (
|
if (
|
||||||
e.user_id &&
|
e.user_id &&
|
||||||
cfg.masterQQ.includes(String(e.user_id) || String(e.user_id))
|
cfg.masterQQ.includes(String(e.user_id) || String(e.user_id))
|
||||||
|
@ -487,7 +525,9 @@ class PluginsLoader {
|
||||||
e.isMaster = true
|
e.isMaster = true
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 只关注主动at msg处理 */
|
/**
|
||||||
|
* 只关注主动at msg处理
|
||||||
|
*/
|
||||||
if (e.msg && e.isGroup) {
|
if (e.msg && e.isGroup) {
|
||||||
let groupCfg = cfg.getGroup(e.group_id)
|
let groupCfg = cfg.getGroup(e.group_id)
|
||||||
let alias = groupCfg.botAlias
|
let alias = groupCfg.botAlias
|
||||||
|
@ -509,7 +549,13 @@ class PluginsLoader {
|
||||||
* @param e
|
* @param e
|
||||||
*/
|
*/
|
||||||
reply(e) {
|
reply(e) {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
if (e.reply) {
|
if (e.reply) {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
e.replyNew = e.reply
|
e.replyNew = e.reply
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -581,7 +627,13 @@ class PluginsLoader {
|
||||||
this.count(e, msg)
|
this.count(e, msg)
|
||||||
return msgRes
|
return msgRes
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
} else {
|
} else {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
e.reply = async (msg = '', _ = false, __ = {}) => {
|
e.reply = async (msg = '', _ = false, __ = {}) => {
|
||||||
if (!msg) return false
|
if (!msg) return false
|
||||||
this.count(e, msg)
|
this.count(e, msg)
|
||||||
|
@ -609,16 +661,37 @@ class PluginsLoader {
|
||||||
* @param msg
|
* @param msg
|
||||||
*/
|
*/
|
||||||
count(e, msg) {
|
count(e, msg) {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
let screenshot = false
|
let screenshot = false
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
if (msg && msg?.file && Buffer.isBuffer(msg?.file)) {
|
if (msg && msg?.file && Buffer.isBuffer(msg?.file)) {
|
||||||
screenshot = true
|
screenshot = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
this.saveCount('sendMsg')
|
this.saveCount('sendMsg')
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
if (screenshot) this.saveCount('screenshot')
|
if (screenshot) this.saveCount('screenshot')
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
if (e.group_id) {
|
if (e.group_id) {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
this.saveCount('sendMsg', e.group_id)
|
this.saveCount('sendMsg', e.group_id)
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
if (screenshot) this.saveCount('screenshot', e.group_id)
|
if (screenshot) this.saveCount('screenshot', e.group_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -629,20 +702,53 @@ class PluginsLoader {
|
||||||
* @param groupId
|
* @param groupId
|
||||||
*/
|
*/
|
||||||
saveCount(type, groupId = '') {
|
saveCount(type, groupId = '') {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
let key = 'Yz:count:'
|
let key = 'Yz:count:'
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
if (groupId) {
|
if (groupId) {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
key += `group:${groupId}:`
|
key += `group:${groupId}:`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
let dayKey = `${key}${type}:day:${moment().format('MMDD')}`
|
let dayKey = `${key}${type}:day:${moment().format('MMDD')}`
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
let monthKey = `${key}${type}:month:${Number(moment().month()) + 1}`
|
let monthKey = `${key}${type}:month:${Number(moment().month()) + 1}`
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
let totalKey = `${key}${type}:total`
|
let totalKey = `${key}${type}:total`
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
redis.incr(dayKey)
|
redis.incr(dayKey)
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
redis.incr(monthKey)
|
redis.incr(monthKey)
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
if (!groupId) redis.incr(totalKey)
|
if (!groupId) redis.incr(totalKey)
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
redis.expire(dayKey, 3600 * 24 * 30)
|
redis.expire(dayKey, 3600 * 24 * 30)
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
redis.expire(monthKey, 3600 * 24 * 30)
|
redis.expire(monthKey, 3600 * 24 * 30)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -650,8 +756,17 @@ class PluginsLoader {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
delCount() {
|
delCount() {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
let key = 'Yz:count:'
|
let key = 'Yz:count:'
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
redis.set(`${key}sendMsg:total`, '0')
|
redis.set(`${key}sendMsg:total`, '0')
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
redis.set(`${key}screenshot:total`, '0')
|
redis.set(`${key}screenshot:total`, '0')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -660,18 +775,31 @@ class PluginsLoader {
|
||||||
* @param task
|
* @param task
|
||||||
*/
|
*/
|
||||||
collectTask(task) {
|
collectTask(task) {
|
||||||
for (const i of Array.isArray(task) ? task : [task])
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
for (const i of Array.isArray(task) ? task : [task]) {
|
||||||
if (i?.cron && i?.name) {
|
if (i?.cron && i?.name) {
|
||||||
this.task.push(i)
|
this.task.push(i)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建定时任务
|
* 创建定时任务
|
||||||
*/
|
*/
|
||||||
createTask() {
|
createTask() {
|
||||||
for (const i of this.task)
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
for (const i of this.task) {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
i.job = schedule.scheduleJob(i?.cron, async () => {
|
i.job = schedule.scheduleJob(i?.cron, async () => {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
try {
|
try {
|
||||||
if (i.log == true) logger.mark(`开始定时任务:${i.name}`)
|
if (i.log == true) logger.mark(`开始定时任务:${i.name}`)
|
||||||
await i.fnc()
|
await i.fnc()
|
||||||
|
@ -681,6 +809,7 @@ class PluginsLoader {
|
||||||
logger.error(error)
|
logger.error(error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -691,24 +820,48 @@ class PluginsLoader {
|
||||||
checkLimit(e) {
|
checkLimit(e) {
|
||||||
/** 禁言中 */
|
/** 禁言中 */
|
||||||
if (e.isGroup && e?.group?.mute_left > 0) return false
|
if (e.isGroup && e?.group?.mute_left > 0) return false
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
if (!e.message || e.isPrivate) return true
|
if (!e.message || e.isPrivate) return true
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
let config = cfg.getGroup(e.group_id)
|
let config = cfg.getGroup(e.group_id)
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
if (config.groupGlobalCD && this.groupGlobalCD[e.group_id]) {
|
if (config.groupGlobalCD && this.groupGlobalCD[e.group_id]) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
if (config.singleCD && this.singleCD[`${e.group_id}.${e.user_id}`]) {
|
if (config.singleCD && this.singleCD[`${e.group_id}.${e.user_id}`]) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
let { msgThrottle } = this
|
let { msgThrottle } = this
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
let msgId = e.user_id + ':' + e.raw_message
|
let msgId = e.user_id + ':' + e.raw_message
|
||||||
if (msgThrottle[msgId]) {
|
if (msgThrottle[msgId]) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
msgThrottle[msgId] = true
|
msgThrottle[msgId] = true
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
delete msgThrottle[msgId]
|
delete msgThrottle[msgId]
|
||||||
}, 200)
|
}, 200)
|
||||||
|
@ -722,9 +875,18 @@ class PluginsLoader {
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
setLimit(e) {
|
setLimit(e) {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
if (!e.message || e.isPrivate) return
|
if (!e.message || e.isPrivate) return
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
let config = cfg.getGroup(e.group_id)
|
let config = cfg.getGroup(e.group_id)
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
if (config.groupGlobalCD) {
|
if (config.groupGlobalCD) {
|
||||||
this.groupGlobalCD[e.group_id] = true
|
this.groupGlobalCD[e.group_id] = true
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -780,6 +942,9 @@ class PluginsLoader {
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
checkBlack(e) {
|
checkBlack(e) {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
const other = cfg.getOther()
|
const other = cfg.getOther()
|
||||||
|
|
||||||
/** 黑名单qq */
|
/** 黑名单qq */
|
||||||
|
@ -866,13 +1031,17 @@ class PluginsLoader {
|
||||||
const watcher = chokidar.watch(file)
|
const watcher = chokidar.watch(file)
|
||||||
const key = `${dirName}/${appName}`
|
const key = `${dirName}/${appName}`
|
||||||
|
|
||||||
/** 监听修改 */
|
/**
|
||||||
|
* 监听修改
|
||||||
|
*/
|
||||||
watcher.on('change', () => {
|
watcher.on('change', () => {
|
||||||
logger.mark(`[修改插件][${dirName}][${appName}]`)
|
logger.mark(`[修改插件][${dirName}][${appName}]`)
|
||||||
this.changePlugin(key)
|
this.changePlugin(key)
|
||||||
})
|
})
|
||||||
|
|
||||||
/** 监听删除 */
|
/**
|
||||||
|
* 监听删除
|
||||||
|
*/
|
||||||
watcher.on('unlink', () => {
|
watcher.on('unlink', () => {
|
||||||
logger.mark(`[卸载插件][${dirName}][${appName}]`)
|
logger.mark(`[卸载插件][${dirName}][${appName}]`)
|
||||||
/** 停止更新监听 */
|
/** 停止更新监听 */
|
||||||
|
@ -895,20 +1064,35 @@ class PluginsLoader {
|
||||||
watchDir(dirName) {
|
watchDir(dirName) {
|
||||||
if (this.watcher[dirName]) return
|
if (this.watcher[dirName]) return
|
||||||
const watcher = chokidar.watch(`./${this.dir}/${dirName}/`)
|
const watcher = chokidar.watch(`./${this.dir}/${dirName}/`)
|
||||||
/** 热更新 */
|
|
||||||
|
/**
|
||||||
|
* 热更新
|
||||||
|
*/
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
/** 新增文件 */
|
/**
|
||||||
|
* 新增文件
|
||||||
|
*/
|
||||||
watcher.on('add', async PluPath => {
|
watcher.on('add', async PluPath => {
|
||||||
const appName = path.basename(PluPath)
|
const appName = path.basename(PluPath)
|
||||||
if (!appName.endsWith('.js')) return
|
/**
|
||||||
|
*/
|
||||||
|
if (!/^(.js|.ts)$/.test(appName)) return
|
||||||
logger.mark(`[新增插件][${dirName}][${appName}]`)
|
logger.mark(`[新增插件][${dirName}][${appName}]`)
|
||||||
const key = `${dirName}/${appName}`
|
const key = `${dirName}/${appName}`
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
await this.importPlugin({
|
await this.importPlugin({
|
||||||
name: key,
|
name: key,
|
||||||
path: `../../${this.dir}/${key}?${moment().format('X')}`
|
path: `../../${this.dir}/${key}?${moment().format('X')}`
|
||||||
})
|
})
|
||||||
/** 优先级排序 */
|
/**
|
||||||
|
* 优先级排序
|
||||||
|
*/
|
||||||
this.priority = lodash.orderBy(this.priority, ['priority'], ['asc'])
|
this.priority = lodash.orderBy(this.priority, ['priority'], ['asc'])
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
this.watch(dirName, appName)
|
this.watch(dirName, appName)
|
||||||
})
|
})
|
||||||
}, 10000)
|
}, 10000)
|
||||||
|
|
|
@ -20,16 +20,24 @@ export const PluginSuperDefine: {
|
||||||
* 消息
|
* 消息
|
||||||
*/
|
*/
|
||||||
export class Messages {
|
export class Messages {
|
||||||
count = 0
|
#count = 0
|
||||||
rule: {
|
#rule: {
|
||||||
reg: RegExp
|
reg: RegExp
|
||||||
fnc: string
|
fnc: string
|
||||||
}[] = []
|
}[] = []
|
||||||
|
|
||||||
#init = PluginSuperDefine
|
#init = PluginSuperDefine
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化配置
|
||||||
|
* @param init
|
||||||
|
*/
|
||||||
constructor(init?: typeof PluginSuperDefine) {
|
constructor(init?: typeof PluginSuperDefine) {
|
||||||
this.#init = init
|
for (const key in init) {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(this.#init, key)) {
|
||||||
|
this.#init[key] = init[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,10 +46,10 @@ export class Messages {
|
||||||
* @param fnc
|
* @param fnc
|
||||||
*/
|
*/
|
||||||
response(reg: RegExp, fnc: MessageCallBackType) {
|
response(reg: RegExp, fnc: MessageCallBackType) {
|
||||||
this.count++
|
this.#count++
|
||||||
const propName = `prop_${this.count}`
|
const propName = `prop_${this.#count}`
|
||||||
this[propName] = fnc
|
this[propName] = fnc
|
||||||
this.rule.push({
|
this.#rule.push({
|
||||||
reg,
|
reg,
|
||||||
fnc: propName
|
fnc: propName
|
||||||
})
|
})
|
||||||
|
@ -55,9 +63,10 @@ export class Messages {
|
||||||
constructor() {
|
constructor() {
|
||||||
super({
|
super({
|
||||||
...App.#init,
|
...App.#init,
|
||||||
rule: App.rule
|
rule: App.#rule
|
||||||
})
|
})
|
||||||
for (const key of App.rule) {
|
for (const key of App.#rule) {
|
||||||
|
// 确认存在该函数
|
||||||
if (App[key.fnc] instanceof Function) {
|
if (App[key.fnc] instanceof Function) {
|
||||||
this[key.fnc] = App[key.fnc].bind(App)
|
this[key.fnc] = App[key.fnc].bind(App)
|
||||||
}
|
}
|
||||||
|
@ -75,12 +84,12 @@ export class Events {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
count = 0
|
#count = 0
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
data: {
|
#data: {
|
||||||
[key: string]: typeof plugin
|
[key: string]: typeof plugin
|
||||||
} = {}
|
} = {}
|
||||||
|
|
||||||
|
@ -89,14 +98,14 @@ export class Events {
|
||||||
* @param val
|
* @param val
|
||||||
*/
|
*/
|
||||||
use(val: typeof plugin) {
|
use(val: typeof plugin) {
|
||||||
this.count++
|
this.#count++
|
||||||
this.data[this.count] = val
|
this.#data[this.#count] = val
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
get ok() {
|
get ok() {
|
||||||
return this.data
|
return this.#data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,23 @@
|
||||||
import { Common } from '../../miao.js'
|
import { Common } from '../../miao.js'
|
||||||
import { EventType } from './types.js'
|
import { EventType } from './types.js'
|
||||||
|
|
||||||
const stateArr = {}
|
const State = {}
|
||||||
const SymbolTimeout = Symbol('Timeout')
|
const SymbolTimeout = Symbol('Timeout')
|
||||||
const SymbolResolve = Symbol('Resolve')
|
const SymbolResolve = Symbol('Resolve')
|
||||||
|
|
||||||
export class plugin {
|
export class plugin {
|
||||||
|
/**
|
||||||
|
* @deprecated 已废弃
|
||||||
|
*/
|
||||||
name = 'your-plugin'
|
name = 'your-plugin'
|
||||||
|
/**
|
||||||
|
* @deprecated 已废弃
|
||||||
|
*/
|
||||||
dsc = '无'
|
dsc = '无'
|
||||||
|
/**
|
||||||
|
* @deprecated 已废弃
|
||||||
|
*/
|
||||||
|
task = null
|
||||||
rule: {
|
rule: {
|
||||||
reg?: RegExp | string
|
reg?: RegExp | string
|
||||||
fnc: string
|
fnc: string
|
||||||
|
@ -17,7 +27,6 @@ export class plugin {
|
||||||
}[] = []
|
}[] = []
|
||||||
event = 'message'
|
event = 'message'
|
||||||
priority = 9999
|
priority = 9999
|
||||||
task = null
|
|
||||||
namespace = null
|
namespace = null
|
||||||
handler = null
|
handler = null
|
||||||
e: EventType
|
e: EventType
|
||||||
|
@ -53,12 +62,21 @@ export class plugin {
|
||||||
task,
|
task,
|
||||||
rule
|
rule
|
||||||
}: {
|
}: {
|
||||||
|
/**
|
||||||
|
* @deprecated 已废弃
|
||||||
|
*/
|
||||||
name?: typeof this.name
|
name?: typeof this.name
|
||||||
|
/**
|
||||||
|
* @deprecated 已废弃
|
||||||
|
*/
|
||||||
dsc?: typeof this.dsc
|
dsc?: typeof this.dsc
|
||||||
namespace?: typeof this.namespace
|
namespace?: typeof this.namespace
|
||||||
priority?: typeof this.priority
|
priority?: typeof this.priority
|
||||||
handler?: typeof this.handler
|
handler?: typeof this.handler
|
||||||
event?: typeof this.event
|
event?: typeof this.event
|
||||||
|
/**
|
||||||
|
* @deprecated 已废弃
|
||||||
|
*/
|
||||||
task?: typeof this.task
|
task?: typeof this.task
|
||||||
rule?: typeof this.rule
|
rule?: typeof this.rule
|
||||||
}) {
|
}) {
|
||||||
|
@ -92,6 +110,7 @@ export class plugin {
|
||||||
* @param quote 是否引用回复
|
* @param quote 是否引用回复
|
||||||
* @param data.recallMsg 群聊是否撤回消息,0-120秒,0不撤回
|
* @param data.recallMsg 群聊是否撤回消息,0-120秒,0不撤回
|
||||||
* @param data.at 是否at用户
|
* @param data.at 是否at用户
|
||||||
|
* @deprecated 已废弃
|
||||||
*/
|
*/
|
||||||
reply(msg = '', quote = false, data = {}) {
|
reply(msg = '', quote = false, data = {}) {
|
||||||
if (!this.e?.reply || !msg) return false
|
if (!this.e?.reply || !msg) return false
|
||||||
|
@ -99,14 +118,20 @@ export class plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ******
|
* @deprecated 已废弃
|
||||||
* tudo
|
|
||||||
* 异常写法
|
|
||||||
* *****
|
|
||||||
*/
|
*/
|
||||||
group_id: number
|
group_id: number
|
||||||
|
/**
|
||||||
|
* @deprecated 已废弃
|
||||||
|
*/
|
||||||
groupId: number
|
groupId: number
|
||||||
|
/**
|
||||||
|
* @deprecated 已废弃
|
||||||
|
*/
|
||||||
user_id: number
|
user_id: number
|
||||||
|
/**
|
||||||
|
* @deprecated 已废弃
|
||||||
|
*/
|
||||||
userId: number
|
userId: number
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -135,17 +160,17 @@ export class plugin {
|
||||||
timeout = '操作超时已取消'
|
timeout = '操作超时已取消'
|
||||||
) {
|
) {
|
||||||
const key = this.conKey(isGroup)
|
const key = this.conKey(isGroup)
|
||||||
if (!stateArr[key]) stateArr[key] = {}
|
if (!State[key]) State[key] = {}
|
||||||
stateArr[key][type] = this.e
|
State[key][type] = this.e
|
||||||
if (time)
|
if (time)
|
||||||
stateArr[key][type][SymbolTimeout] = setTimeout(() => {
|
State[key][type][SymbolTimeout] = setTimeout(() => {
|
||||||
if (stateArr[key][type]) {
|
if (State[key][type]) {
|
||||||
const resolve = stateArr[key][type][SymbolResolve]
|
const resolve = State[key][type][SymbolResolve]
|
||||||
delete stateArr[key][type]
|
delete State[key][type]
|
||||||
resolve ? resolve(false) : this.reply(timeout, true)
|
resolve ? resolve(false) : this.reply(timeout, true)
|
||||||
}
|
}
|
||||||
}, time * 1000)
|
}, time * 1000)
|
||||||
return stateArr[key][type]
|
return State[key][type]
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -155,8 +180,8 @@ export class plugin {
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getContext(type: string, isGroup?: boolean) {
|
getContext(type: string, isGroup?: boolean) {
|
||||||
if (type) return stateArr[this.conKey(isGroup)]?.[type]
|
if (type) return State[this.conKey(isGroup)]?.[type]
|
||||||
return stateArr[this.conKey(isGroup)]
|
return State[this.conKey(isGroup)]
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -166,9 +191,9 @@ export class plugin {
|
||||||
*/
|
*/
|
||||||
finish(type: string, isGroup?: boolean) {
|
finish(type: string, isGroup?: boolean) {
|
||||||
const key = this.conKey(isGroup)
|
const key = this.conKey(isGroup)
|
||||||
if (stateArr[key]?.[type]) {
|
if (State[key]?.[type]) {
|
||||||
clearTimeout(stateArr[key][type][SymbolTimeout])
|
clearTimeout(State[key][type][SymbolTimeout])
|
||||||
delete stateArr[key][type]
|
delete State[key][type]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +219,7 @@ export class plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @deprecated 已废弃
|
||||||
* @param plugin
|
* @param plugin
|
||||||
* @param tpl
|
* @param tpl
|
||||||
* @param data
|
* @param data
|
||||||
|
|
|
@ -10,7 +10,7 @@ Data.createDir('/data/db', 'root')
|
||||||
/**
|
/**
|
||||||
* DB自定义
|
* DB自定义
|
||||||
*/
|
*/
|
||||||
const sequelize = new Sequelize({
|
export const sequelize = new Sequelize({
|
||||||
dialect: 'sqlite',
|
dialect: 'sqlite',
|
||||||
storage: join(process.cwd(), '/data/db/data.db'),
|
storage: join(process.cwd(), '/data/db/data.db'),
|
||||||
logging: false
|
logging: false
|
||||||
|
@ -34,8 +34,3 @@ export default class BaseModel extends Model {
|
||||||
model.COLUMNS = columns
|
model.COLUMNS = columns
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
export { sequelize }
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import BaseModel from './BaseModel.js'
|
import BaseModel from './BaseModel.js'
|
||||||
|
import { DataTypes } from 'sequelize'
|
||||||
const { Types } = BaseModel
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -8,22 +7,22 @@ const { Types } = BaseModel
|
||||||
const COLUMNS = {
|
const COLUMNS = {
|
||||||
// 用户ID,qq为数字
|
// 用户ID,qq为数字
|
||||||
ltuid: {
|
ltuid: {
|
||||||
type: Types.INTEGER,
|
type: DataTypes.INTEGER,
|
||||||
primaryKey: true
|
primaryKey: true
|
||||||
},
|
},
|
||||||
|
|
||||||
// MysUser类型,mys / hoyolab
|
// MysUser类型,mys / hoyolab
|
||||||
type: {
|
type: {
|
||||||
type: Types.STRING,
|
type: DataTypes.STRING,
|
||||||
defaultValue: 'mys',
|
defaultValue: 'mys',
|
||||||
notNull: true
|
notNull: true
|
||||||
},
|
},
|
||||||
|
|
||||||
// CK
|
// CK
|
||||||
ck: Types.STRING,
|
ck: DataTypes.STRING,
|
||||||
device: Types.STRING,
|
device: DataTypes.STRING,
|
||||||
uids: {
|
uids: {
|
||||||
type: Types.STRING,
|
type: DataTypes.STRING,
|
||||||
get() {
|
get() {
|
||||||
let data = this.getDataValue('uids')
|
let data = this.getDataValue('uids')
|
||||||
let ret = {}
|
let ret = {}
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
import BaseModel from './BaseModel.js'
|
import BaseModel from './BaseModel.js'
|
||||||
import lodash from 'lodash'
|
import lodash from 'lodash'
|
||||||
import MysUtil from '../mys/MysUtil.js'
|
import MysUtil from '../mys/MysUtil.js'
|
||||||
|
import { DataTypes } from 'sequelize'
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
const { Types } = BaseModel
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -13,26 +9,26 @@ const { Types } = BaseModel
|
||||||
const COLUMNS = {
|
const COLUMNS = {
|
||||||
// 用户ID,qq为数字
|
// 用户ID,qq为数字
|
||||||
id: {
|
id: {
|
||||||
type: Types.STRING,
|
type: DataTypes.STRING,
|
||||||
autoIncrement: false,
|
autoIncrement: false,
|
||||||
primaryKey: true
|
primaryKey: true
|
||||||
},
|
},
|
||||||
|
|
||||||
type: {
|
type: {
|
||||||
type: Types.STRING,
|
type: DataTypes.STRING,
|
||||||
defaultValue: 'qq',
|
defaultValue: 'qq',
|
||||||
notNull: true
|
notNull: true
|
||||||
},
|
},
|
||||||
|
|
||||||
// 昵称
|
// 昵称
|
||||||
name: Types.STRING,
|
name: DataTypes.STRING,
|
||||||
|
|
||||||
// 头像
|
// 头像
|
||||||
face: Types.STRING,
|
face: DataTypes.STRING,
|
||||||
|
|
||||||
ltuids: Types.STRING,
|
ltuids: DataTypes.STRING,
|
||||||
games: {
|
games: {
|
||||||
type: Types.STRING,
|
type: DataTypes.STRING,
|
||||||
get() {
|
get() {
|
||||||
let data = this.getDataValue('games')
|
let data = this.getDataValue('games')
|
||||||
let ret = {}
|
let ret = {}
|
||||||
|
@ -54,7 +50,7 @@ const COLUMNS = {
|
||||||
this.setDataValue('games', JSON.stringify(data))
|
this.setDataValue('games', JSON.stringify(data))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data: Types.STRING
|
data: DataTypes.STRING
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,23 +1,18 @@
|
||||||
|
import { DataTypes } from 'sequelize'
|
||||||
import BaseModel from './BaseModel.js'
|
import BaseModel from './BaseModel.js'
|
||||||
import lodash from 'lodash'
|
import lodash from 'lodash'
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
const { Types } = BaseModel
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
const COLUMNS = {
|
const COLUMNS = {
|
||||||
// 用户ID,qq为数字
|
// 用户ID,qq为数字
|
||||||
userId: {
|
userId: {
|
||||||
type: Types.STRING
|
type: DataTypes.STRING
|
||||||
},
|
},
|
||||||
game: Types.STRING,
|
game: DataTypes.STRING,
|
||||||
uid: Types.STRING,
|
uid: DataTypes.STRING,
|
||||||
data: {
|
data: {
|
||||||
type: Types.STRING,
|
type: DataTypes.STRING,
|
||||||
get() {
|
get() {
|
||||||
let data = this.getDataValue('data')
|
let data = this.getDataValue('data')
|
||||||
let ret = {}
|
let ret = {}
|
||||||
|
|
|
@ -54,21 +54,26 @@ type ChalkInstanceType = {
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
/**
|
/**
|
||||||
* @deprecated 不推荐使用
|
* @deprecated 不推荐使用,未来将废弃
|
||||||
*/
|
*/
|
||||||
var redis: RedisClientType
|
var redis: RedisClientType
|
||||||
/**
|
/**
|
||||||
* @deprecated 不推荐使用
|
*
|
||||||
|
* @deprecated 不推荐使用,未来将废弃
|
||||||
*/
|
*/
|
||||||
var Bot: typeof Yunzai.prototype
|
var Bot: typeof Yunzai.prototype
|
||||||
/**
|
/**
|
||||||
* @deprecated 不推荐使用
|
* @deprecated 不推荐使用,未来将废弃
|
||||||
*/
|
*/
|
||||||
var segment: typeof se
|
var segment: typeof se
|
||||||
/**
|
/**
|
||||||
* @deprecated 不推荐使用
|
* @deprecated 不推荐使用,未来将废弃
|
||||||
*/
|
*/
|
||||||
var plugin: typeof p
|
var plugin: typeof p
|
||||||
|
/**
|
||||||
|
* 统一化的打印对象
|
||||||
|
* 构造颜色请使用 logger.chalk
|
||||||
|
*/
|
||||||
var logger: LoggerType &
|
var logger: LoggerType &
|
||||||
ChalkInstanceType & {
|
ChalkInstanceType & {
|
||||||
chalk: ChalkInstance
|
chalk: ChalkInstance
|
||||||
|
|
|
@ -3,9 +3,19 @@
|
||||||
*/
|
*/
|
||||||
import MysUtil from './MysUtil.js'
|
import MysUtil from './MysUtil.js'
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
const cacheMap = {}
|
const cacheMap = {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
const reFn = {}
|
const reFn = {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
export default class BaseModel {
|
export default class BaseModel {
|
||||||
_uuid = null
|
_uuid = null
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,19 @@ import BaseModel from './BaseModel.js'
|
||||||
import MysUtil from './MysUtil.js'
|
import MysUtil from './MysUtil.js'
|
||||||
import { REDIS_ROOT_KEY } from '../config/system.js'
|
import { REDIS_ROOT_KEY } from '../config/system.js'
|
||||||
|
|
||||||
//
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
const servs = ['mys', 'hoyolab']
|
const servs = ['mys', 'hoyolab']
|
||||||
// 超时时间不必精确,直接定24小时即可
|
|
||||||
|
/**
|
||||||
|
* 超时时间不必精确,直接定24小时即可
|
||||||
|
*/
|
||||||
const EX = 3600 * 24
|
const EX = 3600 * 24
|
||||||
//
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
const redisKeyRoot = REDIS_ROOT_KEY
|
const redisKeyRoot = REDIS_ROOT_KEY
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -5,16 +5,14 @@
|
||||||
* 一个MysUser对应一个有效CK
|
* 一个MysUser对应一个有效CK
|
||||||
* 一个MysUser可能有多个MysUid关联记录
|
* 一个MysUser可能有多个MysUid关联记录
|
||||||
*/
|
*/
|
||||||
|
import lodash from 'lodash'
|
||||||
|
import fetch from 'node-fetch'
|
||||||
import DailyCache from './DailyCache.js'
|
import DailyCache from './DailyCache.js'
|
||||||
import BaseModel from './BaseModel.js'
|
import BaseModel from './BaseModel.js'
|
||||||
import NoteUser from './NoteUser.js'
|
import NoteUser from './NoteUser.js'
|
||||||
import MysApi from './mysApi.js'
|
import MysApi from './mysApi.js'
|
||||||
import MysUtil from './MysUtil.js'
|
import MysUtil from './MysUtil.js'
|
||||||
import lodash from 'lodash'
|
|
||||||
import fetch from 'node-fetch'
|
|
||||||
|
|
||||||
import { MysUserDB } from '../db/index.js'
|
import { MysUserDB } from '../db/index.js'
|
||||||
|
|
||||||
import { Data } from '../miao.js'
|
import { Data } from '../miao.js'
|
||||||
|
|
||||||
const tables = {
|
const tables = {
|
||||||
|
|
|
@ -11,7 +11,7 @@ const games = [
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
const MysUtil = {
|
export default {
|
||||||
/**
|
/**
|
||||||
* 获取标准ltuid
|
* 获取标准ltuid
|
||||||
* @param data
|
* @param data
|
||||||
|
@ -87,8 +87,3 @@ const MysUtil = {
|
||||||
await Data.forEach(['mys', 'hoyolab'], fn)
|
await Data.forEach(['mys', 'hoyolab'], fn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
export default MysUtil
|
|
||||||
|
|
|
@ -14,6 +14,13 @@ import { Data } from '../miao.js'
|
||||||
* *******************
|
* *******************
|
||||||
*/
|
*/
|
||||||
export default class NoteUser extends BaseModel {
|
export default class NoteUser extends BaseModel {
|
||||||
|
db = null
|
||||||
|
|
||||||
|
qq = null
|
||||||
|
|
||||||
|
mysUsers = null
|
||||||
|
|
||||||
|
_map = null
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param qq
|
* @param qq
|
||||||
|
@ -129,10 +136,6 @@ export default class NoteUser extends BaseModel {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
db = null
|
|
||||||
|
|
||||||
qq = null
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化数据
|
* 初始化数据
|
||||||
* @param db
|
* @param db
|
||||||
|
@ -152,8 +155,6 @@ export default class NoteUser extends BaseModel {
|
||||||
await this.save()
|
await this.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
mysUsers = null
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化MysUser对象
|
* 初始化MysUser对象
|
||||||
*/
|
*/
|
||||||
|
@ -425,8 +426,6 @@ export default class NoteUser extends BaseModel {
|
||||||
return await this.delMysUser(ltuid)
|
return await this.delMysUser(ltuid)
|
||||||
}
|
}
|
||||||
|
|
||||||
_map = null
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param mysUser
|
* @param mysUser
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
mys 存在循环引用
|
|
||||||
|
|
||||||
(!) Circular dependencies
|
|
||||||
src/mys/apiTool.ts -> src/mys/mysApi.ts -> src/mys/apiTool.ts
|
|
||||||
src/mys/gsCfg.ts -> src/mys/mysInfo.ts -> src/mys/gsCfg.ts
|
|
||||||
src/mys/NoteUser.ts -> src/mys/MysUser.ts -> src/mys/NoteUser.ts
|
|
|
@ -7,14 +7,12 @@ import mysInfo from './mysInfo.js'
|
||||||
import MysUser from './MysUser.js'
|
import MysUser from './MysUser.js'
|
||||||
import MysUtil from './MysUtil.js'
|
import MysUtil from './MysUtil.js'
|
||||||
import NoteUser from './NoteUser.js'
|
import NoteUser from './NoteUser.js'
|
||||||
export {
|
export const ApiTool = apiTool
|
||||||
apiTool,
|
export const GSCfg = gsCfg
|
||||||
BaseModel,
|
export const MysApi = mysApi
|
||||||
DailyCache,
|
export const MysInfo = mysInfo
|
||||||
gsCfg,
|
export { BaseModel, DailyCache, MysUser, MysUtil, NoteUser }
|
||||||
mysApi,
|
/**
|
||||||
mysInfo,
|
* @deprecated 已废弃
|
||||||
MysUser,
|
*/
|
||||||
MysUtil,
|
export { apiTool, gsCfg, mysApi, mysInfo }
|
||||||
NoteUser
|
|
||||||
}
|
|
||||||
|
|
|
@ -3,6 +3,9 @@ import fetch from 'node-fetch'
|
||||||
import cfg from '../config/config.js'
|
import cfg from '../config/config.js'
|
||||||
import apiTool from './apiTool.js'
|
import apiTool from './apiTool.js'
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
let HttpsProxyAgent = null
|
let HttpsProxyAgent = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
import MysApi from './mysApi.js'
|
|
||||||
|
|
||||||
// tudo
|
|
||||||
import GsCfg from './gsCfg.js'
|
|
||||||
|
|
||||||
import lodash from 'lodash'
|
import lodash from 'lodash'
|
||||||
|
import MysApi from './mysApi.js'
|
||||||
|
import GsCfg from './gsCfg.js'
|
||||||
import NoteUser from './NoteUser.js'
|
import NoteUser from './NoteUser.js'
|
||||||
import MysUser from './MysUser.js'
|
import MysUser from './MysUser.js'
|
||||||
import DailyCache from './DailyCache.js'
|
import DailyCache from './DailyCache.js'
|
||||||
|
@ -15,14 +12,23 @@ import DailyCache from './DailyCache.js'
|
||||||
*/
|
*/
|
||||||
export default class MysInfo {
|
export default class MysInfo {
|
||||||
static tips = '请先#绑定Cookie\n发送【Cookie帮助】查看配置教程'
|
static tips = '请先#绑定Cookie\n发送【Cookie帮助】查看配置教程'
|
||||||
|
/**
|
||||||
|
* 当前查询原神uid
|
||||||
|
*/
|
||||||
uid = null
|
uid = null
|
||||||
e = null
|
e = null
|
||||||
userId = null
|
userId = null
|
||||||
|
/**
|
||||||
|
* 当前ck信息
|
||||||
|
*/
|
||||||
ckInfo = null
|
ckInfo = null
|
||||||
auth = null
|
auth = null
|
||||||
gtest = null
|
gtest = null
|
||||||
mysButton = null
|
mysButton = null
|
||||||
|
/**
|
||||||
|
* ck对应MysUser对象
|
||||||
|
*/
|
||||||
|
ckUser = null
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param e
|
* @param e
|
||||||
|
@ -32,9 +38,7 @@ export default class MysInfo {
|
||||||
this.e = e
|
this.e = e
|
||||||
this.userId = String(e.user_id)
|
this.userId = String(e.user_id)
|
||||||
}
|
}
|
||||||
/** 当前查询原神uid */
|
|
||||||
this.uid = ''
|
this.uid = ''
|
||||||
/** 当前ck信息 */
|
|
||||||
this.ckInfo = {
|
this.ckInfo = {
|
||||||
ck: '',
|
ck: '',
|
||||||
uid: '',
|
uid: '',
|
||||||
|
@ -42,7 +46,6 @@ export default class MysInfo {
|
||||||
ltuid: '',
|
ltuid: '',
|
||||||
type: ''
|
type: ''
|
||||||
}
|
}
|
||||||
// ck对应MysUser对象
|
|
||||||
this.ckUser = null
|
this.ckUser = null
|
||||||
this.auth = [
|
this.auth = [
|
||||||
'dailyNote',
|
'dailyNote',
|
||||||
|
@ -60,9 +63,7 @@ export default class MysInfo {
|
||||||
'action_cardList',
|
'action_cardList',
|
||||||
'avatarInfo'
|
'avatarInfo'
|
||||||
]
|
]
|
||||||
|
|
||||||
this.gtest = false
|
this.gtest = false
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ********
|
* ********
|
||||||
* tudo
|
* tudo
|
||||||
|
@ -619,8 +620,6 @@ export default class MysInfo {
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
ckUser = null
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除失效ck
|
* 删除失效ck
|
||||||
* @returns
|
* @returns
|
||||||
|
|
|
@ -47,6 +47,7 @@ export function mkdirs(dirname: string) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,6 +3,9 @@ import { renderToString } from 'react-dom/server'
|
||||||
import { mkdirSync, writeFileSync } from 'fs'
|
import { mkdirSync, writeFileSync } from 'fs'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
export type ComponentCreateOpsionType = {
|
export type ComponentCreateOpsionType = {
|
||||||
html_head?: string
|
html_head?: string
|
||||||
html_name?: string
|
html_name?: string
|
||||||
|
@ -18,6 +21,9 @@ export type ComponentCreateOpsionType = {
|
||||||
*/
|
*/
|
||||||
export class Component {
|
export class Component {
|
||||||
#dir = ''
|
#dir = ''
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
constructor() {
|
constructor() {
|
||||||
this.#dir = join(process.cwd(), 'html')
|
this.#dir = join(process.cwd(), 'html')
|
||||||
mkdirSync(this.#dir, {
|
mkdirSync(this.#dir, {
|
||||||
|
|
Loading…
Reference in New Issue