Merge branch 'master' of github.com:yoimiya-kokomi/Miao-Yunzai
This commit is contained in:
commit
0b83e8d96b
|
@ -69,7 +69,6 @@ export class ledger extends plugin {
|
|||
if (!data) return
|
||||
|
||||
/** 生成图片 */
|
||||
let img = await puppeteer.screenshot(`${data.srtempFile}ledgerCount`, data)
|
||||
if (img) await this.reply(img)
|
||||
this.renderImg('genshin', `html/ledger/ledger-count-${data.game}`, data)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,12 +31,16 @@ export class add extends plugin {
|
|||
fnc: 'getText',
|
||||
log: false
|
||||
},
|
||||
{
|
||||
reg: '^#+(全局)?(?:查看|查询)(?:表情|词条)(.+)$',
|
||||
fnc: 'faceDetail'
|
||||
},
|
||||
{
|
||||
reg: '#(全局)?(表情|词条)(.*)',
|
||||
fnc: 'list'
|
||||
}
|
||||
]
|
||||
})
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
this.path = './data/textJson/'
|
||||
this.facePath = './data/face/'
|
||||
|
@ -246,16 +250,23 @@ export class add extends plugin {
|
|||
this.finish('addContext')
|
||||
|
||||
for (let i in message) {
|
||||
if (message[i].type == 'at') {
|
||||
if (message[i].type == "at") {
|
||||
if (message[i].qq == this.e.bot.uin) {
|
||||
this.e.reply('添加内容不能@机器人!')
|
||||
return
|
||||
this.e.reply("添加内容不能@机器人!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (message[i].type == 'file') {
|
||||
this.e.reply('添加错误:禁止添加文件')
|
||||
return
|
||||
if (message[i].type == "file") {
|
||||
this.e.reply("添加错误:禁止添加文件");
|
||||
return;
|
||||
}
|
||||
|
||||
// 保存用户信息用于追溯添加者
|
||||
message[i].from_user = {
|
||||
card: this.e.sender.card,
|
||||
nickname: this.e.sender.nickname,
|
||||
user_id: this.e.sender.user_id,
|
||||
};
|
||||
}
|
||||
|
||||
if (message.length == 1 && message[0].type == 'image') {
|
||||
|
@ -790,4 +801,89 @@ export class add extends plugin {
|
|||
|
||||
return msg
|
||||
}
|
||||
|
||||
async faceDetail () {
|
||||
if (!this.e.message) return false
|
||||
this.isGlobal = false
|
||||
await this.getGroupId()
|
||||
if (!this.group_id) return false
|
||||
let faceDetailReg = /^#+(全局)?(?:查看|查询)(?:表情|词条)(.+)$/
|
||||
let regGroup = faceDetailReg.exec(this.e.msg)
|
||||
let keyWord
|
||||
if (regGroup[1]) {
|
||||
this.isGlobal = true
|
||||
}
|
||||
keyWord = regGroup[2].trim()
|
||||
|
||||
if (keyWord === '') return
|
||||
|
||||
this.initTextArr()
|
||||
this.initGlobalTextArr()
|
||||
|
||||
let faces = textArr[this.group_id].get(keyWord) || []
|
||||
let globalfaces = textArr[this.e.bot.uin].get(keyWord) || []
|
||||
faces = [...faces, ...globalfaces]
|
||||
/**
|
||||
* faces example:
|
||||
* [
|
||||
[
|
||||
{
|
||||
"type": "text",
|
||||
"text": "口了",
|
||||
"from_user": {
|
||||
"card": 123,
|
||||
"nickname": "test",
|
||||
"user_id": 456
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"type": "text",
|
||||
"text": "口"
|
||||
}
|
||||
]
|
||||
]
|
||||
*/
|
||||
|
||||
if (lodash.isEmpty(faces)) {
|
||||
await this.e.reply(`表情${keyWord}不存在`)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// process faces into replyArr in type:
|
||||
let replyArr = []
|
||||
for (let i = 0; i < faces.length; i++) {
|
||||
let face = faces[i]
|
||||
let faceItem = face[0]
|
||||
let fromUser = faceItem?.from_user
|
||||
if (fromUser) {
|
||||
fromUser = `添加者: ${fromUser.card}(${fromUser.nickname})[${fromUser.user_id}]`
|
||||
} else {
|
||||
fromUser = '未知'
|
||||
}
|
||||
let faceContent
|
||||
console.log(faceItem)
|
||||
if (faceItem.type === 'image') {
|
||||
// face is an image
|
||||
let tmp = segment.image(faceItem.local)
|
||||
tmp.asface = faceItem.asface
|
||||
faceContent = tmp
|
||||
replyArr.push(`${i + 1}、${fromUser}`)
|
||||
replyArr.push(faceContent)
|
||||
} else {
|
||||
faceContent = `${faceItem.text}`
|
||||
replyArr.push(`${i + 1}、${fromUser}: ` + faceContent)
|
||||
}
|
||||
}
|
||||
|
||||
if (lodash.isEmpty(replyArr)) {
|
||||
return
|
||||
}
|
||||
|
||||
let forwardMsg = await common.makeForwardMsg(this.e, replyArr, `表情${keyWord}详情`)
|
||||
|
||||
this.e.reply(forwardMsg)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue