Skip to content

Commit

Permalink
feat(core): support cqhttp 4.14
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Feb 18, 2020
1 parent 0453948 commit 169089e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/koishi-core/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ export interface EventMap {
'lifecycle' (meta: Meta<'meta_event'>): any
'lifecycle/enable' (meta: Meta<'meta_event'>): any
'lifecycle/disable' (meta: Meta<'meta_event'>): any
'lifecycle/connect' (meta: Meta<'meta_event'>): any
'before-user' (fields: Set<UserField>, argv: ParsedCommandLine): any
'before-group' (fields: Set<GroupField>, argv: ParsedCommandLine): any
'attach' (meta: Meta<'message'>): any
Expand Down
2 changes: 1 addition & 1 deletion packages/koishi-core/src/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface SubTypeMap {
notice: 'set' | 'unset' | 'approve' | 'invite' | 'leave' | 'kick' | 'kick_me' | 'ban' | 'lift_ban'
request: 'add' | 'invite'
// eslint-disable-next-line camelcase
meta_event: 'enable' | 'disable'
meta_event: 'enable' | 'disable' | 'connect'
send: never
}

Expand Down
8 changes: 4 additions & 4 deletions packages/plugin-common/src/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,18 @@ async function showCommandHelp (command: Command, meta: Meta<'message'>, options
const maxUsage = command.getConfig('maxUsage', meta)
const minInterval = command.getConfig('minInterval', meta)
if (meta.$user) {
const { authority, maxUsageText } = command.config
const usage = getUsage(command.usageName, meta.$user)
if (maxUsage !== Infinity) {
output.push(`已调用次数:${Math.min(usage.count, maxUsage)}/${maxUsageText || maxUsage}。`)
output.push(`已调用次数:${Math.min(usage.count || 0, maxUsage)}/${maxUsage}。`)
}

if (minInterval > 0) {
const nextUsage = usage.last ? (Math.max(0, minInterval + usage.last - Date.now()) / 1000).toFixed() : 0
output.push(`距离下次调用还需:${nextUsage}/${minInterval / 1000} 秒。`)
}

if (authority > 1) {
output.push(`最低权限:${authority} 级。`)
if (command.config.authority > 1) {
output.push(`最低权限:${command.config.authority} 级。`)
}
}

Expand Down

0 comments on commit 169089e

Please sign in to comment.