mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
698649f981
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,6 +1,7 @@
|
||||
# Develop
|
||||
node_modules/
|
||||
package-lock.json
|
||||
pnpm-lock.yaml
|
||||
out/
|
||||
dist/
|
||||
src/core.lib/common/
|
||||
@ -13,4 +14,4 @@ test
|
||||
|
||||
# Build
|
||||
*.db
|
||||
checkVersion.sh
|
||||
checkVersion.sh
|
||||
|
@ -3,6 +3,7 @@
|
||||
QQ Version: Windows 9.9.9-23424 / Linux 3.2.7-23361
|
||||
|
||||
## 修复与优化
|
||||
* 重置Rkey获取机制,使用接口分发Rkey
|
||||
|
||||
## 新增与调整
|
||||
* 新增获取好友列表Api /get_friend_category
|
||||
|
2
src/core
2
src/core
@ -1 +1 @@
|
||||
Subproject commit 934d336bbdd2ac59a2b5d025bf4c0d7b2879bf54
|
||||
Subproject commit 85d0256dbcc9cf0d1773da3f10cfc180be1ab56b
|
@ -314,14 +314,18 @@ export async function createSendElements(messageData: OB11MessageData[], group:
|
||||
break;
|
||||
}
|
||||
}
|
||||
const musicMsgElement = await genMusicElement(sendMsg.data);
|
||||
const postData = { ...sendMsg.data } as IdMusicSignPostData | CustomMusicSignPostData;
|
||||
if (sendMsg.data.type === 'custom' && sendMsg.data.content) {
|
||||
(postData as CustomMusicSignPostData).singer = sendMsg.data.content;
|
||||
delete (postData as OB11MessageCustomMusic['data']).content;
|
||||
}
|
||||
const musicMsgElement = await genMusicElement(postData);
|
||||
logDebug('生成音乐消息', musicMsgElement);
|
||||
if (musicMsgElement) {
|
||||
sendElements.push(musicMsgElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -86,7 +86,8 @@ export class NapCatOnebot11 {
|
||||
// console.log('ob11 onRecvMsg', JSON.stringify(msg, null, 2));
|
||||
logDebug('收到消息', msg);
|
||||
for (const m of msg) {
|
||||
if (this.bootTime > parseInt(m.msgTime)) {
|
||||
// try: 减掉3s 试图修复消息半天收不到
|
||||
if (this.bootTime - 3> parseInt(m.msgTime)) {
|
||||
logDebug(`消息时间${m.msgTime}早于启动时间${this.bootTime},忽略上报`);
|
||||
continue;
|
||||
}
|
||||
|
58
src/onebot11/rkey.ts
Normal file
58
src/onebot11/rkey.ts
Normal file
@ -0,0 +1,58 @@
|
||||
//远端rkey获取
|
||||
class ServerRkeyWrapper {
|
||||
serverUrl: string = "";
|
||||
GroupRkey: string = "";
|
||||
PrivateRkey: string = "";
|
||||
expired_time: number = 0;
|
||||
async Init(ServerUrl: string) {
|
||||
this.serverUrl = ServerUrl;
|
||||
}
|
||||
async GetGroupRkey(): Promise<string> {
|
||||
if (await this.IsRkeyExpired()) {
|
||||
await this.RefreshRkey();
|
||||
}
|
||||
return this.GroupRkey;
|
||||
}
|
||||
async GetPrivateRkey(): Promise<string> {
|
||||
if (await this.IsRkeyExpired()) {
|
||||
await this.RefreshRkey();
|
||||
}
|
||||
return this.PrivateRkey;
|
||||
}
|
||||
async IsRkeyExpired(): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
let now = new Date().getTime();
|
||||
if (now > this.expired_time || this.expired_time == 0) {
|
||||
resolve(true);
|
||||
} else {
|
||||
resolve(false);
|
||||
}
|
||||
reject("error");
|
||||
});
|
||||
}
|
||||
async RefreshRkey(): Promise<any> {
|
||||
//刷新rkey
|
||||
let data = await this.Internal_RefreshRkey();
|
||||
this.GroupRkey = data.group_rkey;
|
||||
this.PrivateRkey = data.private_rkey;
|
||||
this.expired_time = data.expired_time;
|
||||
}
|
||||
async Internal_RefreshRkey(): Promise<any> {
|
||||
return new Promise((resolve, reject) => {
|
||||
fetch(this.serverUrl)
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
reject(response.statusText); // 请求失败,返回错误信息
|
||||
}
|
||||
return response.json(); // 解析 JSON 格式的响应体
|
||||
})
|
||||
.then(data => {
|
||||
resolve(data);
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
export const serverRkey = new ServerRkeyWrapper();
|
@ -212,7 +212,7 @@ export interface OB11MessageIdMusic {
|
||||
}
|
||||
export interface OB11MessageCustomMusic {
|
||||
type: OB11MessageDataType.music
|
||||
data: CustomMusicSignPostData
|
||||
data: Omit<CustomMusicSignPostData, 'singer'> & { content?: string }
|
||||
}
|
||||
|
||||
export interface OB11MessageJson {
|
||||
|
Loading…
x
Reference in New Issue
Block a user