修复 GSUIDCore 不注册 bot_id
This commit is contained in:
		
							parent
							
								
									5917fd820c
								
							
						
					
					
						commit
						222239b730
					
				| 
						 | 
					@ -478,55 +478,42 @@ class PluginsLoader {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let { recallMsg = 0, at = "" } = data
 | 
					      let { recallMsg = 0, at = "" } = data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (at && e.isGroup) {
 | 
					      if (at) {
 | 
				
			||||||
        let text = e.sender.card || e.sender.nickname
 | 
					        if (at === true)
 | 
				
			||||||
        if (text) {
 | 
					 | 
				
			||||||
          text = lodash.truncate(text, { length: 10 })
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        if (at === true) {
 | 
					 | 
				
			||||||
          at = e.user_id
 | 
					          at = e.user_id
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (Array.isArray(msg)) {
 | 
					        if (Array.isArray(msg))
 | 
				
			||||||
          msg = [segment.at(at, text), ...msg]
 | 
					          msg = [segment.at(at), ...msg]
 | 
				
			||||||
        } else {
 | 
					        else
 | 
				
			||||||
          msg = [segment.at(at, text), msg]
 | 
					          msg = [segment.at(at), msg]
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (quote) {
 | 
					      if (quote && e.message_id) {
 | 
				
			||||||
        if (Array.isArray(msg)) {
 | 
					        if (Array.isArray(msg))
 | 
				
			||||||
          msg = [segment.reply(e.message_id), ...msg]
 | 
					          msg = [segment.reply(e.message_id), ...msg]
 | 
				
			||||||
        } else {
 | 
					        else
 | 
				
			||||||
          msg = [segment.reply(e.message_id), msg]
 | 
					          msg = [segment.reply(e.message_id), msg]
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let msgRes
 | 
					      let msgRes
 | 
				
			||||||
      try {
 | 
					      try {
 | 
				
			||||||
        msgRes = await e.replyNew(msg)
 | 
					        msgRes = await e.replyNew(msg)
 | 
				
			||||||
      } catch (err) {
 | 
					      } catch (err) {
 | 
				
			||||||
        if (typeof msg != "string") {
 | 
					        if (typeof msg != "string")
 | 
				
			||||||
          if (msg.type == "image" && Buffer.isBuffer(msg?.file))
 | 
					 | 
				
			||||||
            msg.file = {}
 | 
					 | 
				
			||||||
          msg = lodash.truncate(JSON.stringify(msg), { length: 300 })
 | 
					          msg = lodash.truncate(JSON.stringify(msg), { length: 300 })
 | 
				
			||||||
        }
 | 
					        logger.error(`发送消息错误:${msg}`)
 | 
				
			||||||
        logger.error(`发送消息错误:${msg}`)
 | 
					 | 
				
			||||||
        logger.error(err)
 | 
					        logger.error(err)
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (recallMsg > 0 && msgRes?.message_id) {
 | 
					      if (recallMsg > 0 && msgRes?.message_id) {
 | 
				
			||||||
        if (e.isGroup) {
 | 
					        if (e.group?.recallMsg)
 | 
				
			||||||
          setTimeout(
 | 
					          setTimeout(() =>
 | 
				
			||||||
            () => e.group.recallMsg(msgRes.message_id),
 | 
					            e.group.recallMsg(msgRes.message_id),
 | 
				
			||||||
            recallMsg * 1000
 | 
					          recallMsg * 1000)
 | 
				
			||||||
          )
 | 
					        else if (e.friend?.recallMsg)
 | 
				
			||||||
        } else if (e.friend) {
 | 
					          setTimeout(() =>
 | 
				
			||||||
          setTimeout(
 | 
					            e.friend.recallMsg(msgRes.message_id),
 | 
				
			||||||
            () => e.friend.recallMsg(msgRes.message_id),
 | 
					          recallMsg * 1000)
 | 
				
			||||||
            recallMsg * 1000
 | 
					 | 
				
			||||||
          )
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      this.count(e, msg)
 | 
					      this.count(e, msg)
 | 
				
			||||||
| 
						 | 
					@ -536,16 +523,17 @@ class PluginsLoader {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  count(e, msg) {
 | 
					  count(e, msg) {
 | 
				
			||||||
    let screenshot = false
 | 
					    let screenshot = false
 | 
				
			||||||
    if (msg && msg?.file && Buffer.isBuffer(msg?.file)) {
 | 
					    if (msg && msg?.file)
 | 
				
			||||||
      screenshot = true
 | 
					      screenshot = true
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    this.saveCount("sendMsg")
 | 
					    this.saveCount("sendMsg")
 | 
				
			||||||
    if (screenshot) this.saveCount("screenshot")
 | 
					    if (screenshot)
 | 
				
			||||||
 | 
					      this.saveCount("screenshot")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (e.group_id) {
 | 
					    if (e.group_id) {
 | 
				
			||||||
      this.saveCount("sendMsg", e.group_id)
 | 
					      this.saveCount("sendMsg", e.group_id)
 | 
				
			||||||
      if (screenshot) this.saveCount("screenshot", e.group_id)
 | 
					      if (screenshot)
 | 
				
			||||||
 | 
					        this.saveCount("screenshot", e.group_id)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -177,6 +177,9 @@ Bot.adapter.push(new class GSUIDCoreAdapter {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    Bot[data.self_id].pickUser = Bot[data.self_id].pickFriend
 | 
					    Bot[data.self_id].pickUser = Bot[data.self_id].pickFriend
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    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])
 | 
				
			||||||
    Bot.emit("connect", Bot[data.self_id])
 | 
					    Bot.emit("connect", Bot[data.self_id])
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue