2022-09-17 22:19:26 +00:00
|
|
|
import { Common, App } from '../components/index.js'
|
2022-09-16 20:37:09 +00:00
|
|
|
import { Character } from '../models/index.js'
|
2022-10-06 22:20:46 +00:00
|
|
|
import { renderAvatar } from './character/AvatarCard.js'
|
|
|
|
import { uploadCharacterImg } from './character/ImgUpload.js'
|
|
|
|
import { wife, wifeReg } from './character/AvatarWife.js'
|
|
|
|
import { getOriginalPicture } from './character/ProfileUtils.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-17 21:24:04 +00:00
|
|
|
|
2022-09-16 20:37:09 +00:00
|
|
|
app.reg('character', character, {
|
2022-09-30 12:20:04 +00:00
|
|
|
rule: /^#喵喵角色卡片$/,
|
|
|
|
check: checkCharacter,
|
2022-09-17 21:24:04 +00:00
|
|
|
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
|
|
|
// 查看当前角色
|
2022-08-24 01:07:06 +00:00
|
|
|
export async function character (e) {
|
2022-09-30 12:20:04 +00:00
|
|
|
if (!e.char) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return renderAvatar(e, e.char?.name)
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkCharacter (e) {
|
2022-07-30 21:06:00 +00:00
|
|
|
let msg = e.original_msg || e.msg
|
2022-10-01 18:33:08 +00:00
|
|
|
if (!msg || !/^#/.exec(msg)) {
|
2022-09-30 12:20:04 +00:00
|
|
|
return false
|
2022-03-27 11:24:06 +00:00
|
|
|
}
|
2022-11-12 21:35:46 +00:00
|
|
|
if (!Common.cfg('avatarCard')) {
|
|
|
|
return false
|
|
|
|
}
|
2022-07-23 20:32:10 +00:00
|
|
|
let uidRet = /[0-9]{9}/.exec(msg)
|
2022-06-04 21:29:24 +00:00
|
|
|
if (uidRet) {
|
2022-07-23 20:32:10 +00:00
|
|
|
e.uid = uidRet[0]
|
|
|
|
msg = msg.replace(uidRet[0], '')
|
2022-06-04 21:29:24 +00:00
|
|
|
}
|
2022-09-18 20:54:01 +00:00
|
|
|
let name = msg.replace(/#|老婆|老公|卡片/g, '').trim()
|
2022-04-29 21:54:41 +00:00
|
|
|
|
2022-12-27 20:01:22 +00:00
|
|
|
// cache gsCfg
|
|
|
|
Character.gsCfg = Character.gsCfg || e?.runtime?.gsCfg
|
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
let char = Character.get(name.trim())
|
2022-04-28 19:38:43 +00:00
|
|
|
|
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
|
|
|
}
|
2022-09-30 12:20:04 +00:00
|
|
|
|
|
|
|
e.msg = '#喵喵角色卡片'
|
|
|
|
e.char = char
|
|
|
|
return true
|
2022-04-28 20:50:58 +00:00
|
|
|
}
|