mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
fix
This commit is contained in:
parent
9200520f70
commit
d3f91a832b
@ -101,7 +101,6 @@ export class NTQQPacketApi {
|
||||
try {
|
||||
let packet = this.packetPacker.packStatusPacket(uin);
|
||||
let ret = await this.core.apis.PacketApi.sendPacket('OidbSvcTrpcTcp.0xfe1_2', packet, true);
|
||||
console.log('ret: ', ret);
|
||||
let data = Buffer.from(ret.hex_data, 'hex');
|
||||
let ext = new NapProtoMsg(OidbSvcTrpcTcp0XFE1_2RSP).decode(new NapProtoMsg(OidbSvcTrpcTcpBase).decode(data).body).data.status.value;
|
||||
// ext & 0xff00 + ext >> 16 & 0xff
|
||||
@ -118,6 +117,5 @@ export class NTQQPacketApi {
|
||||
async sendSetSpecialTittlePacket(groupCode: string, uid: string, tittle: string) {
|
||||
let data = this.packetPacker.packSetSpecialTittlePacket(groupCode, uid, tittle);
|
||||
let ret = await this.core.apis.PacketApi.sendPacket('OidbSvcTrpcTcp.0x8fc_2', data, true);
|
||||
console.log('ret: ', ret);
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ export class PacketPacker {
|
||||
groupUin: +groupCode,
|
||||
body: oidb_0x8FC_2_body
|
||||
});
|
||||
return this.toHexStr(this.packOidbPacket(0x8FC, 2, oidb_0x8FC_2));
|
||||
return this.toHexStr(this.packOidbPacket(0x8FC, 2, oidb_0x8FC_2, false, false));
|
||||
}
|
||||
|
||||
packStatusPacket(uin: number): PacketHexStr {
|
||||
@ -75,17 +75,4 @@ export class PacketPacker {
|
||||
});
|
||||
return this.toHexStr(this.packOidbPacket(0xfe1, 2, oidb_0xfe1_2));
|
||||
}
|
||||
packSetSpecialTittle(groupCode: string, uid: string, tittle: string): PacketHexStr {
|
||||
const oidb_0x8FC_2_body = new NapProtoMsg(OidbSvcTrpcTcp0X8FC_2_Body).encode({
|
||||
targetUid: uid,
|
||||
specialTitle: tittle,
|
||||
expiredTime: -1,
|
||||
uinName: tittle
|
||||
});
|
||||
const oidb_0x8FC_2 = new NapProtoMsg(OidbSvcTrpcTcp0X8FC_2).encode({
|
||||
groupUin: +groupCode,
|
||||
body: oidb_0x8FC_2_body
|
||||
});
|
||||
return this.toHexStr(this.packOidbPacket(0x8FC, 2, oidb_0x8FC_2));
|
||||
}
|
||||
}
|
||||
|
28
src/onebot/action/extends/SetSpecialTittle.ts
Normal file
28
src/onebot/action/extends/SetSpecialTittle.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
group_id: { type: ['number', 'string'] },
|
||||
user_id: { type: ['number', 'string'] },
|
||||
special_title: { type: 'string' },
|
||||
},
|
||||
required: ['group_id', 'user_id', 'special_title'],
|
||||
} as const satisfies JSONSchema;
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export class SetSpecialTittle extends BaseAction<Payload, any> {
|
||||
actionName = ActionName.SetSpecialTittle;
|
||||
payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
if (!this.core.apis.PacketApi.packetClient?.isConnected) {
|
||||
throw new Error('PacketClient is not init');
|
||||
}
|
||||
let uid = await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString());
|
||||
if(!uid) throw new Error('User not found');
|
||||
await this.core.apis.PacketApi.sendSetSpecialTittlePacket(payload.group_id.toString(), uid, payload.special_title);
|
||||
}
|
||||
}
|
@ -87,6 +87,7 @@ import { GetGroupSystemMsg } from './system/GetSystemMsg';
|
||||
import { GroupPoke } from './group/GroupPoke';
|
||||
import { GetUserStatus } from './extends/GetUserStatus';
|
||||
import { GetRkey } from './extends/GetRkey';
|
||||
import { SetSpecialTittle } from './extends/SetSpecialTittle';
|
||||
|
||||
|
||||
export type ActionMap = Map<string, BaseAction<any, any>>;
|
||||
@ -186,6 +187,7 @@ export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCo
|
||||
new GroupPoke(obContext, core),
|
||||
new GetUserStatus(obContext, core),
|
||||
new GetRkey(obContext, core),
|
||||
new SetSpecialTittle(obContext, core),
|
||||
];
|
||||
const actionMap = new Map();
|
||||
for (const action of actionHandlers) {
|
||||
|
@ -122,4 +122,5 @@ export enum ActionName {
|
||||
FetchUserProfileLike = "fetch_user_profile_like",
|
||||
GetUserStatus = "nc_get_user_status",
|
||||
GetRkey = "nc_get_rkey",
|
||||
SetSpecialTittle = "set_group_special_title",
|
||||
}
|
||||
|
@ -541,16 +541,16 @@ export class NapCatOneBot11Adapter {
|
||||
if (isSelfMsg) {
|
||||
ob11Msg.target_id = parseInt(message.peerUin);
|
||||
}
|
||||
if (ob11Msg.raw_message.startsWith('!set')) {
|
||||
this.core.apis.UserApi.getUidByUinV2(ob11Msg.user_id.toString()).then(uid => {
|
||||
if(uid){
|
||||
this.core.apis.PacketApi.sendSetSpecialTittlePacket(message.peerUin, uid, '测试');
|
||||
console.log('set', message.peerUin, uid);
|
||||
}
|
||||
// if (ob11Msg.raw_message.startsWith('!set')) {
|
||||
// this.core.apis.UserApi.getUidByUinV2(ob11Msg.user_id.toString()).then(uid => {
|
||||
// if(uid){
|
||||
// this.core.apis.PacketApi.sendSetSpecialTittlePacket(message.peerUin, uid, '测试');
|
||||
// console.log('set', message.peerUin, uid);
|
||||
// }
|
||||
|
||||
});
|
||||
// });
|
||||
|
||||
}
|
||||
// }
|
||||
// if (ob11Msg.raw_message.startsWith('!status')) {
|
||||
// console.log('status', message.peerUin, message.senderUin);
|
||||
// let delMsg: string[] = [];
|
||||
|
Loading…
x
Reference in New Issue
Block a user