mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-29 02:27:26 +00:00
3a2c672aed
* `#刻晴排行` 命令会触发排行更新,防止部分排行错位 * `#喵喵设置` 部分配置项及功能改进 * 其余一些已知问题修正及改进
69 lines
1.6 KiB
JavaScript
69 lines
1.6 KiB
JavaScript
import { Common, App } from '../components/index.js'
|
|
import { Character } from '../models/index.js'
|
|
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'
|
|
|
|
let app = App.init({
|
|
id: 'character',
|
|
name: '角色查询'
|
|
})
|
|
|
|
app.reg('character', character, {
|
|
rule: /^#喵喵角色卡片$/,
|
|
check: checkCharacter,
|
|
name: '角色卡片'
|
|
})
|
|
|
|
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
|
|
|
|
// 查看当前角色
|
|
export async function character (e) {
|
|
if (!e.char) {
|
|
return false
|
|
}
|
|
return renderAvatar(e, e.char?.name)
|
|
}
|
|
|
|
function checkCharacter (e) {
|
|
let msg = e.original_msg || e.msg
|
|
if (!msg || !/^#/.exec(msg)) {
|
|
return false
|
|
}
|
|
if (!Common.cfg('avatarCard')) {
|
|
return false
|
|
}
|
|
let uidRet = /[0-9]{9}/.exec(msg)
|
|
if (uidRet) {
|
|
e.uid = uidRet[0]
|
|
msg = msg.replace(uidRet[0], '')
|
|
}
|
|
let name = msg.replace(/#|老婆|老公|卡片/g, '').trim()
|
|
|
|
let char = Character.get(name.trim())
|
|
|
|
if (!char) {
|
|
return false
|
|
}
|
|
|
|
e.msg = '#喵喵角色卡片'
|
|
e.char = char
|
|
return true
|
|
}
|