2022-07-23 20:32:10 +00:00
|
|
|
import { Common, Cfg } from '../components/index.js'
|
|
|
|
import { renderAvatar } from './character/avatar-card.js'
|
2022-08-05 22:12:57 +00:00
|
|
|
import { getTargetUid, getProfile, profileHelp, getProfileAll, inputProfile } from './character/profile-common.js'
|
2022-07-23 20:32:10 +00:00
|
|
|
import { profileArtis } from './character/profile-artis.js'
|
|
|
|
import { renderProfile } from './character/profile-detail.js'
|
2022-08-18 10:13:42 +00:00
|
|
|
import { Character } from '../models/index.js'
|
2022-08-05 22:12:57 +00:00
|
|
|
//
|
|
|
|
export { getProfileAll, getProfile, profileHelp }
|
2022-07-23 20:32:10 +00:00
|
|
|
|
|
|
|
export { enemyLv, getOriginalPicture } from './character/utils.js'
|
2022-03-26 08:21:44 +00:00
|
|
|
|
2022-06-27 20:46:49 +00:00
|
|
|
// 角色图像上传
|
2022-07-23 20:32:10 +00:00
|
|
|
export { uploadCharacterImg } from './character/character-img-upload.js'
|
2022-06-27 20:46:49 +00:00
|
|
|
|
2022-06-25 23:45:43 +00:00
|
|
|
// 圣遗物列表
|
2022-07-23 20:32:10 +00:00
|
|
|
export { profileArtisList } from './character/profile-artis.js'
|
2022-04-03 11:14:38 +00:00
|
|
|
|
2022-06-25 23:45:43 +00:00
|
|
|
// 老婆
|
2022-07-23 20:32:10 +00:00
|
|
|
export { wife, pokeWife, wifeReg } from './character/avatar-wife.js'
|
2022-03-26 08:21:44 +00:00
|
|
|
|
2022-08-05 22:12:57 +00:00
|
|
|
// 面板角色列表
|
|
|
|
export { profileList } from './character/profile-list.js'
|
|
|
|
|
2022-08-06 22:36:05 +00:00
|
|
|
// 面板练度统计
|
|
|
|
export { profileStat } from './character/profile-stat.js'
|
|
|
|
|
2022-03-26 21:34:33 +00:00
|
|
|
// 查看当前角色
|
2022-08-24 01:07:06 +00:00
|
|
|
export async function character (e) {
|
2022-07-30 21:06:00 +00:00
|
|
|
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-03-27 11:24:06 +00:00
|
|
|
}
|
2022-04-09 21:33:21 +00:00
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
let mode = 'card'
|
|
|
|
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-07-23 20:32:10 +00:00
|
|
|
let name = msg.replace(/#|老婆|老公/g, '').trim()
|
|
|
|
msg = msg.replace('面版', '面板')
|
|
|
|
let dmgRet = /伤害(\d?)$/.exec(name);
|
|
|
|
let dmgIdx = 0
|
2022-06-14 22:07:24 +00:00
|
|
|
if (/(详情|详细|面板|面版)\s*$/.test(msg) && !/更新|录入|输入/.test(msg)) {
|
2022-07-23 20:32:10 +00:00
|
|
|
mode = 'profile'
|
|
|
|
name = name.replace(/(详情|详细|面板)/, '').trim()
|
2022-04-30 21:06:17 +00:00
|
|
|
} else if (dmgRet) {
|
2022-07-23 20:32:10 +00:00
|
|
|
mode = 'dmg'
|
|
|
|
name = name.replace(/伤害[0-5]?/, '').trim()
|
2022-04-30 21:06:17 +00:00
|
|
|
if (dmgRet[1]) {
|
2022-07-23 20:32:10 +00:00
|
|
|
dmgIdx = dmgRet[1] * 1
|
2022-04-30 21:06:17 +00:00
|
|
|
}
|
2022-05-31 21:16:10 +00:00
|
|
|
} else if (/(详情|详细|面板)更新$/.test(msg) || (/更新/.test(msg) && /(详情|详细|面板)$/.test(msg))) {
|
2022-07-23 20:32:10 +00:00
|
|
|
mode = 'refresh'
|
|
|
|
name = name.replace(/详情|详细|面板|更新/g, '').trim()
|
2022-05-31 21:16:10 +00:00
|
|
|
} else if (/(录入|输入)/.test(msg) && /(详情|详细|面板)/.test(msg)) {
|
2022-07-23 20:32:10 +00:00
|
|
|
mode = 'input'
|
|
|
|
let nameRet = /(?:录入|输入)(.+)(?:面板|详细|详情|数据)+/.exec(name)
|
2022-05-31 21:16:10 +00:00
|
|
|
if (nameRet) {
|
2022-07-23 20:32:10 +00:00
|
|
|
name = nameRet[1]
|
|
|
|
e.inputData = msg.replace(nameRet[0], '')
|
2022-05-31 21:16:10 +00:00
|
|
|
}
|
2022-07-23 20:32:10 +00:00
|
|
|
name = name.replace(/录入|输入|详情|详细|面板|数据|[0-9]|\.|\+/g, '').trim()
|
2022-06-25 23:45:43 +00:00
|
|
|
} else if (/圣遗物/.test(msg)) {
|
2022-07-23 20:32:10 +00:00
|
|
|
mode = 'artis'
|
|
|
|
name = name.replace('圣遗物', '').trim()
|
2022-04-14 20:53:22 +00:00
|
|
|
}
|
2022-04-29 21:54:41 +00:00
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
if (mode === 'card' && Common.isDisable(e, 'char.char')) {
|
|
|
|
return
|
2022-05-22 13:10:10 +00:00
|
|
|
}
|
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
if (mode !== 'card' && !e.isMaster) {
|
|
|
|
if (Common.isDisable(e, 'char.profile')) {
|
2022-05-28 21:18:13 +00:00
|
|
|
// 面板开关关闭
|
2022-07-23 20:32:10 +00:00
|
|
|
return
|
2022-05-28 21:18:13 +00:00
|
|
|
}
|
|
|
|
if (e.isPrivate) {
|
2022-07-23 20:32:10 +00:00
|
|
|
if ((e.sub_type === 'friend' && Cfg.get('profile.friend.status') === false) ||
|
|
|
|
(e.sub_type === 'group' && Cfg.get('profile.stranger.status') === false)) {
|
|
|
|
return
|
2022-05-28 21:18:13 +00:00
|
|
|
}
|
|
|
|
} else if (e.isGroup) {
|
2022-07-23 20:32:10 +00:00
|
|
|
let groupCfg = Cfg.get(`profile.groups.群${e.group_id}.status`)
|
|
|
|
if (groupCfg === false || (groupCfg !== true && Cfg.get('profile.group.status') === false)) {
|
|
|
|
return
|
2022-05-28 21:18:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-04-07 20:51:47 +00:00
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
if (mode === 'card') {
|
2022-08-24 01:07:06 +00:00
|
|
|
return renderAvatar(e, char.name)
|
2022-06-25 23:45:43 +00:00
|
|
|
}
|
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
let uid = await getTargetUid(e)
|
2022-07-12 21:53:20 +00:00
|
|
|
if (!uid) {
|
2022-07-23 20:32:10 +00:00
|
|
|
return true
|
2022-07-12 21:53:20 +00:00
|
|
|
}
|
2022-07-23 20:32:10 +00:00
|
|
|
e.uid = uid
|
|
|
|
e.avatar = char.id
|
2022-04-28 19:38:43 +00:00
|
|
|
|
2022-06-29 23:05:31 +00:00
|
|
|
if (char.isCustom) {
|
2022-07-23 20:32:10 +00:00
|
|
|
e.reply('自定义角色暂不支持此功能')
|
|
|
|
return true
|
2022-06-29 23:05:31 +00:00
|
|
|
}
|
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
if (mode === 'profile' || mode === 'dmg') {
|
2022-08-24 01:07:06 +00:00
|
|
|
return renderProfile(e, char, mode, { dmgIdx })
|
2022-08-05 22:12:57 +00:00
|
|
|
} else if (mode === 'input') {
|
|
|
|
await inputProfile(e, mode)
|
|
|
|
return true
|
|
|
|
} else if (mode === 'refresh') {
|
2022-08-24 01:07:06 +00:00
|
|
|
await getProfile(e)
|
2022-07-23 20:32:10 +00:00
|
|
|
return true
|
|
|
|
} else if (mode === 'artis') {
|
2022-08-24 01:07:06 +00:00
|
|
|
return profileArtis(e)
|
2022-04-24 19:22:27 +00:00
|
|
|
}
|
2022-07-23 20:32:10 +00:00
|
|
|
return true
|
2022-04-28 20:50:58 +00:00
|
|
|
}
|