-
Notifications
You must be signed in to change notification settings - Fork 0
/
lolicon.js
89 lines (81 loc) · 2.41 KB
/
lolicon.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import {
segment
} from 'icqq'
import plugin from '../../lib/plugins/plugin.js'
let msgsscr = false // 消息转发信息是否为bot,false为是,true为否
let selilo = 2 // 默认数量
const url = 'https://api.wdvipa.com/sj'
export class St extends plugin {
constructor () {
super({
name: 'lolicon',
dsc: 'st',
event: 'message',
priority: 1,
rule: [{
reg: '^原神((\\d+)|(.*))',
fnc: 'js'
}, {
reg: '^sst',
fnc: 'sst'
}]
})
}
// 获取图片并利用本文件makeForwardMsg函数制作转发消息
async js (e) {
let num = e.msg.match(/\d+/) || selilo
let dec = '已帮你整理好了'
let sule = `正在给你找图片啦~\n 数量${num}张获取中~`
let res
let msg
let msgList = []
await e.reply(sule, true, {
recallMsg: 0
})
for (let i = 0; i < [num]; i++) {
msg = `已获取图片第${i + 1}张`
res = await segment.image(url)
msgList.push(res)
console.log(msg)
}
let forwardMsg = await this.makeForwardMsg(dec, msgList) // 借助makeForwardMsg函数制作转发消息
await e.reply(forwardMsg) // 发送消息
}
// 制作转发消息(因为yunzai的制作转发消息函数传入值不包含描述项,所以重写函数并添加对应判断)
async makeForwardMsg (title, msg) {
let nickname =
msgsscr === false ? Bot.nickname : this.e.sender.card || this.e.user_id
let id =
msgsscr === false ? Bot.uin : this.e.user_id
if (this.e.isGroup) {
let info = await Bot.getGroupMemberInfo(this.e.group_id, Bot.uin)
nickname = info.nickname
}
let userInfo = {
nickname,
user_id: id
}
let forwardMsg = [
{
...userInfo,
message: title
},
{
...userInfo,
message: msg
}
]
/** 制作转发内容 */
if (this.e.isGroup) {
forwardMsg = await this.e.group.makeForwardMsg(forwardMsg)
} else {
forwardMsg = await this.e.friend.makeForwardMsg(forwardMsg)
}
/** 处理描述 */
forwardMsg.data = forwardMsg.data
.replace(/\n/g, '')
.replace(/<title color="#777777" size="26">(.+?)<\/title>/g, '___')
.replace(/___+/, `<title color="#777777" size="26">${title}</title>`)
return forwardMsg
}
}