Skip to content

Commit

Permalink
fix(core): fix suggestion bug
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Sep 4, 2023
1 parent 84bbbf3 commit 76cf45d
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"devDependencies": {
"@koishijs/eslint-config": "^1.0.4",
"@koishijs/plugin-database-memory": "^2.3.0",
"@koishijs/plugin-mock": "^2.5.0",
"@koishijs/plugin-mock": "^2.5.2",
"@koishijs/vitepress": "^3.0.0",
"@sinonjs/fake-timers": "^6.0.1",
"@types/mocha": "^9.1.1",
Expand All @@ -48,7 +48,7 @@
"yakumo-publish": "^0.3.3",
"yakumo-publish-sync": "^0.3.3",
"yakumo-tsc": "^0.3.12",
"yakumo-upgrade": "^0.3.2",
"yakumo-upgrade": "^0.3.4",
"yakumo-version": "^0.3.2",
"vitepress": "1.0.0-rc.4"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/author/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export function apply(ctx: Context, config: Config) {
}
}

if (options.action !== 'modify' && hasUnnamed && session.subtype === 'group') {
if (options.action !== 'modify' && hasUnnamed && !session.isDirect) {
try {
const memberMap = await session.bot.getGuildMemberMap(session.guildId)
for (const userId in memberMap) {
Expand Down
6 changes: 3 additions & 3 deletions packages/context/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export function apply(ctx: Context, config: Config) {
} else {
defineProperty(options, '_guilds', options.guilds ? options.guilds.split(',').map(id => `${session.platform}:${id}`) : [])
}
} else if (session.subtype !== 'group' && options['partial']) {
} else if (session.isDirect && options['partial']) {
return session.text('.context.private-context')
} else {
defineProperty(options, '_guilds', guilds)
Expand Down Expand Up @@ -142,7 +142,7 @@ export function apply(ctx: Context, config: Config) {
})

ctx.on('dialogue/detail', ({ guilds, flag }, detail, session) => {
const includeCurrentGuild = session.subtype === 'group' && guilds.includes(session.gid)
const includeCurrentGuild = !session.isDirect && guilds.includes(session.gid)
const prefix = flag & Dialogue.Flag.complement ? 'enable-' : 'disable-'
const path = includeCurrentGuild
? 'except-current-' + (guilds.length - 1 ? 'and-more' : 'only')
Expand All @@ -152,7 +152,7 @@ export function apply(ctx: Context, config: Config) {

ctx.on('dialogue/abstract', ({ guilds, flag }, output, session) => {
const { options } = session.argv
if (!options._guilds && session.subtype === 'group') {
if (!options._guilds && !session.isDirect) {
const isReversed = flag & Dialogue.Flag.complement
const hasGroup = guilds.includes(session.gid)
output.unshift(!isReversed === hasGroup ? isReversed ? 'E' : 'e' : isReversed ? 'd' : 'D')
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ export default function apply(ctx: Context, config: Dialogue.Config) {
const [question, answer] = args

function applySuggestion(session: Dialogue.Session) {
// Create a new session to isolate i18n scope.
session = Object.create(session)
return session.withScope('commands.teach.messages', () => {
return session.argv.options.target ? analyze(session) : create(session)
})
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default function apply(ctx: Context) {
...test,
regexp: null,
question: parsed,
original: original,
original,
})
Object.defineProperty(dialogue, '_redirections', { writable: true, value: dialogues })
await ctx.parallel('dialogue/search', session, test, dialogues)
Expand Down

0 comments on commit 76cf45d

Please sign in to comment.