细节优化
This commit is contained in:
		
							parent
							
								
									6e515e3d15
								
							
						
					
					
						commit
						7492ae49a1
					
				| 
						 | 
				
			
			@ -164,10 +164,9 @@ Bot.adapter.push(new class ComWeChatAdapter {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  async getFriendMap(data) {
 | 
			
		||||
    const map = new Map()
 | 
			
		||||
    for (const i of (await this.getFriendArray(data)))
 | 
			
		||||
      map.set(i.user_id, i)
 | 
			
		||||
    return map
 | 
			
		||||
      Bot[data.self_id].fl.set(i.user_id, i)
 | 
			
		||||
    return Bot[data.self_id].fl
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  getFriendInfo(data) {
 | 
			
		||||
| 
						 | 
				
			
			@ -188,10 +187,9 @@ Bot.adapter.push(new class ComWeChatAdapter {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  async getGroupMap(data) {
 | 
			
		||||
    const map = new Map()
 | 
			
		||||
    for (const i of (await this.getGroupArray(data)))
 | 
			
		||||
      map.set(i.group_id, i)
 | 
			
		||||
    return map
 | 
			
		||||
      Bot[data.self_id].gl.set(i.group_id, i)
 | 
			
		||||
    return Bot[data.self_id].gl
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  getGroupInfo(data) {
 | 
			
		||||
| 
						 | 
				
			
			@ -298,12 +296,18 @@ Bot.adapter.push(new class ComWeChatAdapter {
 | 
			
		|||
      sendApi: data.sendApi,
 | 
			
		||||
      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),
 | 
			
		||||
      pickFriend: user_id => this.pickFriend(data, user_id),
 | 
			
		||||
 | 
			
		||||
      getFriendArray: () => this.getFriendArray(data),
 | 
			
		||||
      getFriendList: () => this.getFriendList(data),
 | 
			
		||||
      getFriendMap: () => this.getFriendMap(data),
 | 
			
		||||
      fl: new Map(),
 | 
			
		||||
 | 
			
		||||
      pickMember: (group_id, user_id) => this.pickMember(data, group_id, user_id),
 | 
			
		||||
      pickGroup: group_id => this.pickGroup(data, group_id),
 | 
			
		||||
| 
						 | 
				
			
			@ -311,24 +315,21 @@ Bot.adapter.push(new class ComWeChatAdapter {
 | 
			
		|||
      getGroupArray: () => this.getGroupArray(data),
 | 
			
		||||
      getGroupList: () => this.getGroupList(data),
 | 
			
		||||
      getGroupMap: () => this.getGroupMap(data),
 | 
			
		||||
      gl: new Map(),
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Bot[data.self_id].info = (await data.sendApi("get_self_info")).data
 | 
			
		||||
    Bot[data.self_id].uin = Bot[data.self_id].info.user_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"]
 | 
			
		||||
    if (!Bot.uin.includes(data.self_id))
 | 
			
		||||
      Bot.uin.push(data.self_id)
 | 
			
		||||
 | 
			
		||||
    Bot[data.self_id].info = (await data.sendApi("get_self_info")).data
 | 
			
		||||
    Bot[data.self_id].version = {
 | 
			
		||||
      ...(await data.sendApi("get_version")).data,
 | 
			
		||||
      id: this.id,
 | 
			
		||||
      name: this.name,
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Bot[data.self_id].fl = await Bot[data.self_id].getFriendMap()
 | 
			
		||||
    Bot[data.self_id].gl = await Bot[data.self_id].getGroupMap()
 | 
			
		||||
 | 
			
		||||
    if (!Bot.uin.includes(data.self_id))
 | 
			
		||||
      Bot.uin.push(data.self_id)
 | 
			
		||||
    Bot[data.self_id].getFriendMap()
 | 
			
		||||
    Bot[data.self_id].getGroupMap()
 | 
			
		||||
 | 
			
		||||
    logger.mark(`${logger.blue(`[${data.self_id}]`)} ${this.name}(${this.id}) 已连接`)
 | 
			
		||||
    Bot.emit(`connect.${data.self_id}`, Bot[data.self_id])
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -168,10 +168,9 @@ Bot.adapter.push(new class gocqhttpAdapter {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  async getFriendMap(data) {
 | 
			
		||||
    const map = new Map()
 | 
			
		||||
    for (const i of (await this.getFriendArray(data)))
 | 
			
		||||
      map.set(i.user_id, i)
 | 
			
		||||
    return map
 | 
			
		||||
      Bot[data.self_id].fl.set(i.user_id, i)
 | 
			
		||||
    return Bot[data.self_id].fl
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  getFriendInfo(data) {
 | 
			
		||||
| 
						 | 
				
			
			@ -204,10 +203,9 @@ Bot.adapter.push(new class gocqhttpAdapter {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  async getGroupMap(data) {
 | 
			
		||||
    const map = new Map()
 | 
			
		||||
    for (const i of (await this.getGroupArray(data)))
 | 
			
		||||
      map.set(i.group_id, i)
 | 
			
		||||
    return map
 | 
			
		||||
      Bot[data.self_id].gl.set(i.group_id, i)
 | 
			
		||||
    return Bot[data.self_id].gl
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  getGroupInfo(data) {
 | 
			
		||||
| 
						 | 
				
			
			@ -568,6 +566,12 @@ Bot.adapter.push(new class gocqhttpAdapter {
 | 
			
		|||
      adapter: this,
 | 
			
		||||
      sendApi: data.sendApi,
 | 
			
		||||
      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),
 | 
			
		||||
      setNickname: nickname => this.setProfile(data, { nickname }),
 | 
			
		||||
| 
						 | 
				
			
			@ -578,6 +582,7 @@ Bot.adapter.push(new class gocqhttpAdapter {
 | 
			
		|||
      getFriendArray: () => this.getFriendArray(data),
 | 
			
		||||
      getFriendList: () => this.getFriendList(data),
 | 
			
		||||
      getFriendMap: () => this.getFriendMap(data),
 | 
			
		||||
      fl: new Map(),
 | 
			
		||||
 | 
			
		||||
      pickMember: (group_id, user_id) => this.pickMember(data, group_id, user_id),
 | 
			
		||||
      pickGroup: group_id => this.pickGroup(data, group_id),
 | 
			
		||||
| 
						 | 
				
			
			@ -585,6 +590,7 @@ Bot.adapter.push(new class gocqhttpAdapter {
 | 
			
		|||
      getGroupArray: () => this.getGroupArray(data),
 | 
			
		||||
      getGroupList: () => this.getGroupList(data),
 | 
			
		||||
      getGroupMap: () => this.getGroupMap(data),
 | 
			
		||||
      gl: new Map(),
 | 
			
		||||
 | 
			
		||||
      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),
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Bot[data.self_id].info = (await data.sendApi("get_login_info")).data
 | 
			
		||||
    Bot[data.self_id].uin = Bot[data.self_id].info.user_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}`
 | 
			
		||||
    if (!Bot.uin.includes(data.self_id))
 | 
			
		||||
      Bot.uin.push(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", {
 | 
			
		||||
      model: 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].version = (await data.sendApi("get_version_info")).data
 | 
			
		||||
    Bot[data.self_id].version = {
 | 
			
		||||
| 
						 | 
				
			
			@ -614,13 +615,9 @@ Bot.adapter.push(new class gocqhttpAdapter {
 | 
			
		|||
      id: this.id,
 | 
			
		||||
      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].gl = await Bot[data.self_id].getGroupMap()
 | 
			
		||||
 | 
			
		||||
    if (!Bot.uin.includes(data.self_id))
 | 
			
		||||
      Bot.uin.push(data.self_id)
 | 
			
		||||
    Bot[data.self_id].getFriendMap()
 | 
			
		||||
    Bot[data.self_id].getGroupMap()
 | 
			
		||||
 | 
			
		||||
    logger.mark(`${logger.blue(`[${data.self_id}]`)} ${this.name}(${this.id}) 已连接`)
 | 
			
		||||
    Bot.emit(`connect.${data.self_id}`, Bot[data.self_id])
 | 
			
		||||
| 
						 | 
				
			
			@ -672,12 +669,13 @@ Bot.adapter.push(new class gocqhttpAdapter {
 | 
			
		|||
        break
 | 
			
		||||
      case "group_increase":
 | 
			
		||||
        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
 | 
			
		||||
      case "group_decrease":
 | 
			
		||||
        logger.info(`${logger.blue(`[${data.self_id}]`)} 群成员减少:[${data.group_id}, ${data.operator_id}=>${data.user_id}] ${data.sub_type}`)
 | 
			
		||||
        const gld = new Map()
 | 
			
		||||
        Bot[data.self_id].gl = await this.getGroupMap(data)
 | 
			
		||||
        if (data.user_id == data.self_id)
 | 
			
		||||
          Bot[data.self_id].getGroupMap()
 | 
			
		||||
        break
 | 
			
		||||
      case "group_admin":
 | 
			
		||||
        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
 | 
			
		||||
      case "friend_add":
 | 
			
		||||
        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
 | 
			
		||||
      case "notify":
 | 
			
		||||
        if (data.group_id)
 | 
			
		||||
| 
						 | 
				
			
			@ -745,12 +743,12 @@ Bot.adapter.push(new class gocqhttpAdapter {
 | 
			
		|||
      case "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)}`)
 | 
			
		||||
        Bot[data.self_id].gl = await this.getGroupMap(data)
 | 
			
		||||
        Bot[data.self_id].getGroupMap()
 | 
			
		||||
        break
 | 
			
		||||
      case "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)}`)
 | 
			
		||||
        Bot[data.self_id].gl = await this.getGroupMap(data)
 | 
			
		||||
        Bot[data.self_id].getGroupMap()
 | 
			
		||||
        break
 | 
			
		||||
      default:
 | 
			
		||||
        logger.warn(`${logger.blue(`[${data.self_id}]`)} 未知通知:${logger.magenta(JSON.stringify(data))}`)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,22 +5,24 @@ import { Restart } from "./restart.js"
 | 
			
		|||
 | 
			
		||||
let insing = false
 | 
			
		||||
const list = {
 | 
			
		||||
  "Atlas"             :"https://gitee.com/Nwflower/atlas",
 | 
			
		||||
  "TRSS-Plugin"       :"https://Yunzai.TRSS.me",
 | 
			
		||||
  "yenai-plugin"      :"https://gitee.com/yeyang52/yenai-plugin",
 | 
			
		||||
  "expand-plugin"     :"https://gitee.com/SmallK111407/expand-plugin",
 | 
			
		||||
  "flower-plugin"     :"https://gitee.com/Nwflower/flower-plugin",
 | 
			
		||||
  "earth-k-plugin"    :"https://gitee.com/SmallK111407/earth-k-plugin",
 | 
			
		||||
  "xiaofei-plugin"    :"https://gitee.com/xfdown/xiaofei-plugin",
 | 
			
		||||
  "Atlas":"https://gitee.com/Nwflower/atlas",
 | 
			
		||||
  "TRSS-Plugin"   :"https://Yunzai.TRSS.me",
 | 
			
		||||
  "yenai-plugin"  :"https://gitee.com/yeyang52/yenai-plugin",
 | 
			
		||||
  "flower-plugin" :"https://gitee.com/Nwflower/flower-plugin",
 | 
			
		||||
  "earth-k-plugin":"https://gitee.com/SmallK111407/earth-k-plugin",
 | 
			
		||||
  "useless-plugin":"https://gitee.com/SmallK111407/useless-plugin",
 | 
			
		||||
  "StarRail-plugin"   :"https://gitee.com/hewang1an/StarRail-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",
 | 
			
		||||
  "Telegram-Plugin"   :"https://gitee.com/TimeRainStarSky/Yunzai-Telegram-Plugin",
 | 
			
		||||
  "Discord-Plugin"    :"https://gitee.com/TimeRainStarSky/Yunzai-Discord-Plugin",
 | 
			
		||||
  "QQGuild-Plugin"    :"https://gitee.com/TimeRainStarSky/Yunzai-QQGuild-Plugin",
 | 
			
		||||
  "WeChat-Plugin"     :"https://gitee.com/TimeRainStarSky/Yunzai-WeChat-Plugin",
 | 
			
		||||
  "Proxy-Plugin"      :"https://gitee.com/TimeRainStarSky/Yunzai-Proxy-Plugin",
 | 
			
		||||
  "ICQQ-Plugin"       :"https://gitee.com/TimeRainStarSky/Yunzai-ICQQ-Plugin",
 | 
			
		||||
  "KOOK-Plugin"       :"https://gitee.com/TimeRainStarSky/Yunzai-KOOK-Plugin",
 | 
			
		||||
  "Discord-Plugin":"https://gitee.com/TimeRainStarSky/Yunzai-Discord-Plugin",
 | 
			
		||||
  "QQGuild-Plugin":"https://gitee.com/TimeRainStarSky/Yunzai-QQGuild-Plugin",
 | 
			
		||||
  "WeChat-Plugin" :"https://gitee.com/TimeRainStarSky/Yunzai-WeChat-Plugin",
 | 
			
		||||
  "Proxy-Plugin"  :"https://gitee.com/TimeRainStarSky/Yunzai-Proxy-Plugin",
 | 
			
		||||
  "ICQQ-Plugin"   :"https://gitee.com/TimeRainStarSky/Yunzai-ICQQ-Plugin",
 | 
			
		||||
  "KOOK-Plugin"   :"https://gitee.com/TimeRainStarSky/Yunzai-KOOK-Plugin",
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export class install extends plugin {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue