Compare commits

..

7 Commits

Author SHA1 Message Date
linyuchen
ca0a6cfb22 chore: ver 3.19.4 2024-03-25 19:04:30 +08:00
linyuchen
3303b30c4c Merge branch 'main' into dev 2024-03-25 19:01:34 +08:00
linyuchen
429d8deb5c feat: gocq api router add send_forward_msg 2024-03-25 19:01:28 +08:00
linyuchen
48f12fc30b fix: pic subType 2024-03-25 18:52:15 +08:00
linyuchen
41f0e8f574 Merge pull request #159 from MisakaTAT/main
feat: added an gocqhttp extended api send_forward_msg
2024-03-25 18:11:05 +08:00
MisakaTAT
cd50df3a56 feat: added an gocqhttp extended api send_forward_msg 2024-03-25 17:51:04 +08:00
linyuchen
4461c7ed47 fix: group card event old_card 2024-03-25 15:07:35 +08:00
11 changed files with 46 additions and 32 deletions

View File

@@ -1,10 +1,10 @@
{ {
"manifest_version": 4, "manifest_version": 4,
"type": "extension", "type": "extension",
"name": "LLOneBot v3.19.3", "name": "LLOneBot v3.19.4",
"slug": "LLOneBot", "slug": "LLOneBot",
"description": "使你的NTQQ支持OneBot11协议进行QQ机器人开发, 不支持商店在线更新", "description": "使你的NTQQ支持OneBot11协议进行QQ机器人开发, 不支持商店在线更新",
"version": "3.19.3", "version": "3.19.4",
"icon": "./icon.jpg", "icon": "./icon.jpg",
"authors": [ "authors": [
{ {

View File

@@ -47,7 +47,7 @@ export class NTQQFileApi {
} }
// 上传文件到QQ的文件夹 // 上传文件到QQ的文件夹
static async uploadFile(filePath: string, elementType: ElementType = ElementType.PIC) { static async uploadFile(filePath: string, elementType: ElementType = ElementType.PIC, elementSubType: number = 0) {
const md5 = await NTQQFileApi.getFileMd5(filePath); const md5 = await NTQQFileApi.getFileMd5(filePath);
let ext = (await NTQQFileApi.getFileType(filePath))?.ext let ext = (await NTQQFileApi.getFileType(filePath))?.ext
if (ext) { if (ext) {
@@ -66,7 +66,7 @@ export class NTQQFileApi {
md5HexStr: md5, md5HexStr: md5,
fileName: fileName, fileName: fileName,
elementType: elementType, elementType: elementType,
elementSubType: 0, elementSubType,
thumbSize: 0, thumbSize: 0,
needCreate: true, needCreate: true,
downloadType: 1, downloadType: 1,
@@ -81,7 +81,8 @@ export class NTQQFileApi {
md5, md5,
fileName, fileName,
path: mediaPath, path: mediaPath,
fileSize fileSize,
ext
} }
} }

View File

@@ -62,32 +62,32 @@ export class SendMsgElementConstructor {
} }
} }
static async pic(picPath: string, summary: string = ""): Promise<SendPicElement> { static async pic(picPath: string, summary: string = "", subType: 0|1=0): Promise<SendPicElement> {
const {md5, fileName, path, fileSize} = await NTQQFileApi.uploadFile(picPath, ElementType.PIC); const {md5, fileName, path, fileSize, ext} = await NTQQFileApi.uploadFile(picPath, ElementType.PIC, subType);
if (fileSize === 0) { if (fileSize === 0) {
throw "文件异常大小为0"; throw "文件异常大小为0";
} }
const imageSize = await NTQQFileApi.getImageSize(picPath); const imageSize = await NTQQFileApi.getImageSize(picPath);
const picElement = { const picElement = {
md5HexStr: md5, md5HexStr: md5,
fileSize: fileSize, fileSize: fileSize.toString(),
picWidth: imageSize.width, picWidth: imageSize.width,
picHeight: imageSize.height, picHeight: imageSize.height,
fileName: fileName, fileName: md5 + ext,
sourcePath: path, sourcePath: path,
original: true, original: true,
picType: isGIF(picPath) ? PicType.gif : PicType.jpg, picType: isGIF(picPath) ? PicType.gif : PicType.jpg,
picSubType: 0, picSubType: subType,
fileUuid: "", fileUuid: "",
fileSubId: "", fileSubId: "",
thumbFileSize: 0, thumbFileSize: 0,
summary, summary
}; };
log("图片信息", picElement)
return { return {
elementType: ElementType.PIC, elementType: ElementType.PIC,
elementId: "", elementId: "",
picElement picElement,
}; };
} }
@@ -118,7 +118,7 @@ export class SendMsgElementConstructor {
let thumb = path.replace(`${pathLib.sep}Ori${pathLib.sep}`, `${pathLib.sep}Thumb${pathLib.sep}`) let thumb = path.replace(`${pathLib.sep}Ori${pathLib.sep}`, `${pathLib.sep}Thumb${pathLib.sep}`)
thumb = pathLib.dirname(thumb) thumb = pathLib.dirname(thumb)
// log("thumb 目录", thumb) // log("thumb 目录", thumb)
let videoInfo ={ let videoInfo = {
width: 1920, height: 1080, width: 1920, height: 1080,
time: 15, time: 15,
format: "mp4", format: "mp4",
@@ -128,7 +128,7 @@ export class SendMsgElementConstructor {
try { try {
videoInfo = await getVideoInfo(path); videoInfo = await getVideoInfo(path);
log("视频信息", videoInfo) log("视频信息", videoInfo)
}catch (e) { } catch (e) {
log("获取视频信息失败", e) log("获取视频信息失败", e)
} }
const createThumb = new Promise<string>((resolve, reject) => { const createThumb = new Promise<string>((resolve, reject) => {

View File

@@ -49,24 +49,29 @@ export enum PicType {
jpg = 1000 jpg = 1000
} }
export enum PicSubType {
normal = 0, // 普通图片,大图
face = 1 // 表情包小图
}
export interface SendPicElement { export interface SendPicElement {
elementType: ElementType.PIC, elementType: ElementType.PIC,
elementId: "", elementId: "",
picElement: { picElement: {
md5HexStr: string, md5HexStr: string,
fileSize: number, fileSize: number | string,
picWidth: number, picWidth: number,
picHeight: number, picHeight: number,
fileName: string, fileName: string,
sourcePath: string, sourcePath: string,
original: boolean, original: boolean,
picType: PicType, picType: PicType,
picSubType: number, picSubType: PicSubType,
fileUuid: string, fileUuid: string,
fileSubId: string, fileSubId: string,
thumbFileSize: number, thumbFileSize: number,
summary: string, summary: string,
} },
} }
export interface SendReplyElement { export interface SendReplyElement {
@@ -200,7 +205,7 @@ export interface GrayTipElement {
xmlElement: { xmlElement: {
content: string; content: string;
}, },
jsonGrayTipElement:{ jsonGrayTipElement: {
jsonStr: string; jsonStr: string;
} }
} }
@@ -248,6 +253,7 @@ export interface MarketFaceElement {
], ],
"apngSupportSize": null "apngSupportSize": null
} }
export interface VideoElement { export interface VideoElement {
"filePath": string, "filePath": string,
"fileName": string, "fileName": string,

View File

@@ -2,17 +2,19 @@ import SendMsg, {convertMessage2List} from "../msg/SendMsg";
import {OB11PostSendMsg} from "../../types"; import {OB11PostSendMsg} from "../../types";
import {ActionName} from "../types"; import {ActionName} from "../types";
export class GoCQHTTPSendGroupForwardMsg extends SendMsg { export class GoCQHTTPSendForwardMsg extends SendMsg {
actionName = ActionName.GoCQHTTP_SendGroupForwardMsg; actionName = ActionName.GoCQHTTP_SendForwardMsg;
protected async check(payload: OB11PostSendMsg) { protected async check(payload: OB11PostSendMsg) {
if (payload.messages){ if (payload.messages) payload.message = convertMessage2List(payload.messages);
payload.message = convertMessage2List(payload.messages);
}
return super.check(payload); return super.check(payload);
} }
} }
export class GoCQHTTPSendPrivateForwardMsg extends GoCQHTTPSendGroupForwardMsg { export class GoCQHTTPSendPrivateForwardMsg extends GoCQHTTPSendForwardMsg {
actionName = ActionName.GoCQHTTP_SendPrivateForwardMsg; actionName = ActionName.GoCQHTTP_SendPrivateForwardMsg;
}
export class GoCQHTTPSendGroupForwardMsg extends GoCQHTTPSendForwardMsg {
actionName = ActionName.GoCQHTTP_SendGroupForwardMsg;
} }

View File

@@ -14,7 +14,7 @@ import GetVersionInfo from "./system/GetVersionInfo";
import CanSendRecord from "./system/CanSendRecord"; import CanSendRecord from "./system/CanSendRecord";
import CanSendImage from "./system/CanSendImage"; import CanSendImage from "./system/CanSendImage";
import GetStatus from "./system/GetStatus"; import GetStatus from "./system/GetStatus";
import {GoCQHTTPSendGroupForwardMsg, GoCQHTTPSendPrivateForwardMsg} from "./go-cqhttp/SendForwardMsg"; import {GoCQHTTPSendForwardMsg, GoCQHTTPSendGroupForwardMsg, GoCQHTTPSendPrivateForwardMsg} from "./go-cqhttp/SendForwardMsg";
import GoCQHTTPGetStrangerInfo from "./go-cqhttp/GetStrangerInfo"; import GoCQHTTPGetStrangerInfo from "./go-cqhttp/GetStrangerInfo";
import SendLike from "./user/SendLike"; import SendLike from "./user/SendLike";
import SetGroupAddRequest from "./group/SetGroupAddRequest"; import SetGroupAddRequest from "./group/SetGroupAddRequest";
@@ -73,6 +73,7 @@ export const actionHandlers = [
new CleanCache(), new CleanCache(),
//以下为go-cqhttp api //以下为go-cqhttp api
new GoCQHTTPSendForwardMsg(),
new GoCQHTTPSendGroupForwardMsg(), new GoCQHTTPSendGroupForwardMsg(),
new GoCQHTTPSendPrivateForwardMsg(), new GoCQHTTPSendPrivateForwardMsg(),
new GoCQHTTPGetStrangerInfo(), new GoCQHTTPGetStrangerInfo(),

View File

@@ -2,7 +2,7 @@ import {
AtType, AtType,
ChatType, ChatType,
ElementType, ElementType,
Group, Group, PicSubType,
RawMessage, RawMessage,
SendArkElement, SendArkElement,
SendMessageElement SendMessageElement
@@ -188,7 +188,7 @@ export async function createSendElements(messageData: OB11MessageData[], group:
} else if (sendMsg.type === OB11MessageDataType.voice) { } else if (sendMsg.type === OB11MessageDataType.voice) {
sendElements.push(await SendMsgElementConstructor.ptt(path)); sendElements.push(await SendMsgElementConstructor.ptt(path));
} else if (sendMsg.type === OB11MessageDataType.image) { } else if (sendMsg.type === OB11MessageDataType.image) {
sendElements.push(await SendMsgElementConstructor.pic(path, sendMsg.data.summary || "")); sendElements.push(await SendMsgElementConstructor.pic(path, sendMsg.data.summary || "", <PicSubType>parseInt(sendMsg.data?.subType?.toString()) || 0));
} }
} }
} }

View File

@@ -51,6 +51,7 @@ export enum ActionName {
GetRecord = "get_record", GetRecord = "get_record",
CleanCache = "clean_cache", CleanCache = "clean_cache",
// 以下为go-cqhttp api // 以下为go-cqhttp api
GoCQHTTP_SendForwardMsg = "send_forward_msg",
GoCQHTTP_SendGroupForwardMsg = "send_group_forward_msg", GoCQHTTP_SendGroupForwardMsg = "send_group_forward_msg",
GoCQHTTP_SendPrivateForwardMsg = "send_private_forward_msg", GoCQHTTP_SendPrivateForwardMsg = "send_private_forward_msg",
GoCQHTTP_GetStrangerInfo = "get_stranger_info", GoCQHTTP_GetStrangerInfo = "get_stranger_info",

View File

@@ -227,8 +227,9 @@ export class OB11Constructor {
if (msg.senderUin){ if (msg.senderUin){
let member = await getGroupMember(msg.peerUid, msg.senderUin); let member = await getGroupMember(msg.peerUid, msg.senderUin);
if (member && member.cardName !== msg.sendMemberName) { if (member && member.cardName !== msg.sendMemberName) {
const event = new OB11GroupCardEvent(parseInt(msg.peerUid), parseInt(msg.senderUin), msg.sendMemberName, member.cardName)
member.cardName = msg.sendMemberName; member.cardName = msg.sendMemberName;
return new OB11GroupCardEvent(parseInt(msg.peerUid), parseInt(msg.senderUin), msg.sendMemberName, member.cardName) return event
} }
} }
// log("group msg", msg); // log("group msg", msg);

View File

@@ -1,4 +1,4 @@
import {RawMessage} from "../ntqqapi/types"; import {PicSubType, RawMessage} from "../ntqqapi/types";
import {EventType} from "./event/OB11BaseEvent"; import {EventType} from "./event/OB11BaseEvent";
export interface OB11User { export interface OB11User {
@@ -134,11 +134,13 @@ interface OB11MessageFileBase {
} }
} }
export interface OB11MessageImage extends OB11MessageFileBase { export interface OB11MessageImage extends OB11MessageFileBase {
type: OB11MessageDataType.image type: OB11MessageDataType.image
data: OB11MessageFileBase['data'] & { data: OB11MessageFileBase['data'] & {
summary ? : string; // 图片摘要 summary ? : string; // 图片摘要
} subType?: PicSubType
},
} }
export interface OB11MessageRecord extends OB11MessageFileBase { export interface OB11MessageRecord extends OB11MessageFileBase {

View File

@@ -1 +1 @@
export const version = "3.19.3" export const version = "3.19.4"