Skip to content

Commit

Permalink
feat: update tarot command to support text output instead of images
Browse files Browse the repository at this point in the history
  • Loading branch information
MaikoTan committed Nov 1, 2024
1 parent 9566fda commit e3dd100
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ export function apply(ctx: Context) {
for (let i = 0; i < options.count || 1; i++) {
let result = await getTarot(ctx)
let img = result.match(/(?<=(±img=)).+(?=±)/g)[0]
let text1 = result.match(/.+(?=(±i))/g)[0].replace(/(\\r)/, '\n')
let text2 = result.match(/(?<=(g±)).+/g)[0].replace(/(\\r)/, ' ')

if (options.minimal) {
ret.push(h('img', { src: img }))
ret.push(h('text', text1))
ret.push(h('text', text2))
continue
}

let text1 = result.match(/.+(?=(±i))/g)[0].replace(/(\\r)/, '\n')
let text2 = result.match(/(?<=(g±)).+/g)[0].replace(/(\\r)/, ' ')
ret.push(h('img', { src: img }), text1, text2)
}

Expand All @@ -34,7 +35,7 @@ export function apply(ctx: Context) {
'commands.tarot': {
description: '抽取一张塔罗牌',
options: {
minimal: '仅输出图片',
minimal: '仅输出文本',
count: '抽取张数',
},
},
Expand All @@ -43,7 +44,7 @@ export function apply(ctx: Context) {
'commands.tarot': {
description: 'Draw a tarot card (Chinese only)',
options: {
minimal: 'show image only',
minimal: 'show text only',
count: 'number of cards',
},
},
Expand Down

0 comments on commit e3dd100

Please sign in to comment.