细节优化
This commit is contained in:
parent
6e515e3d15
commit
7492ae49a1
|
@ -164,10 +164,9 @@ Bot.adapter.push(new class ComWeChatAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
async getFriendMap(data) {
|
async getFriendMap(data) {
|
||||||
const map = new Map()
|
|
||||||
for (const i of (await this.getFriendArray(data)))
|
for (const i of (await this.getFriendArray(data)))
|
||||||
map.set(i.user_id, i)
|
Bot[data.self_id].fl.set(i.user_id, i)
|
||||||
return map
|
return Bot[data.self_id].fl
|
||||||
}
|
}
|
||||||
|
|
||||||
getFriendInfo(data) {
|
getFriendInfo(data) {
|
||||||
|
@ -188,10 +187,9 @@ Bot.adapter.push(new class ComWeChatAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGroupMap(data) {
|
async getGroupMap(data) {
|
||||||
const map = new Map()
|
|
||||||
for (const i of (await this.getGroupArray(data)))
|
for (const i of (await this.getGroupArray(data)))
|
||||||
map.set(i.group_id, i)
|
Bot[data.self_id].gl.set(i.group_id, i)
|
||||||
return map
|
return Bot[data.self_id].gl
|
||||||
}
|
}
|
||||||
|
|
||||||
getGroupInfo(data) {
|
getGroupInfo(data) {
|
||||||
|
@ -298,12 +296,18 @@ Bot.adapter.push(new class ComWeChatAdapter {
|
||||||
sendApi: data.sendApi,
|
sendApi: data.sendApi,
|
||||||
stat: { ...data.status, start_time: data.time },
|
stat: { ...data.status, start_time: data.time },
|
||||||
|
|
||||||
|
info: {},
|
||||||
|
get uin() { return this.info.user_id },
|
||||||
|
get nickname() { return this.info.user_name },
|
||||||
|
get avatar() { return this.info["wx.avatar"] },
|
||||||
|
|
||||||
pickUser: user_id => this.pickFriend(data, user_id),
|
pickUser: user_id => this.pickFriend(data, user_id),
|
||||||
pickFriend: user_id => this.pickFriend(data, user_id),
|
pickFriend: user_id => this.pickFriend(data, user_id),
|
||||||
|
|
||||||
getFriendArray: () => this.getFriendArray(data),
|
getFriendArray: () => this.getFriendArray(data),
|
||||||
getFriendList: () => this.getFriendList(data),
|
getFriendList: () => this.getFriendList(data),
|
||||||
getFriendMap: () => this.getFriendMap(data),
|
getFriendMap: () => this.getFriendMap(data),
|
||||||
|
fl: new Map(),
|
||||||
|
|
||||||
pickMember: (group_id, user_id) => this.pickMember(data, group_id, user_id),
|
pickMember: (group_id, user_id) => this.pickMember(data, group_id, user_id),
|
||||||
pickGroup: group_id => this.pickGroup(data, group_id),
|
pickGroup: group_id => this.pickGroup(data, group_id),
|
||||||
|
@ -311,24 +315,21 @@ Bot.adapter.push(new class ComWeChatAdapter {
|
||||||
getGroupArray: () => this.getGroupArray(data),
|
getGroupArray: () => this.getGroupArray(data),
|
||||||
getGroupList: () => this.getGroupList(data),
|
getGroupList: () => this.getGroupList(data),
|
||||||
getGroupMap: () => this.getGroupMap(data),
|
getGroupMap: () => this.getGroupMap(data),
|
||||||
|
gl: new Map(),
|
||||||
}
|
}
|
||||||
|
|
||||||
Bot[data.self_id].info = (await data.sendApi("get_self_info")).data
|
if (!Bot.uin.includes(data.self_id))
|
||||||
Bot[data.self_id].uin = Bot[data.self_id].info.user_id
|
Bot.uin.push(data.self_id)
|
||||||
Bot[data.self_id].nickname = Bot[data.self_id].info.user_name
|
|
||||||
Bot[data.self_id].avatar = Bot[data.self_id].info["wx.avatar"]
|
|
||||||
|
|
||||||
|
Bot[data.self_id].info = (await data.sendApi("get_self_info")).data
|
||||||
Bot[data.self_id].version = {
|
Bot[data.self_id].version = {
|
||||||
...(await data.sendApi("get_version")).data,
|
...(await data.sendApi("get_version")).data,
|
||||||
id: this.id,
|
id: this.id,
|
||||||
name: this.name,
|
name: this.name,
|
||||||
}
|
}
|
||||||
|
|
||||||
Bot[data.self_id].fl = await Bot[data.self_id].getFriendMap()
|
Bot[data.self_id].getFriendMap()
|
||||||
Bot[data.self_id].gl = await Bot[data.self_id].getGroupMap()
|
Bot[data.self_id].getGroupMap()
|
||||||
|
|
||||||
if (!Bot.uin.includes(data.self_id))
|
|
||||||
Bot.uin.push(data.self_id)
|
|
||||||
|
|
||||||
logger.mark(`${logger.blue(`[${data.self_id}]`)} ${this.name}(${this.id}) 已连接`)
|
logger.mark(`${logger.blue(`[${data.self_id}]`)} ${this.name}(${this.id}) 已连接`)
|
||||||
Bot.emit(`connect.${data.self_id}`, Bot[data.self_id])
|
Bot.emit(`connect.${data.self_id}`, Bot[data.self_id])
|
||||||
|
|
|
@ -168,10 +168,9 @@ Bot.adapter.push(new class gocqhttpAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
async getFriendMap(data) {
|
async getFriendMap(data) {
|
||||||
const map = new Map()
|
|
||||||
for (const i of (await this.getFriendArray(data)))
|
for (const i of (await this.getFriendArray(data)))
|
||||||
map.set(i.user_id, i)
|
Bot[data.self_id].fl.set(i.user_id, i)
|
||||||
return map
|
return Bot[data.self_id].fl
|
||||||
}
|
}
|
||||||
|
|
||||||
getFriendInfo(data) {
|
getFriendInfo(data) {
|
||||||
|
@ -204,10 +203,9 @@ Bot.adapter.push(new class gocqhttpAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGroupMap(data) {
|
async getGroupMap(data) {
|
||||||
const map = new Map()
|
|
||||||
for (const i of (await this.getGroupArray(data)))
|
for (const i of (await this.getGroupArray(data)))
|
||||||
map.set(i.group_id, i)
|
Bot[data.self_id].gl.set(i.group_id, i)
|
||||||
return map
|
return Bot[data.self_id].gl
|
||||||
}
|
}
|
||||||
|
|
||||||
getGroupInfo(data) {
|
getGroupInfo(data) {
|
||||||
|
@ -568,6 +566,12 @@ Bot.adapter.push(new class gocqhttpAdapter {
|
||||||
adapter: this,
|
adapter: this,
|
||||||
sendApi: data.sendApi,
|
sendApi: data.sendApi,
|
||||||
stat: { start_time: data.time },
|
stat: { start_time: data.time },
|
||||||
|
model: "TRSS Yunzai ",
|
||||||
|
|
||||||
|
info: {},
|
||||||
|
get uin() { return this.info.user_id },
|
||||||
|
get nickname() { return this.info.nickname },
|
||||||
|
get avatar() { return `https://q1.qlogo.cn/g?b=qq&s=0&nk=${this.uin}` },
|
||||||
|
|
||||||
setProfile: profile => this.setProfile(data, profile),
|
setProfile: profile => this.setProfile(data, profile),
|
||||||
setNickname: nickname => this.setProfile(data, { nickname }),
|
setNickname: nickname => this.setProfile(data, { nickname }),
|
||||||
|
@ -578,6 +582,7 @@ Bot.adapter.push(new class gocqhttpAdapter {
|
||||||
getFriendArray: () => this.getFriendArray(data),
|
getFriendArray: () => this.getFriendArray(data),
|
||||||
getFriendList: () => this.getFriendList(data),
|
getFriendList: () => this.getFriendList(data),
|
||||||
getFriendMap: () => this.getFriendMap(data),
|
getFriendMap: () => this.getFriendMap(data),
|
||||||
|
fl: new Map(),
|
||||||
|
|
||||||
pickMember: (group_id, user_id) => this.pickMember(data, group_id, user_id),
|
pickMember: (group_id, user_id) => this.pickMember(data, group_id, user_id),
|
||||||
pickGroup: group_id => this.pickGroup(data, group_id),
|
pickGroup: group_id => this.pickGroup(data, group_id),
|
||||||
|
@ -585,6 +590,7 @@ Bot.adapter.push(new class gocqhttpAdapter {
|
||||||
getGroupArray: () => this.getGroupArray(data),
|
getGroupArray: () => this.getGroupArray(data),
|
||||||
getGroupList: () => this.getGroupList(data),
|
getGroupList: () => this.getGroupList(data),
|
||||||
getGroupMap: () => this.getGroupMap(data),
|
getGroupMap: () => this.getGroupMap(data),
|
||||||
|
gl: new Map(),
|
||||||
|
|
||||||
request_list: [],
|
request_list: [],
|
||||||
getSystemMsg: () => Bot[data.self_id].request_list,
|
getSystemMsg: () => Bot[data.self_id].request_list,
|
||||||
|
@ -592,21 +598,16 @@ Bot.adapter.push(new class gocqhttpAdapter {
|
||||||
setGroupAddRequest: (flag, sub_type, approve, reason) => this.setGroupAddRequest(data, flag, sub_type, approve, reason),
|
setGroupAddRequest: (flag, sub_type, approve, reason) => this.setGroupAddRequest(data, flag, sub_type, approve, reason),
|
||||||
}
|
}
|
||||||
|
|
||||||
Bot[data.self_id].info = (await data.sendApi("get_login_info")).data
|
if (!Bot.uin.includes(data.self_id))
|
||||||
Bot[data.self_id].uin = Bot[data.self_id].info.user_id
|
Bot.uin.push(data.self_id)
|
||||||
Bot[data.self_id].nickname = Bot[data.self_id].info.nickname
|
|
||||||
Bot[data.self_id].avatar = `https://q1.qlogo.cn/g?b=qq&s=0&nk=${data.self_id}`
|
|
||||||
|
|
||||||
Bot[data.self_id].guild_info = (await data.sendApi("get_guild_service_profile")).data
|
|
||||||
Bot[data.self_id].tiny_id = Bot[data.self_id].guild_info.tiny_id
|
|
||||||
Bot[data.self_id].guild_nickname = Bot[data.self_id].guild_info.nickname
|
|
||||||
|
|
||||||
Bot[data.self_id].model = "TRSS Yunzai "
|
|
||||||
data.sendApi("_set_model_show", {
|
data.sendApi("_set_model_show", {
|
||||||
model: Bot[data.self_id].model,
|
model: Bot[data.self_id].model,
|
||||||
model_show: Bot[data.self_id].model,
|
model_show: Bot[data.self_id].model,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Bot[data.self_id].info = (await data.sendApi("get_login_info")).data
|
||||||
|
Bot[data.self_id].guild_info = (await data.sendApi("get_guild_service_profile")).data
|
||||||
Bot[data.self_id].clients = (await data.sendApi("get_online_clients")).clients
|
Bot[data.self_id].clients = (await data.sendApi("get_online_clients")).clients
|
||||||
Bot[data.self_id].version = (await data.sendApi("get_version_info")).data
|
Bot[data.self_id].version = (await data.sendApi("get_version_info")).data
|
||||||
Bot[data.self_id].version = {
|
Bot[data.self_id].version = {
|
||||||
|
@ -614,13 +615,9 @@ Bot.adapter.push(new class gocqhttpAdapter {
|
||||||
id: this.id,
|
id: this.id,
|
||||||
name: this.name,
|
name: this.name,
|
||||||
}
|
}
|
||||||
Bot[data.self_id].status = Bot[data.self_id].version.protocol_name
|
|
||||||
|
|
||||||
Bot[data.self_id].fl = await Bot[data.self_id].getFriendMap()
|
Bot[data.self_id].getFriendMap()
|
||||||
Bot[data.self_id].gl = await Bot[data.self_id].getGroupMap()
|
Bot[data.self_id].getGroupMap()
|
||||||
|
|
||||||
if (!Bot.uin.includes(data.self_id))
|
|
||||||
Bot.uin.push(data.self_id)
|
|
||||||
|
|
||||||
logger.mark(`${logger.blue(`[${data.self_id}]`)} ${this.name}(${this.id}) 已连接`)
|
logger.mark(`${logger.blue(`[${data.self_id}]`)} ${this.name}(${this.id}) 已连接`)
|
||||||
Bot.emit(`connect.${data.self_id}`, Bot[data.self_id])
|
Bot.emit(`connect.${data.self_id}`, Bot[data.self_id])
|
||||||
|
@ -672,12 +669,13 @@ Bot.adapter.push(new class gocqhttpAdapter {
|
||||||
break
|
break
|
||||||
case "group_increase":
|
case "group_increase":
|
||||||
logger.info(`${logger.blue(`[${data.self_id}]`)} 群成员增加:[${data.group_id}, ${data.operator_id}=>${data.user_id}] ${data.sub_type}`)
|
logger.info(`${logger.blue(`[${data.self_id}]`)} 群成员增加:[${data.group_id}, ${data.operator_id}=>${data.user_id}] ${data.sub_type}`)
|
||||||
Bot[data.self_id].gl = await this.getGroupMap(data)
|
if (data.user_id == data.self_id)
|
||||||
|
Bot[data.self_id].getGroupMap()
|
||||||
break
|
break
|
||||||
case "group_decrease":
|
case "group_decrease":
|
||||||
logger.info(`${logger.blue(`[${data.self_id}]`)} 群成员减少:[${data.group_id}, ${data.operator_id}=>${data.user_id}] ${data.sub_type}`)
|
logger.info(`${logger.blue(`[${data.self_id}]`)} 群成员减少:[${data.group_id}, ${data.operator_id}=>${data.user_id}] ${data.sub_type}`)
|
||||||
const gld = new Map()
|
if (data.user_id == data.self_id)
|
||||||
Bot[data.self_id].gl = await this.getGroupMap(data)
|
Bot[data.self_id].getGroupMap()
|
||||||
break
|
break
|
||||||
case "group_admin":
|
case "group_admin":
|
||||||
logger.info(`${logger.blue(`[${data.self_id}]`)} 群管理员变动:[${data.group_id}, ${data.user_id}] ${data.sub_type}`)
|
logger.info(`${logger.blue(`[${data.self_id}]`)} 群管理员变动:[${data.group_id}, ${data.user_id}] ${data.sub_type}`)
|
||||||
|
@ -691,7 +689,7 @@ Bot.adapter.push(new class gocqhttpAdapter {
|
||||||
break
|
break
|
||||||
case "friend_add":
|
case "friend_add":
|
||||||
logger.info(`${logger.blue(`[${data.self_id}]`)} 好友添加:[${data.user_id}]`)
|
logger.info(`${logger.blue(`[${data.self_id}]`)} 好友添加:[${data.user_id}]`)
|
||||||
Bot[data.self_id].fl = await this.getFriendMap(data)
|
Bot[data.self_id].getFriendMap()
|
||||||
break
|
break
|
||||||
case "notify":
|
case "notify":
|
||||||
if (data.group_id)
|
if (data.group_id)
|
||||||
|
@ -745,12 +743,12 @@ Bot.adapter.push(new class gocqhttpAdapter {
|
||||||
case "channel_created":
|
case "channel_created":
|
||||||
data.notice_type = "guild_channel_created"
|
data.notice_type = "guild_channel_created"
|
||||||
logger.info(`${logger.blue(`[${data.self_id}]`)} 子频道创建:[${data.guild_id}-${data.channel_id}, ${data.user_id}] ${JSON.stringify(data.channel_info)}`)
|
logger.info(`${logger.blue(`[${data.self_id}]`)} 子频道创建:[${data.guild_id}-${data.channel_id}, ${data.user_id}] ${JSON.stringify(data.channel_info)}`)
|
||||||
Bot[data.self_id].gl = await this.getGroupMap(data)
|
Bot[data.self_id].getGroupMap()
|
||||||
break
|
break
|
||||||
case "channel_destroyed":
|
case "channel_destroyed":
|
||||||
data.notice_type = "guild_channel_destroyed"
|
data.notice_type = "guild_channel_destroyed"
|
||||||
logger.info(`${logger.blue(`[${data.self_id}]`)} 子频道删除:[${data.guild_id}-${data.channel_id}, ${data.user_id}] ${JSON.stringify(data.channel_info)}`)
|
logger.info(`${logger.blue(`[${data.self_id}]`)} 子频道删除:[${data.guild_id}-${data.channel_id}, ${data.user_id}] ${JSON.stringify(data.channel_info)}`)
|
||||||
Bot[data.self_id].gl = await this.getGroupMap(data)
|
Bot[data.self_id].getGroupMap()
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
logger.warn(`${logger.blue(`[${data.self_id}]`)} 未知通知:${logger.magenta(JSON.stringify(data))}`)
|
logger.warn(`${logger.blue(`[${data.self_id}]`)} 未知通知:${logger.magenta(JSON.stringify(data))}`)
|
||||||
|
|
|
@ -5,22 +5,24 @@ import { Restart } from "./restart.js"
|
||||||
|
|
||||||
let insing = false
|
let insing = false
|
||||||
const list = {
|
const list = {
|
||||||
"Atlas" :"https://gitee.com/Nwflower/atlas",
|
"Atlas":"https://gitee.com/Nwflower/atlas",
|
||||||
"TRSS-Plugin" :"https://Yunzai.TRSS.me",
|
"TRSS-Plugin" :"https://Yunzai.TRSS.me",
|
||||||
"yenai-plugin" :"https://gitee.com/yeyang52/yenai-plugin",
|
"yenai-plugin" :"https://gitee.com/yeyang52/yenai-plugin",
|
||||||
"expand-plugin" :"https://gitee.com/SmallK111407/expand-plugin",
|
"flower-plugin" :"https://gitee.com/Nwflower/flower-plugin",
|
||||||
"flower-plugin" :"https://gitee.com/Nwflower/flower-plugin",
|
"earth-k-plugin":"https://gitee.com/SmallK111407/earth-k-plugin",
|
||||||
"earth-k-plugin" :"https://gitee.com/SmallK111407/earth-k-plugin",
|
"useless-plugin":"https://gitee.com/SmallK111407/useless-plugin",
|
||||||
"xiaofei-plugin" :"https://gitee.com/xfdown/xiaofei-plugin",
|
"StarRail-plugin" :"https://gitee.com/hewang1an/StarRail-plugin",
|
||||||
"xiaoyao-cvs-plugin":"https://gitee.com/Ctrlcvs/xiaoyao-cvs-plugin",
|
"xiaoyao-cvs-plugin":"https://gitee.com/Ctrlcvs/xiaoyao-cvs-plugin",
|
||||||
|
"Jinmaocuicuisha-plugin":"https://gitee.com/JMCCS/jinmaocuicuisha",
|
||||||
|
"trss-xianxin-plugin" :"https://gitee.com/snowtafir/xianxin-plugin",
|
||||||
"mysVilla-Plugin" :"https://gitee.com/TimeRainStarSky/Yunzai-mysVilla-Plugin",
|
"mysVilla-Plugin" :"https://gitee.com/TimeRainStarSky/Yunzai-mysVilla-Plugin",
|
||||||
"Telegram-Plugin" :"https://gitee.com/TimeRainStarSky/Yunzai-Telegram-Plugin",
|
"Telegram-Plugin" :"https://gitee.com/TimeRainStarSky/Yunzai-Telegram-Plugin",
|
||||||
"Discord-Plugin" :"https://gitee.com/TimeRainStarSky/Yunzai-Discord-Plugin",
|
"Discord-Plugin":"https://gitee.com/TimeRainStarSky/Yunzai-Discord-Plugin",
|
||||||
"QQGuild-Plugin" :"https://gitee.com/TimeRainStarSky/Yunzai-QQGuild-Plugin",
|
"QQGuild-Plugin":"https://gitee.com/TimeRainStarSky/Yunzai-QQGuild-Plugin",
|
||||||
"WeChat-Plugin" :"https://gitee.com/TimeRainStarSky/Yunzai-WeChat-Plugin",
|
"WeChat-Plugin" :"https://gitee.com/TimeRainStarSky/Yunzai-WeChat-Plugin",
|
||||||
"Proxy-Plugin" :"https://gitee.com/TimeRainStarSky/Yunzai-Proxy-Plugin",
|
"Proxy-Plugin" :"https://gitee.com/TimeRainStarSky/Yunzai-Proxy-Plugin",
|
||||||
"ICQQ-Plugin" :"https://gitee.com/TimeRainStarSky/Yunzai-ICQQ-Plugin",
|
"ICQQ-Plugin" :"https://gitee.com/TimeRainStarSky/Yunzai-ICQQ-Plugin",
|
||||||
"KOOK-Plugin" :"https://gitee.com/TimeRainStarSky/Yunzai-KOOK-Plugin",
|
"KOOK-Plugin" :"https://gitee.com/TimeRainStarSky/Yunzai-KOOK-Plugin",
|
||||||
}
|
}
|
||||||
|
|
||||||
export class install extends plugin {
|
export class install extends plugin {
|
||||||
|
|
Loading…
Reference in New Issue