Skip to content

Commit

Permalink
feat(status): support experimental status hook
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Sep 9, 2020
1 parent 0c58830 commit 827aa1f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/plugin-status/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import { ActiveData } from './database'

export * from './database'

declare module 'koishi-core/dist/context' {
interface EventMap {
'status'(status: Status, output: string[]): void
}
}

declare module 'koishi-core/dist/server' {
interface BotOptions {
label?: string
Expand Down Expand Up @@ -161,6 +167,7 @@ export function apply(ctx: Context, config: Config) {
`内存使用率:${(memory.app * 100).toFixed()}% / ${(memory.total * 100).toFixed()}%`,
)

ctx.emit('status', status, output)
return output.join('\n')
})

Expand Down

0 comments on commit 827aa1f

Please sign in to comment.