2022-12-03 19:45:50 +00:00
|
|
|
import { Common, App, Data } from '../components/index.js'
|
2022-09-17 21:24:04 +00:00
|
|
|
import { Character } from '../models/index.js'
|
2023-01-17 18:40:17 +00:00
|
|
|
import { getTargetUid, getProfile, profileHelp } from './profile/ProfileCommon.js'
|
|
|
|
import { profileArtis, profileArtisList } from './profile/ProfileArtis.js'
|
|
|
|
import { renderProfile } from './profile/ProfileDetail.js'
|
|
|
|
import { profileStat } from './profile/ProfileStat.js'
|
|
|
|
import { profileList } from './profile/ProfileList.js'
|
2022-12-03 21:17:07 +00:00
|
|
|
import { uploadCharacterImg, delProfileImg, profileImgList } from './character/ImgUpload.js'
|
2023-01-17 18:40:17 +00:00
|
|
|
import { enemyLv } from './profile/ProfileUtils.js'
|
2022-11-26 08:12:32 +00:00
|
|
|
import ProfileChange from './profile/ProfileChange.js'
|
2023-01-17 18:40:17 +00:00
|
|
|
import { groupRank, resetRank, refreshRank, manageRank } from './profile/ProfileRank.js'
|
2022-09-17 21:24:04 +00:00
|
|
|
|
|
|
|
let app = App.init({
|
|
|
|
id: 'profile',
|
|
|
|
name: '角色面板'
|
|
|
|
})
|
|
|
|
app.reg('profile-detail', profileDetail, {
|
2022-11-26 21:51:36 +00:00
|
|
|
rule: /^#*([^#]+)\s*(详细|详情|面板|面版|圣遗物|伤害[1-7]?)\s*(\d{9})*(.*[换变改].*)?$/,
|
2022-09-17 21:24:04 +00:00
|
|
|
name: '角色面板'
|
|
|
|
})
|
2022-11-26 21:51:36 +00:00
|
|
|
app.reg('profile-change', profileDetail, {
|
|
|
|
rule: /^#.+换.+$/,
|
|
|
|
name: '角色面板计算'
|
|
|
|
})
|
2022-09-17 21:24:04 +00:00
|
|
|
|
2022-11-10 20:56:15 +00:00
|
|
|
app.reg('group-profile', groupRank, {
|
|
|
|
rule: /^#(群|群内)?(排名|排行)?(最强|最高|最高分|最牛|第一)+.+/,
|
2022-11-08 22:04:08 +00:00
|
|
|
name: '群内最强'
|
|
|
|
})
|
|
|
|
|
2022-11-09 19:48:13 +00:00
|
|
|
app.reg('reset-rank', resetRank, {
|
|
|
|
rule: /^#(重置|重设)(.*)(排名|排行)$/,
|
|
|
|
name: '重置排名'
|
|
|
|
})
|
2022-11-11 21:57:13 +00:00
|
|
|
|
2022-11-15 20:07:21 +00:00
|
|
|
app.reg('refresh-rank', refreshRank, {
|
2022-11-15 20:58:19 +00:00
|
|
|
rule: /^#(刷新|更新|重新加载)(群内|群|全部)*(排名|排行)$/,
|
2022-11-15 20:07:21 +00:00
|
|
|
name: '重置排名'
|
|
|
|
})
|
|
|
|
|
2023-01-17 18:40:17 +00:00
|
|
|
app.reg('manage-rank', manageRank, {
|
|
|
|
rule: /^#(开启|打开|启用|关闭|禁用)(群内|群|全部)*(排名|排行)$/,
|
|
|
|
name: '打开关闭'
|
|
|
|
})
|
|
|
|
|
2022-11-10 20:56:15 +00:00
|
|
|
app.reg('rank-list', groupRank, {
|
2022-11-18 01:38:55 +00:00
|
|
|
rule: /^#(群|群内)?.+(排名|排行)(榜)?$/,
|
2022-11-10 20:56:15 +00:00
|
|
|
name: '面板排名榜'
|
|
|
|
})
|
2022-11-11 21:57:13 +00:00
|
|
|
|
2022-09-17 21:24:04 +00:00
|
|
|
app.reg('artis-list', profileArtisList, {
|
|
|
|
rule: /^#圣遗物列表\s*(\d{9})?$/,
|
|
|
|
name: '面板圣遗物列表'
|
|
|
|
})
|
|
|
|
|
|
|
|
app.reg('profile-list', profileList, {
|
|
|
|
rule: /^#(面板角色|角色面板|面板)(列表)?\s*(\d{9})?$/,
|
|
|
|
name: '面板角色列表',
|
|
|
|
desc: '查看当前已获取面板数据的角色列表'
|
|
|
|
})
|
|
|
|
|
|
|
|
app.reg('profile-stat', profileStat, {
|
2023-02-03 15:05:43 +00:00
|
|
|
rule: /^#(面板|喵喵|角色|武器|天赋|技能|圣遗物)?练度统计$/,
|
2022-09-17 21:24:04 +00:00
|
|
|
name: '面板练度统计$'
|
|
|
|
})
|
|
|
|
|
|
|
|
app.reg('profile-help', profileHelp, {
|
2022-11-27 05:36:51 +00:00
|
|
|
rule: /^#(角色|换|更换)?面[板版]帮助$/,
|
2022-09-17 21:24:04 +00:00
|
|
|
name: '角色面板帮助'
|
|
|
|
})
|
|
|
|
|
|
|
|
app.reg('enemy-lv', enemyLv, {
|
|
|
|
rule: /^#(敌人|怪物)等级\s*\d{1,3}\s*$/,
|
|
|
|
describe: '【#角色】 设置伤害计算中目标敌人的等级'
|
|
|
|
})
|
|
|
|
|
|
|
|
app.reg('profile-refresh', getProfile, {
|
|
|
|
rule: /^#(全部面板更新|更新全部面板|获取游戏角色详情|更新面板|面板更新)\s*(\d{9})?$/,
|
|
|
|
describe: '【#角色】 获取游戏橱窗详情数据'
|
|
|
|
})
|
|
|
|
|
2022-12-03 19:45:50 +00:00
|
|
|
app.reg('upload-img', uploadCharacterImg, {
|
2022-12-03 21:17:07 +00:00
|
|
|
rule: /^#?\s*(?:上传|添加)(.+)(?:面板图)\s*$/,
|
2022-12-03 19:45:50 +00:00
|
|
|
describe: '【#上传刻晴面板图】 上传角色面板图'
|
|
|
|
})
|
2022-12-03 21:17:07 +00:00
|
|
|
app.reg('del-profile', delProfileImg, {
|
|
|
|
rule: /^#?\s*(?:移除|清除|删除)(.+)(?:面板图)(\d){1,}\s*$/,
|
2022-12-03 19:45:50 +00:00
|
|
|
describe: '【#删除刻晴面板图1】 删除指定角色面板图(序号)'
|
|
|
|
})
|
2022-12-03 21:17:07 +00:00
|
|
|
app.reg('profile-img-list', profileImgList, {
|
|
|
|
rule: /^#?\s*(.+)(?:面板图列表)\s*$/,
|
2022-12-03 19:45:50 +00:00
|
|
|
describe: '【#刻晴面板图列表】 删除指定角色面板图(序号)'
|
|
|
|
})
|
2022-12-03 21:17:07 +00:00
|
|
|
/**
|
|
|
|
app.reg('del-uidflie', delProfile, {
|
|
|
|
rule: /^#?\s*(?:移除|清除|删除)面板数据$/,
|
2022-12-03 19:45:50 +00:00
|
|
|
describe: '【#删除面板数据】 删除面板数据'
|
|
|
|
})
|
2022-12-03 21:17:07 +00:00
|
|
|
*/
|
2022-09-17 21:24:04 +00:00
|
|
|
|
2022-12-03 19:45:50 +00:00
|
|
|
export default app
|
2022-12-03 21:17:07 +00:00
|
|
|
|
|
|
|
export async function delProfile (e) {
|
2022-12-03 19:45:50 +00:00
|
|
|
let uid = await getTargetUid(e)
|
|
|
|
if (!uid) {
|
|
|
|
return true
|
|
|
|
}
|
2022-12-03 21:17:07 +00:00
|
|
|
if (Data.delfile(`data/UserData/${uid}.json`)) {
|
2022-12-03 19:45:50 +00:00
|
|
|
e.reply(`uid:${uid}缓存面板数据已删除~`)
|
|
|
|
}
|
2022-12-03 21:17:07 +00:00
|
|
|
return true
|
2022-12-03 19:45:50 +00:00
|
|
|
}
|
2022-12-03 21:17:07 +00:00
|
|
|
|
2022-09-17 21:24:04 +00:00
|
|
|
// 查看当前角色
|
2022-12-03 21:17:07 +00:00
|
|
|
export async function profileDetail (e) {
|
2022-09-17 21:24:04 +00:00
|
|
|
let msg = e.original_msg || e.msg
|
|
|
|
if (!msg) {
|
2022-09-30 12:20:04 +00:00
|
|
|
return false
|
2022-09-17 21:24:04 +00:00
|
|
|
}
|
2022-11-26 21:51:36 +00:00
|
|
|
if (!/详细|详情|面板|面版|圣遗物|伤害|换/.test(msg)) {
|
2022-11-12 21:35:46 +00:00
|
|
|
return false
|
|
|
|
}
|
2022-09-17 21:24:04 +00:00
|
|
|
let mode = 'profile'
|
2022-11-26 08:12:32 +00:00
|
|
|
let profileChange = false
|
|
|
|
let changeMsg = msg
|
|
|
|
let pc = ProfileChange.matchMsg(msg)
|
|
|
|
if (pc && pc.char && pc.change) {
|
|
|
|
e.uid = pc.uid || e.runtime.uid
|
|
|
|
profileChange = ProfileChange.getProfile(e.uid, pc.char, pc.change)
|
|
|
|
if (profileChange && profileChange.char) {
|
|
|
|
msg = `#${profileChange.char?.name}${pc.mode || '面板'}`
|
|
|
|
e._profile = profileChange
|
|
|
|
e._profileMsg = changeMsg
|
|
|
|
}
|
|
|
|
}
|
2022-09-17 21:24:04 +00:00
|
|
|
let uidRet = /[0-9]{9}/.exec(msg)
|
|
|
|
if (uidRet) {
|
|
|
|
e.uid = uidRet[0]
|
|
|
|
msg = msg.replace(uidRet[0], '')
|
|
|
|
}
|
2022-11-12 21:35:46 +00:00
|
|
|
|
2022-09-17 21:24:04 +00:00
|
|
|
let name = msg.replace(/#|老婆|老公/g, '').trim()
|
|
|
|
msg = msg.replace('面版', '面板')
|
|
|
|
let dmgRet = /伤害(\d?)$/.exec(name)
|
|
|
|
let dmgIdx = 0
|
2022-11-08 22:04:08 +00:00
|
|
|
if (/(最强|最高|最高分|最牛|第一)/.test(msg)) {
|
|
|
|
mode = /(分|圣遗物|评分|ACE)/.test(msg) ? 'rank-mark' : 'rank-dmg'
|
|
|
|
name = name.replace(/(最强|最高分|第一|最高|最牛|圣遗物|评分|群)/g, '')
|
|
|
|
}
|
2022-09-17 21:24:04 +00:00
|
|
|
if (/(详情|详细|面板|面版)\s*$/.test(msg) && !/更新|录入|输入/.test(msg)) {
|
|
|
|
mode = 'profile'
|
|
|
|
name = name.replace(/(详情|详细|面板)/, '').trim()
|
|
|
|
} else if (dmgRet) {
|
|
|
|
mode = 'dmg'
|
|
|
|
name = name.replace(/伤害[0-5]?/, '').trim()
|
|
|
|
if (dmgRet[1]) {
|
|
|
|
dmgIdx = dmgRet[1] * 1
|
|
|
|
}
|
|
|
|
} else if (/(详情|详细|面板)更新$/.test(msg) || (/更新/.test(msg) && /(详情|详细|面板)$/.test(msg))) {
|
|
|
|
mode = 'refresh'
|
|
|
|
name = name.replace(/详情|详细|面板|更新/g, '').trim()
|
|
|
|
} else if (/圣遗物/.test(msg)) {
|
|
|
|
mode = 'artis'
|
|
|
|
name = name.replace('圣遗物', '').trim()
|
|
|
|
}
|
2022-11-12 21:35:46 +00:00
|
|
|
if (!Common.cfg('avatarProfile')) {
|
|
|
|
// 面板开关关闭
|
|
|
|
return false
|
2022-09-17 21:24:04 +00:00
|
|
|
}
|
|
|
|
let char = Character.get(name.trim())
|
|
|
|
if (!char) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2022-11-26 08:12:32 +00:00
|
|
|
let uid = e.uid || await getTargetUid(e)
|
2022-09-17 21:24:04 +00:00
|
|
|
if (!uid) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
e.uid = uid
|
|
|
|
e.avatar = char.id
|
|
|
|
|
|
|
|
if (char.isCustom) {
|
|
|
|
e.reply('自定义角色暂不支持此功能')
|
|
|
|
return true
|
|
|
|
}
|
2022-11-26 08:12:32 +00:00
|
|
|
if (!char.isRelease && !profileChange) {
|
2022-09-30 13:02:24 +00:00
|
|
|
e.reply('角色尚未实装')
|
|
|
|
return true
|
|
|
|
}
|
2022-09-17 21:24:04 +00:00
|
|
|
|
|
|
|
if (mode === 'profile' || mode === 'dmg') {
|
|
|
|
return renderProfile(e, char, mode, { dmgIdx })
|
|
|
|
} else if (mode === 'refresh') {
|
|
|
|
await getProfile(e)
|
|
|
|
return true
|
|
|
|
} else if (mode === 'artis') {
|
|
|
|
return profileArtis(e)
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|