Skip to content

Commit

Permalink
feat(core): support image as arg type
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jan 9, 2024
1 parent 5d440e4 commit 35c16ff
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/core/src/command/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ export namespace Argv {
posint: number
natural: number
date: Date
image: {
src?: string
}
}

type DomainType = keyof Domain
Expand Down Expand Up @@ -319,6 +322,14 @@ export namespace Argv {
throw new Error('internal.invalid-channel')
})

createDomain('image', (source, session) => {
const code = h.from(source)
if (code && code.type === 'img') {
return code.attrs
}
throw new Error('internal.invalid-image')
})

const BRACKET_REGEXP = /<[^>]+>|\[[^\]]+\]/g

interface DeclarationList extends Array<Declaration> {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ internal:
invalid-date: Expect a valid date.
invalid-user: Expect a valid user.
invalid-channel: Expect a valid channel.
invalid-image: Expect an image.
suggest-hint: Do you mean {0}?
suggest-command: Send a period to apply the suggestion.
commands:
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/locales/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ internal:
invalid-date: 请输入合法的时间。
invalid-user: 请指定正确的用户。
invalid-channel: 请指定正确的频道。
invalid-image: 请输入图片。
suggest-hint: 您要找的是不是{0}?
suggest-command: 回复句号以使用推测的指令。

Expand Down

0 comments on commit 35c16ff

Please sign in to comment.