Skip to content

Commit

Permalink
fix:修正部分日志,类型错误
Browse files Browse the repository at this point in the history
  • Loading branch information
sj817 committed Apr 15, 2024
1 parent 1b7626a commit f4a068d
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 18 deletions.
1 change: 0 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ module.exports = {
sourceType: 'module'
},
globals: {
Karin: true,
logger: true
},
rules: {
Expand Down
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"editor.detectIndentation": false,
"editor.tabSize": 2,
"editor.formatOnSave": false,
"editor.formatOnSave": true,
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
"javascript.format.insertSpaceAfterConstructor": true
}
}
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Bot from './lib/config/index.js'
import logger from './lib/config/log.js'
import Bot from './lib/config/index.js'

/** 初始化Bot */
await Bot.start()
Expand Down
2 changes: 1 addition & 1 deletion lib/adapter/onebot/OneBot11.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class OneBot11 {
const timer = setInterval(() => {
if (this.account.nickname) {
const { app_name, app_version } = this.version
this.logger('info', `建立连接成功:[${app_name}(${app_version})]${this.url}`)
this.logger('info', `建立连接成功:[${app_name}(${app_version})] ${this.url}`)
clearInterval(timer)
resolve(true)
}
Expand Down
1 change: 0 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ import Renderer from './Renderer/Renderer.js'
import { kritor } from './adapter/kritor/protos/compiled.js'

export { App, Bot, Cfg, common, logger, plugin, redis, segment, Renderer, kritor }
export default { App, Bot, Cfg, common, logger, plugin, redis, segment, Renderer, kritor }
18 changes: 6 additions & 12 deletions lib/plugins/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Plugins {
* priority: number,
* permission: string,
* accept: boolean,
* rule: Array<{reg: RegExp, fnc: string, event?: string, permission?: string, log?: boolean}>,
* rule: Array<{reg: RegExp, fnc: string, event?: string, permission?: string, log?: Function}>,
* }[]}
*/
this.Apps = []
Expand All @@ -38,7 +38,8 @@ class Plugins {
* file: { name: string, dir: string },
* cron: string,
* fnc: string,
* log: boolean
* log: Function,
* name: string
* }>}
*/
this.task = []
Expand Down Expand Up @@ -172,13 +173,6 @@ class Plugins {
/** 执行初始化 */
Class.init && Class.init()

/** 注册handler */
lodash.forEach(Class.handler, ({ fnc, key, name = Class.name, priority = Class.priority }) => {
const self = Class
fnc = Class[fnc]
Handler.add({ name, key, priority, self, fnc })
})

/** 收集定时任务 */
lodash.forEach(Class.task, (val) => {
if (!val.name) return logger.error(`[${dir}][${name}] 定时任务name错误`)
Expand Down Expand Up @@ -237,13 +231,13 @@ class Plugins {
val.log = val.log === false ? () => '' : (log) => logger.mark(log)
val.schedule = schedule.scheduleJob(val.cron, async () => {
try {
val.log(`[定时任务][${val.name}] 开始执行`)
val.log(`[定时任务][${val.file.dir}][${val.name}] 开始执行`)
const App = new val.App()
let res = App[val.fnc] && App[val.fnc]()
if (util.types.isPromise(res)) res = await res
val.log(`[定时任务][${val.name}] 执行完毕`)
val.log(`[定时任务][${val.file.dir}][${val.name}] 执行完毕`)
} catch (error) {
logger.error(`[定时任务][${val.name}] 执行报错`)
logger.error(`[定时任务][${val.file.dir}][${val.name}] 执行报错`)
logger.error(error)
}
})
Expand Down

0 comments on commit f4a068d

Please sign in to comment.