Compare commits

..

8 Commits

Author SHA1 Message Date
linyuchen
ecd64529a4 chore: ver 3.20.5 2024-03-30 13:50:17 +08:00
linyuchen
016482c9e5 fix: friend request flag invalid 2024-03-30 13:48:06 +08:00
linyuchen
23be081d29 fix: some png can not send 2024-03-30 12:02:38 +08:00
linyuchen
33688e9e5c fix: image url can not access when appid=1406 2024-03-30 11:52:00 +08:00
linyuchen
de8c2e1168 chore: ver 3.20.3 2024-03-29 21:42:07 +08:00
linyuchen
2a1fc07b94 fix: image rkey expired 2024-03-29 21:26:29 +08:00
linyuchen
c1b6daaf32 refactor: emmm 2024-03-29 01:30:05 +08:00
linyuchen
02c973fe5e refactor: optimize save image rkey 2024-03-29 01:26:38 +08:00
7 changed files with 31 additions and 23 deletions

View File

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

View File

@@ -354,8 +354,9 @@ function onLoad() {
registerReceiveHook<FriendRequestNotify>(ReceiveCmdS.FRIEND_REQUEST, async (payload) => { registerReceiveHook<FriendRequestNotify>(ReceiveCmdS.FRIEND_REQUEST, async (payload) => {
for (const req of payload.data.buddyReqs) { for (const req of payload.data.buddyReqs) {
if (req.isUnread && !friendRequests[req.sourceId] && (parseInt(req.reqTime) > startTime / 1000)) { let flag = req.friendUid + req.reqTime;
friendRequests[req.sourceId] = req; if (req.isUnread && (parseInt(req.reqTime) > startTime / 1000)) {
friendRequests[flag] = req;
log("有新的好友请求", req); log("有新的好友请求", req);
let friendRequestEvent = new OB11FriendRequestEvent(); let friendRequestEvent = new OB11FriendRequestEvent();
try { try {
@@ -364,7 +365,7 @@ function onLoad() {
} catch (e) { } catch (e) {
log("获取加好友者QQ号失败", e); log("获取加好友者QQ号失败", e);
} }
friendRequestEvent.flag = req.sourceId.toString(); friendRequestEvent.flag = flag;
friendRequestEvent.comment = req.extWords; friendRequestEvent.comment = req.extWords;
postOB11Event(friendRequestEvent); postOB11Event(friendRequestEvent);
} }

View File

@@ -37,10 +37,10 @@ export class NTQQFriendApi{
}, null] }, null]
}) })
} }
static async handleFriendRequest(sourceId: number, accept: boolean,) { static async handleFriendRequest(flag: string, accept: boolean,) {
const request: FriendRequest = friendRequests[sourceId] const request: FriendRequest = friendRequests[flag]
if (!request) { if (!request) {
throw `sourceId ${sourceId}, 对应的好友请求不存在` throw `flat: ${flag}, 对应的好友请求不存在`
} }
const result = await callNTQQApi<GeneralCallResult>({ const result = await callNTQQApi<GeneralCallResult>({
methodName: NTQQApiMethod.HANDLE_FRIEND_REQUEST, methodName: NTQQApiMethod.HANDLE_FRIEND_REQUEST,
@@ -54,7 +54,7 @@ export class NTQQFriendApi{
} }
] ]
}) })
delete friendRequests[sourceId]; delete friendRequests[flag];
return result; return result;
} }

View File

@@ -63,7 +63,7 @@ export class SendMsgElementConstructor {
} }
static async pic(picPath: string, summary: string = "", subType: 0|1=0): Promise<SendPicElement> { static async pic(picPath: string, summary: string = "", subType: 0|1=0): Promise<SendPicElement> {
const {md5, fileName, path, fileSize, ext} = await NTQQFileApi.uploadFile(picPath, ElementType.PIC, subType); const {md5, fileName, path, fileSize} = await NTQQFileApi.uploadFile(picPath, ElementType.PIC, subType);
if (fileSize === 0) { if (fileSize === 0) {
throw "文件异常大小为0"; throw "文件异常大小为0";
} }
@@ -73,7 +73,7 @@ export class SendMsgElementConstructor {
fileSize: fileSize.toString(), fileSize: fileSize.toString(),
picWidth: imageSize.width, picWidth: imageSize.width,
picHeight: imageSize.height, picHeight: imageSize.height,
fileName: md5 + ext, fileName: fileName,
sourcePath: path, sourcePath: path,
original: true, original: true,
picType: isGIF(picPath) ? PicType.gif : PicType.jpg, picType: isGIF(picPath) ? PicType.gif : PicType.jpg,

View File

@@ -13,7 +13,7 @@ export default class SetFriendAddRequest extends BaseAction<Payload, null> {
protected async _handle(payload: Payload): Promise<null> { protected async _handle(payload: Payload): Promise<null> {
const approve = payload.approve.toString() === "true"; const approve = payload.approve.toString() === "true";
await NTQQFriendApi.handleFriendRequest(parseInt(payload.flag), approve) await NTQQFriendApi.handleFriendRequest(payload.flag, approve)
return null; return null;
} }
} }

View File

@@ -40,11 +40,12 @@ import {OB11GroupTitleEvent} from "./event/notice/OB11GroupTitleEvent";
import {OB11GroupCardEvent} from "./event/notice/OB11GroupCardEvent"; import {OB11GroupCardEvent} from "./event/notice/OB11GroupCardEvent";
import {OB11GroupDecreaseEvent} from "./event/notice/OB11GroupDecreaseEvent"; import {OB11GroupDecreaseEvent} from "./event/notice/OB11GroupDecreaseEvent";
let lastRKeyUpdateTime = 0;
export class OB11Constructor { export class OB11Constructor {
static async message(msg: RawMessage): Promise<OB11Message> { static async message(msg: RawMessage): Promise<OB11Message> {
let config = getConfigUtil().getConfig(); let config = getConfigUtil().getConfig();
const {enableLocalFile2Url, ob11: {messagePostFormat}} = getConfigUtil().getConfig() const {enableLocalFile2Url, ob11: {messagePostFormat}} = config;
const message_type = msg.chatType == ChatType.group ? "group" : "private"; const message_type = msg.chatType == ChatType.group ? "group" : "private";
const resMsg: OB11Message = { const resMsg: OB11Message = {
self_id: parseInt(selfInfo.uin), self_id: parseInt(selfInfo.uin),
@@ -140,21 +141,27 @@ export class OB11Constructor {
// message_data["data"]["path"] = element.picElement.sourcePath // message_data["data"]["path"] = element.picElement.sourcePath
const url = element.picElement.originImageUrl const url = element.picElement.originImageUrl
const fileMd5 = element.picElement.md5HexStr const fileMd5 = element.picElement.md5HexStr
let currentRKey = config.imageRKey || "CAQSKAB6JWENi5LMk0kc62l8Pm3Jn1dsLZHyRLAnNmHGoZ3y_gDZPqZt-64" const fileUuid = element.picElement.fileUuid
// let currentRKey = config.imageRKey || "CAQSKAB6JWENi5LMk0kc62l8Pm3Jn1dsLZHyRLAnNmHGoZ3y_gDZPqZt-64"
let currentRKey = "CAQSKAB6JWENi5LMk0kc62l8Pm3Jn1dsLZHyRLAnNmHGoZ3y_gDZPqZt-64"
if (url) { if (url) {
if (url.startsWith("/download")) { if (url.startsWith("/download")) {
if (url.includes("&rkey=")) { if (url.includes("&rkey=")) {
// 正则提取rkey // 正则提取rkey
const rkey = url.match(/&rkey=([^&]+)/)[1] // const rkey = url.match(/&rkey=([^&]+)/)[1]
// log("图片url已有rkey", rkey) // // log("图片url已有rkey", rkey)
if (rkey != currentRKey){ // if (rkey != currentRKey){
config.imageRKey = rkey // config.imageRKey = rkey
getConfigUtil().setConfig(config) // if (Date.now() - lastRKeyUpdateTime > 1000 * 60) {
} // lastRKeyUpdateTime = Date.now()
message_data["data"]["url"] = IMAGE_HTTP_HOST_NT + url // getConfigUtil().setConfig(config)
// }
// }
message_data["data"]["url"] = IMAGE_HTTP_HOST + url
} }
else{ else{
message_data["data"]["url"] = IMAGE_HTTP_HOST_NT + url + "&rkey=" + currentRKey // 有可能会碰到appid为1406的这个不能使用新的NT域名并且需要把appid改为1407才可访问
message_data["data"]["url"] = `${IMAGE_HTTP_HOST}/download?appid=1407&fileid=${fileUuid}&rkey=${currentRKey}&spec=0`
} }
} else { } else {
message_data["data"]["url"] = IMAGE_HTTP_HOST + url message_data["data"]["url"] = IMAGE_HTTP_HOST + url

View File

@@ -1 +1 @@
export const version = "3.20.2" export const version = "3.20.5"