mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
chore: token
This commit is contained in:
parent
3294079b72
commit
deeab036d3
src/onebot
@ -99,7 +99,7 @@ export class NapCatOneBot11Adapter {
|
|||||||
if (ob11Config.reverseWs.enable) {
|
if (ob11Config.reverseWs.enable) {
|
||||||
ob11Config.reverseWs.urls.forEach(url => {
|
ob11Config.reverseWs.urls.forEach(url => {
|
||||||
this.networkManager.registerAdapter(new OB11ActiveWebSocketAdapter(
|
this.networkManager.registerAdapter(new OB11ActiveWebSocketAdapter(
|
||||||
url, 5000, ob11Config.heartInterval, this.core, this
|
url, 5000, ob11Config.heartInterval, ob11Config.token, this.core, this
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,11 @@ export class OB11ActiveWebSocketAdapter implements IOB11NetworkAdapter {
|
|||||||
private heartbeatTimer: NodeJS.Timeout | null = null;
|
private heartbeatTimer: NodeJS.Timeout | null = null;
|
||||||
onebotContext: NapCatOneBot11Adapter;
|
onebotContext: NapCatOneBot11Adapter;
|
||||||
coreContext: NapCatCore;
|
coreContext: NapCatCore;
|
||||||
|
token: string;
|
||||||
|
|
||||||
constructor(url: string, reconnectIntervalInMillis: number, heartbeatInterval: number, coreContext: NapCatCore, onebotContext: NapCatOneBot11Adapter) {
|
constructor(url: string, reconnectIntervalInMillis: number, heartbeatInterval: number, token:string, coreContext: NapCatCore, onebotContext: NapCatOneBot11Adapter) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
|
this.token = token;
|
||||||
this.heartbeatInterval = heartbeatInterval;
|
this.heartbeatInterval = heartbeatInterval;
|
||||||
this.reconnectIntervalInMillis = reconnectIntervalInMillis;
|
this.reconnectIntervalInMillis = reconnectIntervalInMillis;
|
||||||
this.coreContext = coreContext;
|
this.coreContext = coreContext;
|
||||||
@ -72,7 +74,14 @@ export class OB11ActiveWebSocketAdapter implements IOB11NetworkAdapter {
|
|||||||
private async tryConnect() {
|
private async tryConnect() {
|
||||||
while (!this.connection && !this.isClosed) {
|
while (!this.connection && !this.isClosed) {
|
||||||
try {
|
try {
|
||||||
this.connection = new NodeWebSocket(this.url);
|
this.connection = new NodeWebSocket(this.url, {
|
||||||
|
headers: {
|
||||||
|
'X-Self-ID': this.coreContext.selfInfo.uin,
|
||||||
|
'Authorization': `Bearer ${this.token}`,
|
||||||
|
'x-client-role': 'Universal', // koishi-adapter-onebot 需要这个字段
|
||||||
|
'User-Agent': 'OneBot/11',
|
||||||
|
}
|
||||||
|
});
|
||||||
this.connection.on('message', (data) => {
|
this.connection.on('message', (data) => {
|
||||||
this.handleMessage(data);
|
this.handleMessage(data);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user