mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
commit
ba413b9581
@ -4,7 +4,7 @@
|
|||||||
"name": "LLOneBot",
|
"name": "LLOneBot",
|
||||||
"slug": "LLOneBot",
|
"slug": "LLOneBot",
|
||||||
"description": "实现 OneBot 11 协议,用于 QQ 机器人开发",
|
"description": "实现 OneBot 11 协议,用于 QQ 机器人开发",
|
||||||
"version": "3.31.4",
|
"version": "3.31.5",
|
||||||
"icon": "./icon.webp",
|
"icon": "./icon.webp",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,7 @@ declare module 'cordis' {
|
|||||||
export class NTQQGroupApi extends Service {
|
export class NTQQGroupApi extends Service {
|
||||||
static inject = ['ntWindowApi']
|
static inject = ['ntWindowApi']
|
||||||
|
|
||||||
private groupMembers: Map<string, Map<string, GroupMember>> = new Map<string, Map<string, GroupMember>>()
|
public groupMembers: Map<string, Map<string, GroupMember>> = new Map<string, Map<string, GroupMember>>()
|
||||||
|
|
||||||
constructor(protected ctx: Context) {
|
constructor(protected ctx: Context) {
|
||||||
super(ctx, 'ntGroupApi', true)
|
super(ctx, 'ntGroupApi', true)
|
||||||
|
@ -153,12 +153,7 @@ export class NTQQMsgApi extends Service {
|
|||||||
)
|
)
|
||||||
msgList = data.msgList
|
msgList = data.msgList
|
||||||
}
|
}
|
||||||
const retMsg = msgList.find(msgRecord => {
|
return msgList.find(msgRecord => msgRecord.guildId === msgId)
|
||||||
if (msgRecord.guildId === msgId) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return retMsg!
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async forwardMsg(srcPeer: Peer, destPeer: Peer, msgIds: string[]) {
|
async forwardMsg(srcPeer: Peer, destPeer: Peer, msgIds: string[]) {
|
||||||
|
@ -3,7 +3,7 @@ import { User, UserDetailInfoByUin, UserDetailInfoByUinV2, UserDetailInfoListene
|
|||||||
import { getBuildVersion } from '@/common/utils'
|
import { getBuildVersion } from '@/common/utils'
|
||||||
import { getSession } from '@/ntqqapi/wrapper'
|
import { getSession } from '@/ntqqapi/wrapper'
|
||||||
import { RequestUtil } from '@/common/utils/request'
|
import { RequestUtil } from '@/common/utils/request'
|
||||||
import { NodeIKernelProfileService, UserDetailSource, ProfileBizType, forceFetchClientKeyRetType } from '../services'
|
import { NodeIKernelProfileService, UserDetailSource, ProfileBizType } from '../services'
|
||||||
import { NodeIKernelProfileListener } from '../listeners'
|
import { NodeIKernelProfileListener } from '../listeners'
|
||||||
import { NTEventDispatch } from '@/common/utils/eventTask'
|
import { NTEventDispatch } from '@/common/utils/eventTask'
|
||||||
import { Time } from 'cosmokit'
|
import { Time } from 'cosmokit'
|
||||||
@ -17,7 +17,7 @@ declare module 'cordis' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class NTQQUserApi extends Service {
|
export class NTQQUserApi extends Service {
|
||||||
static inject = ['ntFriendApi']
|
static inject = ['ntFriendApi', 'ntGroupApi']
|
||||||
|
|
||||||
constructor(protected ctx: Context) {
|
constructor(protected ctx: Context) {
|
||||||
super(ctx, 'ntUserApi', true)
|
super(ctx, 'ntUserApi', true)
|
||||||
@ -192,11 +192,26 @@ export class NTQQUserApi extends Service {
|
|||||||
// 通用转换开始尝试
|
// 通用转换开始尝试
|
||||||
let uid = (await session?.getUixConvertService().getUid([uin]))?.uidInfo.get(uin)
|
let uid = (await session?.getUixConvertService().getUid([uin]))?.uidInfo.get(uin)
|
||||||
if (!uid) {
|
if (!uid) {
|
||||||
let unveifyUid = (await this.getUserDetailInfoByUin(uin)).info.uid //从QQ Native 特殊转换 方法三
|
for (const membersList of this.ctx.ntGroupApi.groupMembers.values()) { //从群友列表转
|
||||||
if (unveifyUid.indexOf('*') == -1) {
|
for (const member of membersList.values()) {
|
||||||
|
if (member.uin === uin) {
|
||||||
|
uid = member.uid
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (uid) break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!uid) {
|
||||||
|
const unveifyUid = (await this.getUserDetailInfoByUin(uin)).info.uid //特殊转换
|
||||||
|
if (unveifyUid.indexOf('*') === -1) {
|
||||||
uid = unveifyUid
|
uid = unveifyUid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!uid) {
|
||||||
|
const friends = await this.ctx.ntFriendApi.getFriends() //从好友列表转
|
||||||
|
uid = friends.find(item => item.uin === uin)?.uid
|
||||||
|
}
|
||||||
return uid
|
return uid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,13 +11,17 @@ class DeleteMsg extends BaseAction<Payload, void> {
|
|||||||
|
|
||||||
protected async _handle(payload: Payload) {
|
protected async _handle(payload: Payload) {
|
||||||
if (!payload.message_id) {
|
if (!payload.message_id) {
|
||||||
throw Error('message_id不能为空')
|
throw new Error('参数message_id不能为空')
|
||||||
}
|
}
|
||||||
const msg = await MessageUnique.getMsgIdAndPeerByShortId(+payload.message_id)
|
const msg = await MessageUnique.getMsgIdAndPeerByShortId(+payload.message_id)
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
throw `消息${payload.message_id}不存在`
|
throw new Error(`消息${payload.message_id}不存在`)
|
||||||
|
}
|
||||||
|
const data = await this.ctx.ntMsgApi.recallMsg(msg.Peer, [msg.MsgId])
|
||||||
|
if (data.result !== 0) {
|
||||||
|
this.ctx.logger.error('delete_msg', payload.message_id, data)
|
||||||
|
throw new Error(`消息撤回失败`)
|
||||||
}
|
}
|
||||||
await this.ctx.ntMsgApi.recallMsg(msg.Peer, [msg.MsgId])
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,16 +48,16 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((contextMode === ContextMode.Private || contextMode === ContextMode.Normal) && payload.user_id) {
|
if ((contextMode === ContextMode.Private || contextMode === ContextMode.Normal) && payload.user_id) {
|
||||||
const Uid = await this.ctx.ntUserApi.getUidByUin(payload.user_id.toString())
|
const uid = await this.ctx.ntUserApi.getUidByUin(payload.user_id.toString())
|
||||||
const isBuddy = await this.ctx.ntFriendApi.isBuddy(Uid!)
|
if (!uid) throw new Error('无法获取用户信息')
|
||||||
//console.log("[调试代码] UIN:", payload.user_id, " UID:", Uid, " IsBuddy:", isBuddy)
|
const isBuddy = await this.ctx.ntFriendApi.isBuddy(uid)
|
||||||
return {
|
return {
|
||||||
chatType: isBuddy ? ChatType.friend : ChatType.temp,
|
chatType: isBuddy ? ChatType.friend : ChatType.temp,
|
||||||
peerUid: Uid!,
|
peerUid: uid,
|
||||||
guildId: payload.group_id?.toString() || '' //临时主动发起时需要传入群号
|
guildId: isBuddy ? '' : payload.group_id?.toString() || ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw '请指定 group_id 或 user_id'
|
throw new Error('请指定 group_id 或 user_id')
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async check(payload: OB11PostSendMsg): Promise<BaseCheckResult> {
|
protected async check(payload: OB11PostSendMsg): Promise<BaseCheckResult> {
|
||||||
@ -160,6 +160,9 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const returnMsg = await sendMsg(this.ctx, peer, sendElements, deleteAfterSentFiles)
|
const returnMsg = await sendMsg(this.ctx, peer, sendElements, deleteAfterSentFiles)
|
||||||
|
if (!returnMsg) {
|
||||||
|
throw new Error('消息发送失败')
|
||||||
|
}
|
||||||
return { message_id: returnMsg.msgShortId! }
|
return { message_id: returnMsg.msgShortId! }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,9 +254,12 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
|||||||
// log("分割后的转发节点", sendElementsSplit)
|
// log("分割后的转发节点", sendElementsSplit)
|
||||||
for (const eles of sendElementsSplit) {
|
for (const eles of sendElementsSplit) {
|
||||||
const nodeMsg = await sendMsg(this.ctx, selfPeer, eles, [], true)
|
const nodeMsg = await sendMsg(this.ctx, selfPeer, eles, [], true)
|
||||||
|
if (!nodeMsg) {
|
||||||
|
this.ctx.logger.warn('转发节点生成失败', eles)
|
||||||
|
continue
|
||||||
|
}
|
||||||
nodeMsgIds.push(nodeMsg.msgId)
|
nodeMsgIds.push(nodeMsg.msgId)
|
||||||
await this.ctx.sleep(400)
|
await this.ctx.sleep(400)
|
||||||
this.ctx.logger.info('转发节点生成成功', nodeMsg.msgId)
|
|
||||||
}
|
}
|
||||||
deleteAfterSentFiles.map((f) => fs.unlink(f, () => {
|
deleteAfterSentFiles.map((f) => fs.unlink(f, () => {
|
||||||
}))
|
}))
|
||||||
|
@ -270,8 +270,10 @@ export async function sendMsg(
|
|||||||
const timeout = 10000 + (totalSize / 1024 / 256 * 1000) // 10s Basic Timeout + PredictTime( For File 512kb/s )
|
const timeout = 10000 + (totalSize / 1024 / 256 * 1000) // 10s Basic Timeout + PredictTime( For File 512kb/s )
|
||||||
//log('设置消息超时时间', timeout)
|
//log('设置消息超时时间', timeout)
|
||||||
const returnMsg = await ctx.ntMsgApi.sendMsg(peer, sendElements, waitComplete, timeout)
|
const returnMsg = await ctx.ntMsgApi.sendMsg(peer, sendElements, waitComplete, timeout)
|
||||||
|
if (returnMsg) {
|
||||||
returnMsg.msgShortId = MessageUnique.createMsg(peer, returnMsg.msgId)
|
returnMsg.msgShortId = MessageUnique.createMsg(peer, returnMsg.msgId)
|
||||||
ctx.logger.info('消息发送', returnMsg.msgShortId)
|
ctx.logger.info('消息发送', returnMsg.msgShortId)
|
||||||
deleteAfterSentFiles.map(path => fsPromise.unlink(path))
|
deleteAfterSentFiles.map(path => fsPromise.unlink(path))
|
||||||
return returnMsg
|
return returnMsg
|
||||||
|
}
|
||||||
}
|
}
|
@ -1 +1 @@
|
|||||||
export const version = '3.31.4'
|
export const version = '3.31.5'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user