Skip to content

Commit

Permalink
fix(common): fix handler error, fix #209
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Apr 6, 2021
1 parent 95e5181 commit 3ab470f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/plugin-common/src/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function broadcast(ctx: Context) {
ctx.select('database')
.command('common/broadcast <message:text>', '全服广播', { authority: 4 })
.option('forced', '-f 无视 silent 标签进行广播')
.option('only', '-o 仅向当前 Bot 负责的群进行广播')
.option('only', '-o 仅向当前账号负责的群进行广播')
.action(async ({ options, session }, message) => {
if (!message) return template('common.expect-text')
if (!options.only) {
Expand All @@ -36,7 +36,7 @@ export function broadcast(ctx: Context) {

export function contextify(ctx: Context) {
ctx.select('database')
.command('common/contextify <message:text>', '在特定上下文中触发指令', { authority: 3 })
.command('common/contextify <command:text>', '在特定上下文中触发指令', { authority: 3 })
.alias('ctxf')
.userFields(['authority'])
.option('user', '-u [id:user] 使用用户私聊上下文')
Expand Down
6 changes: 3 additions & 3 deletions packages/plugin-common/src/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,17 @@ async function getHandlerResult(handler: RequestHandler, session: Session, prefe
export function verify(ctx: Context, config: HandlerConfig) {
ctx.on('friend-request', async (session) => {
const result = await getHandlerResult(config.onFriendRequest, session, true)
return session.bot.handleFriendRequest(session.messageId, ...result)
if (result) return session.bot.handleFriendRequest(session.messageId, ...result)
})

ctx.on('group-request', async (session) => {
const result = await getHandlerResult(config.onGroupRequest, session, false)
return session.bot.handleGroupRequest(session.messageId, ...result)
if (result) return session.bot.handleGroupRequest(session.messageId, ...result)
})

ctx.on('group-member-request', async (session) => {
const result = await getHandlerResult(config.onGroupMemberRequest, session, false)
return session.bot.handleGroupMemberRequest(session.messageId, ...result)
if (result) return session.bot.handleGroupMemberRequest(session.messageId, ...result)
})
}

Expand Down

0 comments on commit 3ab470f

Please sign in to comment.