mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
fix: report self sent message_id
This commit is contained in:
parent
c4b45f8298
commit
aea67db27c
@ -4,7 +4,7 @@
|
|||||||
"name": "LLOneBot",
|
"name": "LLOneBot",
|
||||||
"slug": "LLOneBot",
|
"slug": "LLOneBot",
|
||||||
"description": "LiteLoaderQQNT的OneBotApi",
|
"description": "LiteLoaderQQNT的OneBotApi",
|
||||||
"version": "3.0.5",
|
"version": "3.0.6",
|
||||||
"thumbnail": "./icon.png",
|
"thumbnail": "./icon.png",
|
||||||
"authors": [{
|
"authors": [{
|
||||||
"name": "linyuchen",
|
"name": "linyuchen",
|
||||||
|
@ -12,7 +12,7 @@ import {
|
|||||||
} from "../common/channels";
|
} from "../common/channels";
|
||||||
import { postMsg, startExpress } from "../onebot11/server";
|
import { postMsg, startExpress } from "../onebot11/server";
|
||||||
import { CONFIG_DIR, getConfigUtil, log } from "../common/utils";
|
import { CONFIG_DIR, getConfigUtil, log } from "../common/utils";
|
||||||
import { addHistoryMsg, selfInfo } from "../common/data";
|
import { addHistoryMsg, msgHistory, selfInfo } from "../common/data";
|
||||||
import { hookNTQQApiReceive, ReceiveCmd, registerReceiveHook } from "../ntqqapi/hook";
|
import { hookNTQQApiReceive, ReceiveCmd, registerReceiveHook } from "../ntqqapi/hook";
|
||||||
import { OB11Constructor } from "../onebot11/constructor";
|
import { OB11Constructor } from "../onebot11/constructor";
|
||||||
import { NTQQApi } from "../ntqqapi/ntcall";
|
import { NTQQApi } from "../ntqqapi/ntcall";
|
||||||
@ -48,6 +48,10 @@ function onLoad() {
|
|||||||
function postRawMsg(msgList: RawMessage[]) {
|
function postRawMsg(msgList: RawMessage[]) {
|
||||||
const {debug, reportSelfMessage} = getConfigUtil().getConfig();
|
const {debug, reportSelfMessage} = getConfigUtil().getConfig();
|
||||||
for (let message of msgList) {
|
for (let message of msgList) {
|
||||||
|
message.msgShortId = msgHistory[message.msgId]?.msgShortId
|
||||||
|
if (!message.msgShortId) {
|
||||||
|
addHistoryMsg(message)
|
||||||
|
}
|
||||||
OB11Constructor.message(message).then((msg) => {
|
OB11Constructor.message(message).then((msg) => {
|
||||||
if (debug) {
|
if (debug) {
|
||||||
msg.raw = message;
|
msg.raw = message;
|
||||||
@ -78,7 +82,7 @@ function onLoad() {
|
|||||||
if (!reportSelfMessage) {
|
if (!reportSelfMessage) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log("reportSelfMessage", payload)
|
// log("reportSelfMessage", payload)
|
||||||
try {
|
try {
|
||||||
postRawMsg([payload.msgRecord]);
|
postRawMsg([payload.msgRecord]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -137,12 +137,8 @@ registerReceiveHook<{ msgList: Array<RawMessage> }>(ReceiveCmd.UPDATE_MSG, (payl
|
|||||||
|
|
||||||
registerReceiveHook<{ msgList: Array<RawMessage> }>(ReceiveCmd.NEW_MSG, (payload) => {
|
registerReceiveHook<{ msgList: Array<RawMessage> }>(ReceiveCmd.NEW_MSG, (payload) => {
|
||||||
for (const message of payload.msgList) {
|
for (const message of payload.msgList) {
|
||||||
log("收到新消息,push到历史记录", message)
|
// log("收到新消息,push到历史记录", message)
|
||||||
if (!msgHistory[message.msgId]) {
|
addHistoryMsg(message)
|
||||||
addHistoryMsg(message)
|
|
||||||
} else {
|
|
||||||
Object.assign(msgHistory[message.msgId], message)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const msgIds = Object.keys(msgHistory);
|
const msgIds = Object.keys(msgHistory);
|
||||||
if (msgIds.length > 30000) {
|
if (msgIds.length > 30000) {
|
||||||
|
@ -1,12 +1,21 @@
|
|||||||
import {OB11MessageDataType, OB11GroupMemberRole, OB11Message, OB11MessageData, OB11Group, OB11GroupMember, OB11User} from "./types";
|
import {
|
||||||
|
OB11MessageDataType,
|
||||||
|
OB11GroupMemberRole,
|
||||||
|
OB11Message,
|
||||||
|
OB11MessageData,
|
||||||
|
OB11Group,
|
||||||
|
OB11GroupMember,
|
||||||
|
OB11User
|
||||||
|
} from "./types";
|
||||||
import { AtType, ChatType, Group, GroupMember, IMAGE_HTTP_HOST, RawMessage, SelfInfo, User } from '../ntqqapi/types';
|
import { AtType, ChatType, Group, GroupMember, IMAGE_HTTP_HOST, RawMessage, SelfInfo, User } from '../ntqqapi/types';
|
||||||
import { addHistoryMsg, getFriend, getGroupMember, getHistoryMsgBySeq, selfInfo } from '../common/data';
|
import { addHistoryMsg, getFriend, getGroupMember, getHistoryMsgBySeq, msgHistory, selfInfo } from '../common/data';
|
||||||
import {file2base64, getConfigUtil, log} from "../common/utils";
|
import { file2base64, getConfigUtil, log } from "../common/utils";
|
||||||
import { NTQQApi } from "../ntqqapi/ntcall";
|
import { NTQQApi } from "../ntqqapi/ntcall";
|
||||||
|
|
||||||
|
|
||||||
export class OB11Constructor {
|
export class OB11Constructor {
|
||||||
static async message(msg: RawMessage): Promise<OB11Message> {
|
static async message(msg: RawMessage): Promise<OB11Message> {
|
||||||
|
|
||||||
const {enableBase64} = getConfigUtil().getConfig()
|
const {enableBase64} = getConfigUtil().getConfig()
|
||||||
const message_type = msg.chatType == ChatType.group ? "group" : "private";
|
const message_type = msg.chatType == ChatType.group ? "group" : "private";
|
||||||
const resMsg: OB11Message = {
|
const resMsg: OB11Message = {
|
||||||
@ -56,13 +65,13 @@ export class OB11Constructor {
|
|||||||
} else {
|
} else {
|
||||||
let atUid = element.textElement.atNtUid
|
let atUid = element.textElement.atNtUid
|
||||||
let atQQ = element.textElement.atUid
|
let atQQ = element.textElement.atUid
|
||||||
if (!atQQ || atQQ === "0"){
|
if (!atQQ || atQQ === "0") {
|
||||||
const atMember = await getGroupMember(msg.peerUin, null, atUid)
|
const atMember = await getGroupMember(msg.peerUin, null, atUid)
|
||||||
if (atMember){
|
if (atMember) {
|
||||||
atQQ = atMember.uin
|
atQQ = atMember.uin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (atQQ){
|
if (atQQ) {
|
||||||
message_data["data"]["mention"] = atQQ
|
message_data["data"]["mention"] = atQQ
|
||||||
message_data["data"]["qq"] = atQQ
|
message_data["data"]["qq"] = atQQ
|
||||||
}
|
}
|
||||||
@ -78,7 +87,7 @@ export class OB11Constructor {
|
|||||||
try {
|
try {
|
||||||
await NTQQApi.downloadMedia(msg.msgId, msg.chatType, msg.peerUid,
|
await NTQQApi.downloadMedia(msg.msgId, msg.chatType, msg.peerUid,
|
||||||
element.elementId, element.picElement.thumbPath.get(0), element.picElement.sourcePath)
|
element.elementId, element.picElement.thumbPath.get(0), element.picElement.sourcePath)
|
||||||
}catch (e) {
|
} catch (e) {
|
||||||
message_data["data"]["http_file"] = IMAGE_HTTP_HOST + element.picElement.originImageUrl
|
message_data["data"]["http_file"] = IMAGE_HTTP_HOST + element.picElement.originImageUrl
|
||||||
}
|
}
|
||||||
} else if (element.replyElement) {
|
} else if (element.replyElement) {
|
||||||
@ -86,8 +95,7 @@ export class OB11Constructor {
|
|||||||
const replyMsg = getHistoryMsgBySeq(element.replyElement.replayMsgSeq)
|
const replyMsg = getHistoryMsgBySeq(element.replyElement.replayMsgSeq)
|
||||||
if (replyMsg) {
|
if (replyMsg) {
|
||||||
message_data["data"]["id"] = replyMsg.msgShortId
|
message_data["data"]["id"] = replyMsg.msgShortId
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
} else if (element.pttElement) {
|
} else if (element.pttElement) {
|
||||||
@ -104,10 +112,9 @@ export class OB11Constructor {
|
|||||||
message_data["type"] = OB11MessageDataType.json;
|
message_data["type"] = OB11MessageDataType.json;
|
||||||
message_data["data"]["data"] = element.arkElement.bytesData;
|
message_data["data"]["data"] = element.arkElement.bytesData;
|
||||||
}
|
}
|
||||||
if (message_data.data.http_file){
|
if (message_data.data.http_file) {
|
||||||
message_data.data.file = message_data.data.http_file
|
message_data.data.file = message_data.data.http_file
|
||||||
}
|
} else if (message_data.data.file) {
|
||||||
else if (message_data.data.file) {
|
|
||||||
let filePath: string = message_data.data.file;
|
let filePath: string = message_data.data.file;
|
||||||
message_data.data.file = "file://" + filePath
|
message_data.data.file = "file://" + filePath
|
||||||
if (enableBase64) {
|
if (enableBase64) {
|
||||||
@ -125,24 +132,24 @@ export class OB11Constructor {
|
|||||||
}
|
}
|
||||||
return resMsg;
|
return resMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
static friend(friend: User): OB11User{
|
static friend(friend: User): OB11User {
|
||||||
return {
|
return {
|
||||||
user_id: friend.uin,
|
user_id: friend.uin,
|
||||||
nickname: friend.nick,
|
nickname: friend.nick,
|
||||||
remark: friend.remark
|
remark: friend.remark
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static selfInfo(selfInfo: SelfInfo): OB11User{
|
static selfInfo(selfInfo: SelfInfo): OB11User {
|
||||||
return {
|
return {
|
||||||
user_id: selfInfo.uin,
|
user_id: selfInfo.uin,
|
||||||
nickname: selfInfo.nick
|
nickname: selfInfo.nick
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static friends(friends: User[]): OB11User[]{
|
static friends(friends: User[]): OB11User[] {
|
||||||
return friends.map(OB11Constructor.friend)
|
return friends.map(OB11Constructor.friend)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +161,7 @@ export class OB11Constructor {
|
|||||||
}[role]
|
}[role]
|
||||||
}
|
}
|
||||||
|
|
||||||
static groupMember(group_id: string, member: GroupMember): OB11GroupMember{
|
static groupMember(group_id: string, member: GroupMember): OB11GroupMember {
|
||||||
return {
|
return {
|
||||||
group_id,
|
group_id,
|
||||||
user_id: member.uin,
|
user_id: member.uin,
|
||||||
@ -163,19 +170,19 @@ export class OB11Constructor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static groupMembers(group: Group): OB11GroupMember[]{
|
static groupMembers(group: Group): OB11GroupMember[] {
|
||||||
log("construct ob11 group members", group)
|
log("construct ob11 group members", group)
|
||||||
return group.members.map(m=>OB11Constructor.groupMember(group.groupCode, m))
|
return group.members.map(m => OB11Constructor.groupMember(group.groupCode, m))
|
||||||
}
|
}
|
||||||
|
|
||||||
static group(group: Group): OB11Group{
|
static group(group: Group): OB11Group {
|
||||||
return {
|
return {
|
||||||
group_id: group.groupCode,
|
group_id: group.groupCode,
|
||||||
group_name: group.groupName
|
group_name: group.groupName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static groups(groups: Group[]): OB11Group[]{
|
static groups(groups: Group[]): OB11Group[] {
|
||||||
return groups.map(OB11Constructor.group)
|
return groups.map(OB11Constructor.group)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user