细节优化
This commit is contained in:
parent
92b53f9ac8
commit
0b33fc9153
40
lib/bot.js
40
lib/bot.js
|
@ -46,25 +46,25 @@ export default class Yunzai extends EventEmitter {
|
||||||
|
|
||||||
getFriendArray() {
|
getFriendArray() {
|
||||||
const array = []
|
const array = []
|
||||||
for (const i of this.uin)
|
for (const bot_id of this.uin)
|
||||||
this[i].fl?.forEach(value =>
|
for (const i of this[bot_id].fl || [])
|
||||||
array.push({ ...value, bot_id: i }))
|
array.push({ ...i[1], bot_id })
|
||||||
return array
|
return array
|
||||||
}
|
}
|
||||||
|
|
||||||
getFriendList() {
|
getFriendList() {
|
||||||
const array = []
|
const array = []
|
||||||
for (const i of this.uin)
|
for (const bot_id of this.uin)
|
||||||
this[i].fl?.forEach((value, key) =>
|
for (const i of this[bot_id].fl || [])
|
||||||
array.push(key))
|
array.push(i[0])
|
||||||
return array
|
return array
|
||||||
}
|
}
|
||||||
|
|
||||||
getFriendMap() {
|
getFriendMap() {
|
||||||
const map = new Map()
|
const map = new Map()
|
||||||
for (const i of this.uin)
|
for (const bot_id of this.uin)
|
||||||
this[i].fl?.forEach((value, key) =>
|
for (const i of this[bot_id].fl || [])
|
||||||
map.set(key, { ...value, bot_id: i }))
|
map.set(i[0], { ...i[1], bot_id })
|
||||||
return map
|
return map
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,25 +74,25 @@ export default class Yunzai extends EventEmitter {
|
||||||
|
|
||||||
getGroupArray() {
|
getGroupArray() {
|
||||||
const array = []
|
const array = []
|
||||||
for (const i of this.uin)
|
for (const bot_id of this.uin)
|
||||||
this[i].gl?.forEach(value =>
|
for (const i of this[bot_id].gl || [])
|
||||||
array.push({ ...value, bot_id: i }))
|
array.push({ ...i[1], bot_id })
|
||||||
return array
|
return array
|
||||||
}
|
}
|
||||||
|
|
||||||
getGroupList() {
|
getGroupList() {
|
||||||
const array = []
|
const array = []
|
||||||
for (const i of this.uin)
|
for (const bot_id of this.uin)
|
||||||
this[i].gl?.forEach((value, key) =>
|
for (const i of this[bot_id].gl || [])
|
||||||
array.push(key))
|
array.push(i[0])
|
||||||
return array
|
return array
|
||||||
}
|
}
|
||||||
|
|
||||||
getGroupMap() {
|
getGroupMap() {
|
||||||
const map = new Map()
|
const map = new Map()
|
||||||
for (const i of this.uin)
|
for (const bot_id of this.uin)
|
||||||
this[i].gl?.forEach((value, key) =>
|
for (const i of this[bot_id].gl || [])
|
||||||
map.set(key, { ...value, bot_id: i }))
|
map.set(i[0], { ...i[1], bot_id })
|
||||||
return map
|
return map
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,8 +195,8 @@ export default class Yunzai extends EventEmitter {
|
||||||
|
|
||||||
async sendForwardMsg(send, msg) {
|
async sendForwardMsg(send, msg) {
|
||||||
const messages = []
|
const messages = []
|
||||||
for (const i of msg)
|
for (const { message } of msg)
|
||||||
messages.push(await send(i.message))
|
messages.push(await send(message))
|
||||||
return messages
|
return messages
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -58,8 +58,8 @@ function mkdirs (dirname) {
|
||||||
*/
|
*/
|
||||||
function makeForwardMsg (e, msg = []) {
|
function makeForwardMsg (e, msg = []) {
|
||||||
const forwardMsg = []
|
const forwardMsg = []
|
||||||
for (const i of msg)
|
for (const message of msg)
|
||||||
forwardMsg.push({ message: i })
|
forwardMsg.push({ message })
|
||||||
|
|
||||||
if (e?.group?.makeForwardMsg)
|
if (e?.group?.makeForwardMsg)
|
||||||
return e.group.makeForwardMsg(forwardMsg)
|
return e.group.makeForwardMsg(forwardMsg)
|
||||||
|
|
|
@ -154,8 +154,8 @@ Bot.adapter.push(new class ComWeChatAdapter {
|
||||||
|
|
||||||
async getFriendList(data) {
|
async getFriendList(data) {
|
||||||
const array = []
|
const array = []
|
||||||
for (const i of (await this.getFriendArray(data)))
|
for (const { user_id } of (await this.getFriendArray(data)))
|
||||||
array.push(i.user_id)
|
array.push(user_id)
|
||||||
return array
|
return array
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,8 +178,8 @@ Bot.adapter.push(new class ComWeChatAdapter {
|
||||||
|
|
||||||
async getGroupList(data) {
|
async getGroupList(data) {
|
||||||
const array = []
|
const array = []
|
||||||
for (const i of (await this.getGroupArray(data)))
|
for (const { group_id } of (await this.getGroupArray(data)))
|
||||||
array.push(i.group_id)
|
array.push(group_id)
|
||||||
return array
|
return array
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,8 +204,8 @@ Bot.adapter.push(new class ComWeChatAdapter {
|
||||||
|
|
||||||
async getMemberList(data) {
|
async getMemberList(data) {
|
||||||
const array = []
|
const array = []
|
||||||
for (const i of (await this.getMemberArray(data)))
|
for (const { user_id } of (await this.getMemberArray(data)))
|
||||||
array.push(i.user_id)
|
array.push(user_id)
|
||||||
return array
|
return array
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,10 +67,13 @@ Bot.adapter.push(new class GSUIDCoreAdapter {
|
||||||
case "reply":
|
case "reply":
|
||||||
i.data = i.data.id
|
i.data = i.data.id
|
||||||
break
|
break
|
||||||
case "node":
|
case "node": {
|
||||||
for (const n in i.data)
|
const array = []
|
||||||
i.data[n] = this.makeMsg(i.data[n])
|
for (const { message } of i.data)
|
||||||
default:
|
array.push(...this.makeMsg(message))
|
||||||
|
i.data = array
|
||||||
|
break
|
||||||
|
} default:
|
||||||
i = { type: "text", data: JSON.stringify(i) }
|
i = { type: "text", data: JSON.stringify(i) }
|
||||||
}
|
}
|
||||||
msgs.push(i)
|
msgs.push(i)
|
||||||
|
|
|
@ -148,8 +148,8 @@ Bot.adapter.push(new class gocqhttpAdapter {
|
||||||
|
|
||||||
async getFriendList(data) {
|
async getFriendList(data) {
|
||||||
const array = []
|
const array = []
|
||||||
for (const i of (await this.getFriendArray(data)))
|
for (const { user_id } of (await this.getFriendArray(data)))
|
||||||
array.push(i.user_id)
|
array.push(user_id)
|
||||||
return array
|
return array
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,8 +184,8 @@ Bot.adapter.push(new class gocqhttpAdapter {
|
||||||
|
|
||||||
async getGroupList(data) {
|
async getGroupList(data) {
|
||||||
const array = []
|
const array = []
|
||||||
for (const i of (await this.getGroupArray(data)))
|
for (const { group_id } of (await this.getGroupArray(data)))
|
||||||
array.push(i.group_id)
|
array.push(group_id)
|
||||||
return array
|
return array
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,8 +210,8 @@ Bot.adapter.push(new class gocqhttpAdapter {
|
||||||
|
|
||||||
async getMemberList(data) {
|
async getMemberList(data) {
|
||||||
const array = []
|
const array = []
|
||||||
for (const i of (await this.getMemberArray(data)))
|
for (const { user_id } of (await this.getMemberArray(data)))
|
||||||
array.push(i.user_id)
|
array.push(user_id)
|
||||||
return array
|
return array
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,8 +274,8 @@ Bot.adapter.push(new class gocqhttpAdapter {
|
||||||
|
|
||||||
async getGuildMemberList(data) {
|
async getGuildMemberList(data) {
|
||||||
const array = []
|
const array = []
|
||||||
for (const i of (await this.getGuildMemberArray(data)))
|
for (const { user_id } of (await this.getGuildMemberArray(data)))
|
||||||
array.push(i.user_id)
|
array.push(user_id)
|
||||||
return array.push
|
return array.push
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue