miao-plugin/apps/character.js

60 lines
1.4 KiB
JavaScript
Raw Normal View History

import { Common, App } from '../components/index.js'
2022-09-16 20:37:09 +00:00
import { Character } from '../models/index.js'
2022-07-23 20:32:10 +00:00
import { renderAvatar } from './character/avatar-card.js'
2022-09-16 20:37:09 +00:00
import { uploadCharacterImg } from './character/character-img-upload.js'
import { wife, wifeReg } from './character/avatar-wife.js'
import { getOriginalPicture } from './character/utils.js'
2022-09-16 20:37:09 +00:00
let app = App.init({
id: 'character',
2022-09-16 22:01:31 +00:00
name: '角色查询'
2022-09-16 20:37:09 +00:00
})
2022-09-16 20:37:09 +00:00
app.reg('character', character, {
rule: /^#.+$/,
name: '角色卡片'
2022-09-16 20:37:09 +00:00
})
app.reg('upload-img', uploadCharacterImg, {
rule: /^#*(喵喵)?(上传|添加)(.+)(照片|写真|图片|图像)\s*$/,
name: '上传角色写真'
})
app.reg('wife', wife, {
rule: wifeReg,
describe: '#老公 #老婆 查询'
})
app.reg('original-pic', getOriginalPicture, {
rule: /^#?(获取|给我|我要|求|发|发下|发个|发一下)?原图(吧|呗)?$/,
describe: '【#原图】 回复角色卡片,可获取原图'
})
export default app
2022-08-06 22:36:05 +00:00
2022-03-26 21:34:33 +00:00
// 查看当前角色
export async function character (e) {
let msg = e.original_msg || e.msg
2022-04-14 20:53:22 +00:00
if (!msg) {
2022-07-23 20:32:10 +00:00
return
}
2022-04-09 21:33:21 +00:00
2022-07-23 20:32:10 +00:00
let uidRet = /[0-9]{9}/.exec(msg)
if (uidRet) {
2022-07-23 20:32:10 +00:00
e.uid = uidRet[0]
msg = msg.replace(uidRet[0], '')
}
2022-07-23 20:32:10 +00:00
let name = msg.replace(/#|老婆|老公/g, '').trim()
if (Common.isDisable(e, 'char.char')) {
2022-07-23 20:32:10 +00:00
return
}
2022-07-23 20:32:10 +00:00
let char = Character.get(name.trim())
2022-03-26 21:34:33 +00:00
if (!char) {
2022-07-23 20:32:10 +00:00
return false
2022-03-26 21:34:33 +00:00
}
return renderAvatar(e, char.name)
}