2023-03-07 17:52:11 +00:00
|
|
|
import { Cfg } from '#miao'
|
|
|
|
import { MysApi } from '#miao.models'
|
2024-05-21 18:05:37 +00:00
|
|
|
import { miaoPath } from '#miao.path'
|
2022-06-25 23:45:43 +00:00
|
|
|
|
|
|
|
/** 获取角色卡片的原图 */
|
2022-07-30 21:06:00 +00:00
|
|
|
export async function getOriginalPicture (e) {
|
|
|
|
let source
|
2023-07-20 00:31:09 +00:00
|
|
|
if (e.reply_id) {
|
|
|
|
source = { message_id: e.reply_id }
|
2022-06-25 23:45:43 +00:00
|
|
|
} else {
|
2023-07-20 00:31:09 +00:00
|
|
|
if (!e.hasReply && !e.source) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
// 引用的消息不是自己的消息
|
|
|
|
if (e.source.user_id !== e.self_id) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
// 获取原消息
|
|
|
|
if (e.group?.getChatHistory) {
|
|
|
|
source = (await e.group.getChatHistory(e.source.seq, 1)).pop()
|
|
|
|
} else if (e.friend?.getChatHistory) {
|
|
|
|
source = (await e.friend.getChatHistory(e.source.time, 1)).pop()
|
|
|
|
}
|
2024-08-08 05:40:57 +00:00
|
|
|
// 引用的不是纯图片
|
|
|
|
if (!(source?.message?.length === 1 && source?.message[0]?.type === 'image')) {
|
|
|
|
return false
|
|
|
|
}
|
2022-06-25 23:45:43 +00:00
|
|
|
}
|
2023-07-20 00:31:09 +00:00
|
|
|
let originalPic = Cfg.get('originalPic') * 1
|
2022-06-25 23:45:43 +00:00
|
|
|
if (source) {
|
2022-07-30 21:06:00 +00:00
|
|
|
let imgPath = await redis.get(`miao:original-picture:${source.message_id}`)
|
2022-06-25 23:45:43 +00:00
|
|
|
if (imgPath) {
|
2023-02-17 20:42:05 +00:00
|
|
|
try {
|
|
|
|
if (imgPath[0] === '{') {
|
|
|
|
imgPath = JSON.parse(imgPath)
|
|
|
|
} else {
|
|
|
|
imgPath = { img: imgPath, type: '' }
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
}
|
2023-03-21 19:03:01 +00:00
|
|
|
if (!e.isMaster) {
|
|
|
|
if (imgPath.type === 'character' && [2, 0].includes(originalPic)) {
|
|
|
|
e.reply('已禁止获取角色原图...')
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
if (imgPath.type === 'profile' && [1, 0].includes(originalPic)) {
|
|
|
|
e.reply('已禁止获取面板原图...')
|
|
|
|
return true
|
|
|
|
}
|
2023-02-17 20:42:05 +00:00
|
|
|
}
|
|
|
|
if (imgPath && imgPath.img) {
|
2024-05-21 18:05:37 +00:00
|
|
|
e.reply(segment.image(`file://${miaoPath}/resources/${decodeURIComponent(imgPath.img)}`), false, { recallMsg: 30 })
|
2023-02-17 20:42:05 +00:00
|
|
|
}
|
2022-07-30 21:06:00 +00:00
|
|
|
return true
|
2022-06-25 23:45:43 +00:00
|
|
|
}
|
2023-07-20 00:31:09 +00:00
|
|
|
// 对at错图像的增加嘲讽...
|
2024-05-21 18:05:37 +00:00
|
|
|
e.reply(segment.image(`file://${miaoPath}/resources/common/face/what.jpg`))
|
2023-07-20 00:31:09 +00:00
|
|
|
return false
|
2022-06-25 23:45:43 +00:00
|
|
|
}
|
2022-07-30 21:06:00 +00:00
|
|
|
e.reply('消息太过久远了,俺也忘了原图是啥了,下次早点来吧~')
|
2023-07-20 00:31:09 +00:00
|
|
|
return false
|
2022-06-25 23:45:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* #敌人等级 */
|
2022-07-30 21:06:00 +00:00
|
|
|
export async function enemyLv (e) {
|
2022-09-20 11:50:27 +00:00
|
|
|
let selfUser = await MysApi.initUser(e)
|
2022-06-25 23:45:43 +00:00
|
|
|
if (!selfUser || !e.msg) {
|
2022-07-30 21:06:00 +00:00
|
|
|
return true
|
2022-06-25 23:45:43 +00:00
|
|
|
}
|
2022-07-30 21:06:00 +00:00
|
|
|
let ret = /(敌人|怪物)等级\s*(\d{1,3})\s*$/.exec(e.msg)
|
2022-06-25 23:45:43 +00:00
|
|
|
if (ret && ret[2]) {
|
2022-07-30 21:06:00 +00:00
|
|
|
let lv = ret[2] * 1
|
|
|
|
await selfUser.setCfg('char.enemyLv', lv)
|
2024-10-01 13:38:53 +00:00
|
|
|
lv = await selfUser.getCfg('char.enemyLv', 103)
|
2022-07-30 21:06:00 +00:00
|
|
|
e.reply(`敌人等级已经设置为${lv}`)
|
|
|
|
return true
|
2022-06-25 23:45:43 +00:00
|
|
|
}
|
2022-07-30 21:06:00 +00:00
|
|
|
return true
|
|
|
|
}
|